Skip to content

Commit

Permalink
another round of fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
RecursivePineapple committed Dec 16, 2024
1 parent 5da0049 commit 55ced3c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -565,7 +565,7 @@ private <T> void addInfoLine(List<String> 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);

Expand Down Expand Up @@ -1656,7 +1656,7 @@ private static Vector3i getDefaultLocation(EntityPlayer player) {

@SideOnly(Side.CLIENT)
private Row makeCoordinateEditor(EntityPlayer player, int coord, int component) {
Supplier<Integer> getter = () -> {
IntSupplier getter = () -> {
MMState currState = getState(player.getHeldItem());

Vector3i l = switch (coord) {
Expand All @@ -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");
};
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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()
Expand All @@ -1816,25 +1817,16 @@ 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),
padding(5, 5),
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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -273,8 +273,6 @@ public VoxelAABB getPasteVisualDeltas(World world, boolean transform) {
this.transform.apply(aabb);
}

aabb.moveOrigin(coordC.toVec());

return aabb;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,13 +535,13 @@ private void getGTCables(Vector3i a, Vector3i b, List<PendingBlock> 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;
}
}
Expand Down

0 comments on commit 55ced3c

Please sign in to comment.