fix
This commit is contained in:
parent
4c1ff7a0aa
commit
e1bbd2fa08
2 changed files with 16 additions and 5 deletions
|
@ -2,6 +2,7 @@ package land.chipmunk.chipmunkmod.mixin;
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
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.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
@ -16,7 +17,7 @@ import land.chipmunk.chipmunkmod.modules.CommandCore;
|
||||||
|
|
||||||
@Mixin(ClientPlayerEntity.class)
|
@Mixin(ClientPlayerEntity.class)
|
||||||
public class ClientPlayerEntityMixin {
|
public class ClientPlayerEntityMixin {
|
||||||
private static MinecraftClient CLIENT = MinecraftClient.getInstance();
|
@Unique private static MinecraftClient CLIENT = MinecraftClient.getInstance();
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "move")
|
@Inject(at = @At("HEAD"), method = "move")
|
||||||
public void move (MovementType type, Vec3d relPos, CallbackInfo ci) {
|
public void move (MovementType type, Vec3d relPos, CallbackInfo ci) {
|
||||||
|
|
|
@ -8,11 +8,13 @@ import land.chipmunk.chipmunkmod.util.MathUtilities;
|
||||||
import net.minecraft.block.entity.CommandBlockBlockEntity;
|
import net.minecraft.block.entity.CommandBlockBlockEntity;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||||
|
import net.minecraft.client.world.ClientWorld;
|
||||||
import net.minecraft.nbt.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.network.ClientConnection;
|
import net.minecraft.network.ClientConnection;
|
||||||
import net.minecraft.network.packet.c2s.play.UpdateCommandBlockC2SPacket;
|
import net.minecraft.network.packet.c2s.play.UpdateCommandBlockC2SPacket;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
|
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
@ -67,21 +69,27 @@ public class CommandCore {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void move (Vec3d position) {
|
public void move (Vec3d position) {
|
||||||
|
final ClientWorld world = client.world;
|
||||||
|
|
||||||
|
if (world == null) return;
|
||||||
|
|
||||||
|
final DimensionType dimension = world.getDimension();
|
||||||
|
|
||||||
origin = new BlockPos(
|
origin = new BlockPos(
|
||||||
((int) position.getX() / 16) * 16,
|
((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
|
((int) position.getZ() / 16) * 16
|
||||||
);
|
);
|
||||||
|
|
||||||
withPos = new BlockArea(
|
withPos = new BlockArea(
|
||||||
new BlockPos(
|
new BlockPos(
|
||||||
noPos.start.getX() + origin.getX(),
|
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()
|
noPos.start.getZ() + origin.getZ()
|
||||||
),
|
),
|
||||||
new BlockPos(
|
new BlockPos(
|
||||||
noPos.end.getX() + origin.getX(),
|
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()
|
noPos.end.getZ() + origin.getZ()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -98,7 +106,7 @@ public class CommandCore {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refill () {
|
public void refill () {
|
||||||
if (!runFillCommand) return;
|
if (!runFillCommand || withPos == null) return;
|
||||||
|
|
||||||
final String command = String.format(
|
final String command = String.format(
|
||||||
KaboomCheck.INSTANCE.isKaboom ?
|
KaboomCheck.INSTANCE.isKaboom ?
|
||||||
|
@ -120,6 +128,8 @@ public class CommandCore {
|
||||||
final BlockPos start = withPos.start;
|
final BlockPos start = withPos.start;
|
||||||
final BlockPos end = withPos.end;
|
final BlockPos end = withPos.end;
|
||||||
|
|
||||||
|
if (start == null || end == null) return;
|
||||||
|
|
||||||
int x = block.getX();
|
int x = block.getX();
|
||||||
int y = block.getY();
|
int y = block.getY();
|
||||||
int z = block.getZ();
|
int z = block.getZ();
|
||||||
|
|
Loading…
Reference in a new issue