Mojira Archive
MC-259315

Boats do not push some entities that have a riding cooldown, or when the boat is submerged

List<Entity> list = this.world.getOtherEntities(this, this.getBoundingBox().expand(0.2f, -0.01f, 0.2f), EntityPredicates.canBePushedBy(this));
if (!list.isEmpty()) {
            boolean bl = !this.world.isClient && !(this.getPrimaryPassenger() instanceof PlayerEntity);
   for (int j = 0; j < list.size(); ++j) {
       Entity entity = list.get(j);
       if (entity.hasPassenger(this)) continue;
       if (bl && this.getPassengerList().size() < this.getMaxPassengers() && !entity.hasVehicle() && entity.getWidth() < this.getWidth() && entity instanceof LivingEntity && !(entity instanceof WaterCreatureEntity) && !(entity instanceof PlayerEntity)) {
          entity.startRiding(this);
          continue;
       }

       this.pushAwayFrom(entity);
    }
}
 

(From BoatEntity.tick())

When the execution falls into the block where entity.startRiding(this); is in, the boat won't try to push the entity anymore. Normally, the entity should start riding the boat now, but it may fail because of the presence or riding cooldown or that the boat is submerged in water.

How to reproduce

  1. Place a boat on the ground, and push it to a corner.
  2. Summon a llama (or anything similar) riding a minecraft.
  3. Let the llama disamount near the boat so that it should be pushed by the boat and have a riding cooldown of 3 seconds.
  4. Discover that the llama is not pushed for 3 seconds before it can ride the boat. 

Possible Soluton: 

Use something like the code below instead.

if (bl && this.getPassengerList().size() < this.getMaxPassengers() && !entity.hasVehicle() && entity.getWidth() < this.getWidth() && entity instanceof LivingEntity && !(entity instanceof WaterCreatureEntity) && !(entity instanceof PlayerEntity) && entity.canStartRiding(this) && this.canAddPassenger(entity)) 

Unresolved

lovexyn0827

2023-01-22, 06:35 PM

2024-01-24, 09:05 PM

0

3

Community Consensus

Entities

1.19.3, 23w03a, 24w04a

-