尝试修复载具乘坐问题

This commit is contained in:
17146 2025-01-03 21:27:29 +08:00
parent 8b1f04537c
commit 409504ac6d
2 changed files with 19 additions and 4 deletions

View file

@ -542,10 +542,6 @@ public class SpeedboatEntity extends MobileVehicleEntity implements GeoEntity, I
}
@Override
protected boolean canAddPassenger(Entity pPassenger) {
return this.getPassengers().size() < this.getMaxPassengers();
}
public int getMaxPassengers() {
return 5;
}

View file

@ -117,6 +117,11 @@ public class VehicleEntity extends Entity {
player.setYRot(this.getYRot());
return player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS;
}
if (this.getPassengers().size() < this.getMaxPassengers()) {
player.setXRot(this.getXRot());
player.setYRot(this.getYRot());
return player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS;
}
}
} else if (!this.level().isClientSide) {
if (this.getFirstPassenger() == null) {
@ -129,6 +134,11 @@ public class VehicleEntity extends Entity {
player.setYRot(this.getYRot());
return player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS;
}
if (this.getPassengers().size() < this.getMaxPassengers()) {
player.setXRot(this.getXRot());
player.setYRot(this.getYRot());
return player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS;
}
}
return InteractionResult.PASS;
}
@ -208,6 +218,15 @@ public class VehicleEntity extends Entity {
return hasPassenger(attacker) || super.skipAttackInteraction(attacker);
}
@Override
protected boolean canAddPassenger(Entity pPassenger) {
return this.getPassengers().size() < this.getMaxPassengers();
}
public int getMaxPassengers() {
return 1;
}
@Override
public void baseTick() {
super.baseTick();