mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Fixed crash at startup due to bad mixins #59
This commit is contained in:
parent
3916e4810f
commit
2f65f5b0c0
2 changed files with 30 additions and 22 deletions
|
@ -5,34 +5,24 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.*;
|
import org.spongepowered.asm.mixin.injection.*;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
|
|
||||||
import net.minecraft.network.packet.c2s.play.*;
|
|
||||||
import net.minecraft.server.network.*;
|
import net.minecraft.server.network.*;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
|
|
||||||
@Mixin(value = {
|
@Mixin(ServerPlayNetworkHandler.class)
|
||||||
ServerPlayerInteractionManager.class,
|
|
||||||
ServerPlayNetworkHandler.class
|
|
||||||
})
|
|
||||||
abstract class MixinReachDistanceFix {
|
abstract class MixinReachDistanceFix {
|
||||||
@Redirect(
|
@Redirect(
|
||||||
target = {
|
method = {
|
||||||
@Desc(owner = ServerPlayerInteractionManager.class, value = "processBlockBreakingAction", args = {
|
"onPlayerInteractBlock",
|
||||||
BlockPos.class, PlayerActionC2SPacket.Action.class, Direction.class, int.class, int.class
|
"onPlayerInteractEntity"
|
||||||
}),
|
|
||||||
@Desc(owner = ServerPlayNetworkHandler.class, value = "onPlayerInteractBlock", args = { PlayerInteractBlockC2SPacket.class }),
|
|
||||||
@Desc(owner = ServerPlayNetworkHandler.class, value = "onPlayerInteractEntity", args = { PlayerInteractEntityC2SPacket.class })
|
|
||||||
},
|
},
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "FIELD",
|
value = "FIELD",
|
||||||
target = "net/minecraft/server/network/ServerPlayNetworkHandler.MAX_BREAK_SQUARED_DISTANCE:D",
|
target = "net/minecraft/server/network/ServerPlayNetworkHandler.MAX_BREAK_SQUARED_DISTANCE:D",
|
||||||
opcode = Opcodes.GETSTATIC
|
opcode = Opcodes.GETSTATIC
|
||||||
)
|
),
|
||||||
|
require = 0
|
||||||
)
|
)
|
||||||
private double getMaxBreakSquaredDistance() {
|
private double bgetMaxBreakSquaredDistance() {
|
||||||
Object o = this;
|
double reach = 6 + Pony.of(((ServerPlayNetworkHandler)(Object)this).getPlayer()).getExtendedReach();
|
||||||
ServerPlayerEntity player = o instanceof ServerPlayNetworkHandler s ? s.getPlayer() : ((MixinServerPlayerInteractionManager)o).getPlayer();
|
|
||||||
double reach = 6 + Pony.of(player).getExtendedReach();
|
|
||||||
return reach * reach;
|
return reach * reach;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,31 @@
|
||||||
package com.minelittlepony.unicopia.mixin;
|
package com.minelittlepony.unicopia.mixin;
|
||||||
|
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
import net.minecraft.server.network.ServerPlayerInteractionManager;
|
|
||||||
|
import net.minecraft.server.network.*;
|
||||||
|
|
||||||
@Mixin(ServerPlayerInteractionManager.class)
|
@Mixin(ServerPlayerInteractionManager.class)
|
||||||
public interface MixinServerPlayerInteractionManager {
|
abstract class MixinServerPlayerInteractionManager {
|
||||||
@Accessor
|
@Accessor
|
||||||
ServerPlayerEntity getPlayer();
|
public abstract ServerPlayerEntity getPlayer();
|
||||||
|
|
||||||
|
@Redirect(
|
||||||
|
method = "processBlockBreakingAction",
|
||||||
|
at = @At(
|
||||||
|
value = "FIELD",
|
||||||
|
target = "net/minecraft/server/network/ServerPlayNetworkHandler.MAX_BREAK_SQUARED_DISTANCE:D",
|
||||||
|
opcode = Opcodes.GETSTATIC
|
||||||
|
),
|
||||||
|
require = 0
|
||||||
|
)
|
||||||
|
private double bgetMaxBreakSquaredDistance() {
|
||||||
|
double reach = 6 + Pony.of(getPlayer()).getExtendedReach();
|
||||||
|
return reach * reach;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue