优化DPS发电机和标靶的右键交互

This commit is contained in:
Light_Quanta 2025-05-22 16:58:34 +08:00
parent 1d6e60ef01
commit c1886d7da5
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
2 changed files with 8 additions and 8 deletions

View file

@ -152,6 +152,10 @@ public class DPSGeneratorEntity extends LivingEntity implements GeoEntity {
@Override
public @NotNull InteractionResult interact(Player player, @NotNull InteractionHand hand) {
if (player.getMainHandItem() != ItemStack.EMPTY) {
return InteractionResult.PASS;
}
if (player.isShiftKeyDown()) {
if (!this.level().isClientSide()) {
this.discard();
@ -161,10 +165,6 @@ public class DPSGeneratorEntity extends LivingEntity implements GeoEntity {
player.addItem(new ItemStack(ModItems.DPS_GENERATOR_DEPLOYER.get()));
}
} else {
if (player.getMainHandItem() != ItemStack.EMPTY) {
return InteractionResult.PASS;
}
this.lookAt(EntityAnchorArgument.Anchor.EYES, new Vec3((player.getX()), this.getY(), (player.getZ())));
this.setXRot(0);
this.xRotO = this.getXRot();

View file

@ -135,6 +135,10 @@ public class TargetEntity extends LivingEntity implements GeoEntity {
@Override
public @NotNull InteractionResult interact(Player player, @NotNull InteractionHand hand) {
if (player.getMainHandItem() != ItemStack.EMPTY) {
return InteractionResult.PASS;
}
if (player.isShiftKeyDown()) {
if (!this.level().isClientSide()) {
this.discard();
@ -144,10 +148,6 @@ public class TargetEntity extends LivingEntity implements GeoEntity {
player.addItem(new ItemStack(ModItems.TARGET_DEPLOYER.get()));
}
} else {
if (player.getMainHandItem() != ItemStack.EMPTY) {
return InteractionResult.PASS;
}
this.lookAt(EntityAnchorArgument.Anchor.EYES, new Vec3((player.getX()), this.getY(), (player.getZ())));
this.setXRot(0);
this.xRotO = this.getXRot();