From cc69e49a205c756b6d26ddede6b122550d436bb3 Mon Sep 17 00:00:00 2001 From: pietru Date: Sat, 15 Mar 2025 21:52:49 +0100 Subject: [PATCH] fix for 0.4.2 --- gradle.properties | 4 +-- .../mixins/EntityLaserProjectileMixin.java | 3 ++- .../mixins/PlayerEntityMixin.java | 25 +++++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 75442c9..b2a418b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,9 +10,9 @@ id=cookie_utils # Dependency Versions cosmic_reach_rev=alpha -cosmic_reach_version=0.4.1 +cosmic_reach_version=0.4.2 # If unspecified, will use the version above -cosmic_reach_server_version=0.4.1 +cosmic_reach_server_version=0.4.2 cosmic_quilt_version=2.3.1 #2.2.0 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 4c18166..4cd3e92 100644 --- a/src/main/java/net/pietru/cookie_utils/mixins/EntityLaserProjectileMixin.java +++ b/src/main/java/net/pietru/cookie_utils/mixins/EntityLaserProjectileMixin.java @@ -1,5 +1,6 @@ package net.pietru.cookie_utils.mixins; +import com.badlogic.gdx.math.Vector3; import finalforeach.cosmicreach.GameSingletons; import finalforeach.cosmicreach.accounts.Account; import finalforeach.cosmicreach.blocks.BlockPosition; @@ -26,7 +27,7 @@ public class EntityLaserProjectileMixin extends EntityMixin { EntityUniqueId sourceEntityId; @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){ + private void event_collide_block(Axis axis, BlockState block, Vector3 targetPosition, int bx, int by, int bz, CallbackInfo ci){ if (GameSingletons.isHost && ServerSingletons.SERVER != null){ BlockPosition blockPos = BlockPosition.ofGlobal(this.zone, bx, by, bz); Player plr = null; diff --git a/src/main/java/net/pietru/cookie_utils/mixins/PlayerEntityMixin.java b/src/main/java/net/pietru/cookie_utils/mixins/PlayerEntityMixin.java index 604edc3..d6950c9 100644 --- a/src/main/java/net/pietru/cookie_utils/mixins/PlayerEntityMixin.java +++ b/src/main/java/net/pietru/cookie_utils/mixins/PlayerEntityMixin.java @@ -4,6 +4,7 @@ import com.llamalad7.mixinextras.sugar.Local; import finalforeach.cosmicreach.accounts.Account; import finalforeach.cosmicreach.entities.Entity; import finalforeach.cosmicreach.entities.EntityLaserProjectile; +import finalforeach.cosmicreach.entities.IDamageSource; import finalforeach.cosmicreach.entities.player.PlayerEntity; import finalforeach.cosmicreach.networking.packets.MessagePacket; import finalforeach.cosmicreach.networking.server.ServerSingletons; @@ -39,4 +40,28 @@ public class PlayerEntityMixin extends EntityMixin{ } } } + + @Inject(method = "hit", at = @At("HEAD"), cancellable = true) + private void event_player_hit(CallbackInfo ci, @Local IDamageSource damageSource, @Local float amount){ + if (damageSource instanceof Entity) { + if (damageSource instanceof PlayerEntity) { + Account account = ((PlayerEntity) damageSource).getPlayer().getAccount(); + + if (!Permissions.has_user_special_perm(account.getUniqueId()) && !can_enter_position(((Entity)damageSource).getPosition(), "pvp", account.getUniqueId())) { + ci.cancel(); + + MessagePacket packet = new MessagePacket("[Server] " + (is_not_reloading ? "Sorry, but you can't attack people here." : "Sorry but you can't do this action right now. [Config Reload In Progress]")); + packet.setupAndSend(ServerSingletons.getConnection(((PlayerEntity) damageSource).getPlayer())); + } + } else if (damageSource instanceof EntityLaserProjectile) { + if (!can_enter_position(((Entity)damageSource).getPosition(), "laser_damage", this.zone)) { + ci.cancel(); + } + } else { + if (!can_enter_position(((Entity)damageSource).getPosition(), "pve", this.zone)) { + ci.cancel(); + } + } + } + } }