调整防御塔关闭逻辑

This commit is contained in:
17146 2025-06-07 03:07:49 +08:00 committed by Light_Quanta
parent 8b89474214
commit bfbbfd718b
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
2 changed files with 16 additions and 10 deletions

View file

@ -169,13 +169,16 @@ public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEnti
if (this.getOwnerUUID() == null) {
this.setOwnerUUID(player.getUUID());
}
if (this.getOwner() == player) {
entityData.set(ACTIVE, !entityData.get(ACTIVE));
if (player instanceof ServerPlayer serverPlayer) {
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), SoundEvents.ARROW_HIT_PLAYER, SoundSource.PLAYERS, 0.5F, 1);
}
return InteractionResult.sidedSuccess(this.level().isClientSide());
} else {
return InteractionResult.PASS;
}
}
}
entityData.set(TARGET_UUID, "none");

View file

@ -146,13 +146,16 @@ public class LaserTowerEntity extends EnergyVehicleEntity implements GeoEntity,
if (this.getOwnerUUID() == null) {
this.setOwnerUUID(player.getUUID());
}
if (this.getOwner() == player) {
entityData.set(ACTIVE, !entityData.get(ACTIVE));
if (player instanceof ServerPlayer serverPlayer) {
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), SoundEvents.ARROW_HIT_PLAYER, SoundSource.PLAYERS, 0.5F, 1);
}
return InteractionResult.sidedSuccess(this.level().isClientSide());
} else {
return InteractionResult.PASS;
}
}
}
return InteractionResult.sidedSuccess(this.level().isClientSide());