mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +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 com.minelittlepony.unicopia.entity.player.Pony;
|
||||
|
||||
import net.minecraft.network.packet.c2s.play.*;
|
||||
import net.minecraft.server.network.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
@Mixin(value = {
|
||||
ServerPlayerInteractionManager.class,
|
||||
ServerPlayNetworkHandler.class
|
||||
})
|
||||
@Mixin(ServerPlayNetworkHandler.class)
|
||||
abstract class MixinReachDistanceFix {
|
||||
@Redirect(
|
||||
target = {
|
||||
@Desc(owner = ServerPlayerInteractionManager.class, value = "processBlockBreakingAction", args = {
|
||||
BlockPos.class, PlayerActionC2SPacket.Action.class, Direction.class, int.class, int.class
|
||||
}),
|
||||
@Desc(owner = ServerPlayNetworkHandler.class, value = "onPlayerInteractBlock", args = { PlayerInteractBlockC2SPacket.class }),
|
||||
@Desc(owner = ServerPlayNetworkHandler.class, value = "onPlayerInteractEntity", args = { PlayerInteractEntityC2SPacket.class })
|
||||
method = {
|
||||
"onPlayerInteractBlock",
|
||||
"onPlayerInteractEntity"
|
||||
},
|
||||
at = @At(
|
||||
value = "FIELD",
|
||||
target = "net/minecraft/server/network/ServerPlayNetworkHandler.MAX_BREAK_SQUARED_DISTANCE:D",
|
||||
opcode = Opcodes.GETSTATIC
|
||||
)
|
||||
),
|
||||
require = 0
|
||||
)
|
||||
private double getMaxBreakSquaredDistance() {
|
||||
Object o = this;
|
||||
ServerPlayerEntity player = o instanceof ServerPlayNetworkHandler s ? s.getPlayer() : ((MixinServerPlayerInteractionManager)o).getPlayer();
|
||||
double reach = 6 + Pony.of(player).getExtendedReach();
|
||||
private double bgetMaxBreakSquaredDistance() {
|
||||
double reach = 6 + Pony.of(((ServerPlayNetworkHandler)(Object)this).getPlayer()).getExtendedReach();
|
||||
return reach * reach;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,31 @@
|
|||
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.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.network.ServerPlayerInteractionManager;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
|
||||
import net.minecraft.server.network.*;
|
||||
|
||||
@Mixin(ServerPlayerInteractionManager.class)
|
||||
public interface MixinServerPlayerInteractionManager {
|
||||
abstract class MixinServerPlayerInteractionManager {
|
||||
@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