diff --git a/src/main/java/land/chipmunk/chipmunkmod/mixin/ClientPlayerEntityMixin.java b/src/main/java/land/chipmunk/chipmunkmod/mixin/ClientPlayerEntityMixin.java index 443030a..5e21818 100644 --- a/src/main/java/land/chipmunk/chipmunkmod/mixin/ClientPlayerEntityMixin.java +++ b/src/main/java/land/chipmunk/chipmunkmod/mixin/ClientPlayerEntityMixin.java @@ -2,6 +2,7 @@ package land.chipmunk.chipmunkmod.mixin; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -16,7 +17,7 @@ import land.chipmunk.chipmunkmod.modules.CommandCore; @Mixin(ClientPlayerEntity.class) public class ClientPlayerEntityMixin { - private static MinecraftClient CLIENT = MinecraftClient.getInstance(); + @Unique private static MinecraftClient CLIENT = MinecraftClient.getInstance(); @Inject(at = @At("HEAD"), method = "move") public void move (MovementType type, Vec3d relPos, CallbackInfo ci) { diff --git a/src/main/java/land/chipmunk/chipmunkmod/modules/CommandCore.java b/src/main/java/land/chipmunk/chipmunkmod/modules/CommandCore.java index 7e5c357..c1a9309 100644 --- a/src/main/java/land/chipmunk/chipmunkmod/modules/CommandCore.java +++ b/src/main/java/land/chipmunk/chipmunkmod/modules/CommandCore.java @@ -8,11 +8,13 @@ import land.chipmunk.chipmunkmod.util.MathUtilities; import net.minecraft.block.entity.CommandBlockBlockEntity; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayNetworkHandler; +import net.minecraft.client.world.ClientWorld; import net.minecraft.nbt.NbtCompound; import net.minecraft.network.ClientConnection; import net.minecraft.network.packet.c2s.play.UpdateCommandBlockC2SPacket; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.dimension.DimensionType; import java.util.Timer; import java.util.TimerTask; @@ -67,21 +69,27 @@ public class CommandCore { } public void move (Vec3d position) { + final ClientWorld world = client.world; + + if (world == null) return; + + final DimensionType dimension = world.getDimension(); + origin = new BlockPos( ((int) position.getX() / 16) * 16, - (int) MathUtilities.clamp(noPos.start.getY(), client.world.getDimension().minY(), client.world.getDimension().height()), + (int) MathUtilities.clamp(noPos.start.getY(), dimension.minY(), dimension.height()), ((int) position.getZ() / 16) * 16 ); withPos = new BlockArea( new BlockPos( noPos.start.getX() + origin.getX(), - (int) MathUtilities.clamp(noPos.start.getY(), client.world.getDimension().minY(), client.world.getDimension().height()), + (int) MathUtilities.clamp(noPos.start.getY(), dimension.minY(), dimension.height()), noPos.start.getZ() + origin.getZ() ), new BlockPos( noPos.end.getX() + origin.getX(), - (int) MathUtilities.clamp(noPos.end.getY(), client.world.getDimension().minY(), client.world.getDimension().height()), + (int) MathUtilities.clamp(noPos.end.getY(), dimension.minY(), dimension.height()), noPos.end.getZ() + origin.getZ() ) ); @@ -98,7 +106,7 @@ public class CommandCore { } public void refill () { - if (!runFillCommand) return; + if (!runFillCommand || withPos == null) return; final String command = String.format( KaboomCheck.INSTANCE.isKaboom ? @@ -120,6 +128,8 @@ public class CommandCore { final BlockPos start = withPos.start; final BlockPos end = withPos.end; + if (start == null || end == null) return; + int x = block.getX(); int y = block.getY(); int z = block.getZ();