添加了能撞掉荷叶的功能

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();
} }
@ -268,8 +267,8 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
double entitySize = entity.getBbWidth() * entity.getBbHeight(); double entitySize = entity.getBbWidth() * entity.getBbHeight();
double thisSize = this.getBbWidth() * this.getBbHeight(); double thisSize = this.getBbWidth() * this.getBbHeight();
double f = Math.min(entitySize / thisSize, 2); double f = Math.min(entitySize / thisSize, 2);
double f1 = thisSize / entitySize; double f1 = thisSize / entitySize;
entity.push(f1 * velAdd.x, f1 * velAdd.y, f1 * velAdd.z); entity.push(f1 * velAdd.x, f1 * velAdd.y, f1 * velAdd.z);
this.push(-f * velAdd.x, -f * velAdd.y, -f * velAdd.z); this.push(-f * velAdd.x, -f * velAdd.y, -f * velAdd.z);
@ -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);
} }
}); });
} }
@ -336,7 +333,7 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
} }
private void handleSetDiffY(float diffY) { private void handleSetDiffY(float diffY) {
this.entityData.set(DELTA_ROT, (float) Mth.clamp(diffY * 1.3 * Math.max(4 * this.getDeltaMovement().length(), 0.5), -2 ,2)); this.entityData.set(DELTA_ROT, (float) Mth.clamp(diffY * 1.3 * Math.max(4 * this.getDeltaMovement().length(), 0.5), -2, 2));
} }
private void handleClientSync() { private void handleClientSync() {
@ -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) {