添加了能撞掉荷叶的功能

This commit is contained in:
17146 2024-12-12 14:17:50 +08:00
parent 281232e2a4
commit 4558b84e30

View file

@ -109,14 +109,13 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
} }
//TODO 创飞碰到的碰撞箱小于该船的实体且本体速度不会减少太多 //TODO 创飞碰到的碰撞箱小于该船的实体且本体速度不会减少太多
public static boolean canVehicleCollide(Entity pVehicle, Entity pEntity) { public static boolean canVehicleCollide(Entity pVehicle, Entity pEntity) {
return (pEntity.canBeCollidedWith() || pEntity.isPushable()) && !pVehicle.isPassengerOfSameVehicle(pEntity); return (pEntity.canBeCollidedWith() || pEntity.isPushable()) && !pVehicle.isPassengerOfSameVehicle(pEntity);
} }
@Override @Override
public boolean canBeCollidedWith() { public boolean canBeCollidedWith() {
return false; return super.canBeCollidedWith();
} }
@Override @Override
@ -256,7 +255,7 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
crushEntities(this.getDeltaMovement()); crushEntities(this.getDeltaMovement());
} }
collBlock(); collideBlock();
this.refreshDimensions(); this.refreshDimensions();
} }
@ -277,15 +276,13 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
} }
} }
public void collBlock() { public void collideBlock() {
AABB aabb = AABB.ofSize(new Vec3(this.getX(), this.getY() + this.getBbHeight() * 0.5, this.getZ()), 5, 2.6, 5); AABB aabb = AABB.ofSize(new Vec3(this.getX(), this.getY() + this.getBbHeight() * 0.5, this.getZ()), 5, 2.6, 5);
BlockPos.betweenClosedStream(aabb).forEach((block) -> { BlockPos.betweenClosedStream(aabb).forEach((pos) -> {
BlockState blockstate = this.level().getBlockState(block); BlockState blockstate = this.level().getBlockState(pos);
if (blockstate.is(Blocks.LILY_PAD)) { if (blockstate.is(Blocks.LILY_PAD)) {
BlockPos blockPos = BlockPos.containing(new Vec3(block.getX(), block.getY(), block.getY())); this.level().destroyBlock(pos, true);
this.level().destroyBlock(blockPos, true);
} }
}); });
} }
@ -443,7 +440,6 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
this.clampRotation(entity); this.clampRotation(entity);
} }
@Override @Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) { public void registerControllers(AnimatableManager.ControllerRegistrar data) {