From a8891729d47457ff99e8dc97ca901a5a8686b48f Mon Sep 17 00:00:00 2001 From: pietru Date: Wed, 26 Feb 2025 10:51:20 +0100 Subject: [PATCH] fix laser stuff --- .../mixins/EntityLaserProjectileMixin.java | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/main/java/net/pietru/cookie_utils/mixins/EntityLaserProjectileMixin.java b/src/main/java/net/pietru/cookie_utils/mixins/EntityLaserProjectileMixin.java index 99c0606..4c18166 100644 --- a/src/main/java/net/pietru/cookie_utils/mixins/EntityLaserProjectileMixin.java +++ b/src/main/java/net/pietru/cookie_utils/mixins/EntityLaserProjectileMixin.java @@ -27,27 +27,29 @@ public class EntityLaserProjectileMixin extends EntityMixin { @Inject(method = "onCollideWithBlock", at = @At("HEAD"), cancellable = true) private void event_collide_block(Axis axis, BlockState block, int bx, int by, int bz, CallbackInfo ci){ - BlockPosition blockPos = BlockPosition.ofGlobal(this.zone, bx, by, bz); - Player plr = null; - for (Player p : GameSingletons.world.players) { - if (p.getEntity().uniqueId.equals(sourceEntityId)) { - plr = p; - break; + if (GameSingletons.isHost && ServerSingletons.SERVER != null){ + BlockPosition blockPos = BlockPosition.ofGlobal(this.zone, bx, by, bz); + Player plr = null; + for (Player p : GameSingletons.world.players) { + if (p.getEntity().uniqueId.equals(sourceEntityId)) { + plr = p; + break; + } } - } - if (plr!=null) { - Account account = GameSingletons.getAccountFromPlayer(plr); - if (!Permissions.has_user_special_perm(account.getUniqueId()) && !can_edit_block(blockPos, "laser", account.getUniqueId())) { - ci.cancel(); + if (plr!=null) { + Account account = GameSingletons.getAccountFromPlayer(plr); + if (!Permissions.has_user_special_perm(account.getUniqueId()) && !can_edit_block(blockPos, "laser", account.getUniqueId())) { + ci.cancel(); - MessagePacket packet = new MessagePacket("[Server] " + (is_not_reloading ? "Sorry, but this area is under protection." : "Sorry but you can't do this action right now. [Config Reload In Progress]")); - packet.setupAndSend(ServerSingletons.getConnection(plr)); + MessagePacket packet = new MessagePacket("[Server] " + (is_not_reloading ? "Sorry, but this area is under protection." : "Sorry but you can't do this action right now. [Config Reload In Progress]")); + packet.setupAndSend(ServerSingletons.getConnection(plr)); + } + }else { + if (sourceEntityId==null && !can_edit_block(blockPos, "be_laser")) + ci.cancel(); + else if (sourceEntityId!=null &&!can_edit_block(blockPos, "laser")) + ci.cancel(); } - }else { - if (sourceEntityId==null && !can_edit_block(blockPos, "be_laser")) - ci.cancel(); - else if (!can_edit_block(blockPos, "laser")) - ci.cancel(); } } }