fix for 0.4.2
All checks were successful
/ Auto-Build-App (push) Successful in 1m57s

This commit is contained in:
pietru 2025-03-15 21:52:49 +01:00
parent 3a97650a7a
commit cc69e49a20
3 changed files with 29 additions and 3 deletions

View file

@ -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

View file

@ -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;

View file

@ -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();
}
}
}
}
}