From 55ced3cd6b1820c1bb525f2c0a8ffa5f3c4bc3a9 Mon Sep 17 00:00:00 2001 From: RecursivePineapple Date: Mon, 16 Dec 2024 12:49:26 -0500 Subject: [PATCH] another round of fixes --- .../manipulator/ItemMatterManipulator.java | 48 ++++++++----------- .../common/items/manipulator/MMConfig.java | 4 +- .../common/items/manipulator/MMState.java | 8 ++-- 3 files changed, 25 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/recursive_pineapple/matter_manipulator/common/items/manipulator/ItemMatterManipulator.java b/src/main/java/com/recursive_pineapple/matter_manipulator/common/items/manipulator/ItemMatterManipulator.java index 08f2096..63c5d79 100644 --- a/src/main/java/com/recursive_pineapple/matter_manipulator/common/items/manipulator/ItemMatterManipulator.java +++ b/src/main/java/com/recursive_pineapple/matter_manipulator/common/items/manipulator/ItemMatterManipulator.java @@ -15,7 +15,7 @@ import java.util.Objects; import java.util.function.Function; import java.util.function.IntConsumer; -import java.util.function.Supplier; +import java.util.function.IntSupplier; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; @@ -565,7 +565,7 @@ private void addInfoLine(List desc, String format, T value, Function @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - if (player.getItemInUse() != null) return stack; + if (player.isUsingItem()) return stack; MMState state = getState(stack); @@ -1656,7 +1656,7 @@ private static Vector3i getDefaultLocation(EntityPlayer player) { @SideOnly(Side.CLIENT) private Row makeCoordinateEditor(EntityPlayer player, int coord, int component) { - Supplier getter = () -> { + IntSupplier getter = () -> { MMState currState = getState(player.getHeldItem()); Vector3i l = switch (coord) { @@ -1683,13 +1683,23 @@ private Row makeCoordinateEditor(EntityPlayer player, int coord, int component) }; }; + IntSupplier getterVisual = () -> { + int k = getter.getAsInt(); + + if (coord == 3) { + if (k >= 0) k++; + } + + return k; + }; + IntConsumer setter = i -> { MMState currState = getState(player.getHeldItem()); Vector3i l = switch (coord) { - case 0 -> currState.config.coordA.toVec(); - case 1 -> currState.config.coordB.toVec(); - case 2 -> currState.config.coordC.toVec(); + case 0 -> currState.config.coordA == null ? null : currState.config.coordA.toVec(); + case 1 -> currState.config.coordB == null ? null : currState.config.coordB.toVec(); + case 2 -> currState.config.coordC == null ? null : currState.config.coordC.toVec(); case 3 -> currState.config.arraySpan; default -> throw new IllegalArgumentException("coord"); }; @@ -1747,17 +1757,8 @@ private Row makeCoordinateEditor(EntityPlayer player, int coord, int component) new VanillaButtonWidget().setDisplayString(compName + " - 1") .setOnClick( (t, u) -> { - Integer i = getter.get(); + int i = getter.getAsInt(); - if (i == null) { - i = switch (component) { - case 0 -> (int) player.posX; - case 1 -> (int) player.posY; - case 2 -> (int) player.posZ; - default -> throw new IllegalArgumentException("component"); - }; - } - int offset = 1; if (GuiScreen.isShiftKeyDown()) { @@ -1806,7 +1807,7 @@ private Row makeCoordinateEditor(EntityPlayer player, int coord, int component) .addChild(new NumericWidget() .setSynced(false, false) .setIntegerOnly(true) - .setGetter(() -> getter.get()) + .setGetter(() -> getterVisual.getAsInt()) .setSetter(i -> setter.accept((int) i)) .setBounds(coord == 3 ? 1 : Integer.MIN_VALUE, Integer.MAX_VALUE) .setScrollBar() @@ -1816,7 +1817,7 @@ private Row makeCoordinateEditor(EntityPlayer player, int coord, int component) .setPos(2, 2) .setTicker(w -> { if (!w.isFocused()) { - ((NumericWidget) w).setValue(getter.get()); + ((NumericWidget) w).setValue(getterVisual.getAsInt()); } })) .setSize(40, 18), @@ -1824,17 +1825,8 @@ private Row makeCoordinateEditor(EntityPlayer player, int coord, int component) new VanillaButtonWidget().setDisplayString(compName + " + 1") .setOnClick( (t, u) -> { - Integer i = getter.get(); + int i = getter.getAsInt(); - if (i == null) { - i = switch (component) { - case 0 -> (int) player.posX; - case 1 -> (int) player.posY; - case 2 -> (int) player.posZ; - default -> throw new IllegalArgumentException("component"); - }; - } - int offset = 1; if (GuiScreen.isShiftKeyDown()) { diff --git a/src/main/java/com/recursive_pineapple/matter_manipulator/common/items/manipulator/MMConfig.java b/src/main/java/com/recursive_pineapple/matter_manipulator/common/items/manipulator/MMConfig.java index df8257e..cfc944e 100644 --- a/src/main/java/com/recursive_pineapple/matter_manipulator/common/items/manipulator/MMConfig.java +++ b/src/main/java/com/recursive_pineapple/matter_manipulator/common/items/manipulator/MMConfig.java @@ -263,7 +263,7 @@ public VoxelAABB getPasteVisualDeltas(World world, boolean transform) { VoxelAABB aabb = new VoxelAABB(coordA.toVec(), coordB.toVec()); - aabb.moveOrigin(new Vector3i(0)); + aabb.moveOrigin(coordC.toVec()); if (arraySpan != null) { aabb.scale(arraySpan.x, arraySpan.y, arraySpan.z); @@ -273,8 +273,6 @@ public VoxelAABB getPasteVisualDeltas(World world, boolean transform) { this.transform.apply(aabb); } - aabb.moveOrigin(coordC.toVec()); - return aabb; } diff --git a/src/main/java/com/recursive_pineapple/matter_manipulator/common/items/manipulator/MMState.java b/src/main/java/com/recursive_pineapple/matter_manipulator/common/items/manipulator/MMState.java index d5e88d5..4732853 100644 --- a/src/main/java/com/recursive_pineapple/matter_manipulator/common/items/manipulator/MMState.java +++ b/src/main/java/com/recursive_pineapple/matter_manipulator/common/items/manipulator/MMState.java @@ -535,13 +535,13 @@ private void getGTCables(Vector3i a, Vector3i b, List out, Block b break; } case 1: { - start = b.y < 0 ? ForgeDirection.DOWN.flag : ForgeDirection.UP.flag; - end = b.y > 0 ? ForgeDirection.DOWN.flag : ForgeDirection.UP.flag; + start = b.y < 0 ? ForgeDirection.UP.flag : ForgeDirection.DOWN.flag; + end = b.y > 0 ? ForgeDirection.UP.flag : ForgeDirection.DOWN.flag; break; } case 2: { - start = b.z < 0 ? ForgeDirection.NORTH.flag : ForgeDirection.SOUTH.flag; - end = b.z > 0 ? ForgeDirection.NORTH.flag : ForgeDirection.SOUTH.flag; + start = b.z < 0 ? ForgeDirection.SOUTH.flag : ForgeDirection.NORTH.flag; + end = b.z > 0 ? ForgeDirection.SOUTH.flag : ForgeDirection.NORTH.flag; break; } }