允许关闭自动防御塔

This commit is contained in:
17146 2025-06-06 21:32:01 +08:00 committed by Light_Quanta
parent 66b4c77089
commit 6b568fb006
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
2 changed files with 14 additions and 6 deletions

View file

@ -165,9 +165,13 @@ public class Hpj11Entity extends ContainerMobileVehicleEntity implements GeoEnti
this.remove(RemovalReason.DISCARDED);
this.discard();
return InteractionResult.SUCCESS;
} else if (!entityData.get(ACTIVE)) {
entityData.set(ACTIVE, true);
} else {
if (this.getOwnerUUID() == null) {
this.setOwnerUUID(player.getUUID());
}
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);
}

View file

@ -142,9 +142,13 @@ public class LaserTowerEntity extends EnergyVehicleEntity implements GeoEntity,
this.remove(RemovalReason.DISCARDED);
this.discard();
return InteractionResult.SUCCESS;
} else if (!entityData.get(ACTIVE)) {
entityData.set(ACTIVE, true);
} else {
if (this.getOwnerUUID() == null) {
this.setOwnerUUID(player.getUUID());
}
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);
}