让船在无人情况下停止操作
This commit is contained in:
parent
a33ec13136
commit
944faf99e3
2 changed files with 13 additions and 4 deletions
|
@ -298,6 +298,10 @@ public class ClickHandler {
|
|||
return;
|
||||
}
|
||||
|
||||
if ((player.getVehicle() != null && player.getVehicle() instanceof SpeedboatEntity boat && boat.getFirstPassenger() == player)) {
|
||||
ModUtils.PACKET_HANDLER.sendToServer(new FireMessage(0));
|
||||
}
|
||||
|
||||
if (stack.is(ModTags.Items.GUN) && !(player.getVehicle() != null && player.getVehicle() instanceof ICannonEntity)) {
|
||||
if ((!(stack.getOrCreateTag().getBoolean("is_normal_reloading") || stack.getOrCreateTag().getBoolean("is_empty_reloading"))
|
||||
&& !stack.getOrCreateTag().getBoolean("reloading")
|
||||
|
|
|
@ -72,9 +72,6 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
|||
public float turretYRotO;
|
||||
public float turretXRotO;
|
||||
|
||||
public float rudderYRot;
|
||||
public float rudderYRot0;
|
||||
|
||||
public SpeedboatEntity(PlayMessages.SpawnEntity packet, Level world) {
|
||||
this(ModEntities.SPEEDBOAT.get(), world);
|
||||
}
|
||||
|
@ -225,7 +222,7 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
|||
|
||||
if (this.onGround()) {
|
||||
this.setDeltaMovement(this.getDeltaMovement().multiply(0.2, 0.85, 0.2));
|
||||
} else if (this.isInWater()) {
|
||||
} else {
|
||||
float f = 0.73f + 0.09f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90;
|
||||
this.setDeltaMovement(this.getDeltaMovement().add(this.getViewVector(1).normalize().scale(0.04 * this.getDeltaMovement().length())));
|
||||
this.setDeltaMovement(this.getDeltaMovement().multiply(f, 0.85, f));
|
||||
|
@ -250,6 +247,7 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
|||
|
||||
collideBlock();
|
||||
gunnerAngle();
|
||||
// gunnerFire();
|
||||
|
||||
this.refreshDimensions();
|
||||
}
|
||||
|
@ -291,6 +289,13 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
|||
private void controlBoat() {
|
||||
Entity passenger0 = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0);
|
||||
|
||||
if (passenger0 == null) {
|
||||
this.getPersistentData().putBoolean("left", false);
|
||||
this.getPersistentData().putBoolean("right", false);
|
||||
this.getPersistentData().putBoolean("forward", false);
|
||||
this.getPersistentData().putBoolean("backward", false);
|
||||
}
|
||||
|
||||
float diffY = 0;
|
||||
if (this.getPersistentData().getBoolean("forward")) {
|
||||
this.entityData.set(POWER, this.entityData.get(POWER) + 0.02f);
|
||||
|
|
Loading…
Add table
Reference in a new issue