From 234e44cbaf11574a5ab853a1d3b7387890b2a665 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 18 Sep 2022 22:12:57 +0200 Subject: [PATCH] Fix mixins --- .../unicopia/mixin/MixinReachDistanceFix.java | 22 +++---------------- .../MixinServerPlayerInteractionManager.java | 13 +++++++++++ src/main/resources/unicopia.mixin.json | 1 + 3 files changed, 17 insertions(+), 19 deletions(-) create mode 100644 src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayerInteractionManager.java diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinReachDistanceFix.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinReachDistanceFix.java index a66b8035..9ebf863b 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinReachDistanceFix.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinReachDistanceFix.java @@ -2,7 +2,6 @@ package com.minelittlepony.unicopia.mixin; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.injection.*; import com.minelittlepony.unicopia.entity.player.Pony; @@ -13,10 +12,6 @@ import net.minecraft.server.network.*; ServerPlayNetworkHandler.class }) abstract class MixinReachDistanceFix { - - @Accessor - public abstract ServerPlayerEntity getPlayer(); - @Redirect( method = { "processBlockBreakingAction", @@ -30,20 +25,9 @@ abstract class MixinReachDistanceFix { ) ) private double getMaxBreakSquaredDistance() { - double reach = 6 + Pony.of(getPlayer()).getExtendedReach(); + Object o = this; + ServerPlayerEntity player = o instanceof ServerPlayNetworkHandler s ? s.getPlayer() : ((MixinServerPlayerInteractionManager)o).getPlayer(); + double reach = 6 + Pony.of(player).getExtendedReach(); return reach * reach; } -/* - @ModifyConstant( - method = { - "processBlockBreakingAction", - "onPlayerInteractBlock", - "onPlayerInteractEntity" - }, - constant = @Constant(doubleValue = 36D) - ) - private double modifyMaxBreakSquaredDistance(double initial) { - double reach = 6 + Pony.of(getPlayer()).getExtendedReach(); - return reach * reach; - }*/ } diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayerInteractionManager.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayerInteractionManager.java new file mode 100644 index 00000000..95499335 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayerInteractionManager.java @@ -0,0 +1,13 @@ +package com.minelittlepony.unicopia.mixin; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.network.ServerPlayerInteractionManager; + +@Mixin(ServerPlayerInteractionManager.class) +public interface MixinServerPlayerInteractionManager { + @Accessor + ServerPlayerEntity getPlayer(); +} diff --git a/src/main/resources/unicopia.mixin.json b/src/main/resources/unicopia.mixin.json index b4f2d9a8..bbbd7813 100644 --- a/src/main/resources/unicopia.mixin.json +++ b/src/main/resources/unicopia.mixin.json @@ -25,6 +25,7 @@ "MixinProjectileEntity", "MixinReachDistanceFix", "MixinServerPlayerEntity", + "MixinServerPlayerInteractionManager", "MixinServerPlayNetworkHandler", "MixinServerWorld", "MixinSheepEntity",