mojira.dev
MC-116567

The "maxEntityCramming" gamerule doesn't apply to bats

The Bug:

The "maxEntityCramming" gamerule doesn't apply to bats.

Steps to Reproduce:

  1. Summon around fifty bats.

  2. Teleport all of the bats to your position by using the command provided below.

    /tp @e[type=minecraft:bat] @s
  3. Take note as to whether or not some of the bats received damage as a result of lots of them occupying the same space.

Observed Behavior:

The "maxEntityCramming" gamerule doesn't apply to bats.

Expected Behavior:

The "maxEntityCramming" gamerule would apply to bats.

Code Analysis:

Code analysis by @unknown can be found in this comment.

Linked issues

Attachments

Comments 10

What commands are you using? How are you testing it?

I used spawn eggs as well as the summon command. I set the maxEntityCramming gamerule to its default setting.

Its probably because of the lack of collision box

Based on MCP 1.12.2:

The reason for this is that the method for cramming is in EntityLivingBase.collideWithNearbyEntities(), and the logic is inside the same block that makes entities push each other.

List<Entity> list = this.world.getEntitiesInAABBexcluding(this, this.getEntityBoundingBox(), EntitySelectors.getTeamCollisionPredicate(this));

Bats are excluded because getTeamCollisionPreciate() returns false when the entity cannot be pushed, and EntityBat.canBePushed() simply returns false.

Since it's rather explicit that only entities that can be pushed affect cramming (and that makes logical sense), I believe this is intended.

Confirmed for 1.13.1-pre1

Can confirm in 21w41a. The expected behavior would be that bats would be affected by the "maxEntityCramming" gamerule, just like every other entity.

Can confirm in 1.18.2 and 22w19a.

TehDarga

Avoma

(Unassigned)

Confirmed

Commands, Mob behaviour

bat, maxEntityCramming

Minecraft 1.11.2, Minecraft 17w16b, Minecraft 1.12.2, Minecraft 17w45b, Minecraft 17w46a, ..., 25w08a, 1.21.5, 1.21.6, 1.21.7, 1.21.8

Retrieved