diff --git a/src/main/java/me/aleksilassila/litematica/printer/LitematicaMixinMod.java b/src/main/java/me/aleksilassila/litematica/printer/LitematicaMixinMod.java index c91036c91..e26f79544 100644 --- a/src/main/java/me/aleksilassila/litematica/printer/LitematicaMixinMod.java +++ b/src/main/java/me/aleksilassila/litematica/printer/LitematicaMixinMod.java @@ -34,10 +34,12 @@ public static ImmutableList getConfigList() { } // Hotkeys - public static final ConfigHotkey TOGGLE_PRINTING_MODE = new ConfigHotkey("togglePrintingMode", "M,O", "Allows quickly toggling on/off Printing mode"); + public static final ConfigHotkey PRINT = new ConfigHotkey("print", "V", "Prints while pressed"); + public static final ConfigHotkey TOGGLE_PRINTING_MODE = new ConfigHotkey("togglePrintingMode", "CAPS_LOCK", "Allows quickly toggling on/off Printing mode"); public static List getHotkeyList() { List list = new java.util.ArrayList<>(List.copyOf(Hotkeys.HOTKEY_LIST)); + list.add(PRINT); list.add(TOGGLE_PRINTING_MODE); return ImmutableList.copyOf(list); diff --git a/src/main/java/me/aleksilassila/litematica/printer/mixin/ClientPlayNetworkHandlerMixin.java b/src/main/java/me/aleksilassila/litematica/printer/mixin/ClientPlayNetworkHandlerMixin.java index fcbf5009a..ab2e76810 100644 --- a/src/main/java/me/aleksilassila/litematica/printer/mixin/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/me/aleksilassila/litematica/printer/mixin/ClientPlayNetworkHandlerMixin.java @@ -9,9 +9,6 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ClientPlayNetworkHandler.class) public class ClientPlayNetworkHandlerMixin { diff --git a/src/main/java/me/aleksilassila/litematica/printer/mixin/MixinClientPlayerEntity.java b/src/main/java/me/aleksilassila/litematica/printer/mixin/MixinClientPlayerEntity.java index 8bdea3434..3a6915f78 100644 --- a/src/main/java/me/aleksilassila/litematica/printer/mixin/MixinClientPlayerEntity.java +++ b/src/main/java/me/aleksilassila/litematica/printer/mixin/MixinClientPlayerEntity.java @@ -46,7 +46,9 @@ public void tick(CallbackInfo ci) { return; } - if (SchematicWorldHandler.getSchematicWorld() == null || !LitematicaMixinMod.PRINT_MODE.getBooleanValue()) return; + if (SchematicWorldHandler.getSchematicWorld() == null || + !(LitematicaMixinMod.PRINT_MODE.getBooleanValue() || LitematicaMixinMod.PRINT.getKeybind().isPressed())) + return; printer.onTick(); } diff --git a/src/main/java/me/aleksilassila/litematica/printer/printer/PlacementGuide.java b/src/main/java/me/aleksilassila/litematica/printer/printer/PlacementGuide.java index 6a00a904c..f9f11eba1 100644 --- a/src/main/java/me/aleksilassila/litematica/printer/printer/PlacementGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/printer/PlacementGuide.java @@ -28,6 +28,8 @@ public enum PlacementGuide { AMETHYST(AmethystClusterBlock.class), DOOR(DoorBlock.class), COCOA(CocoaBlock.class), + OBSERVER(ObserverBlock.class), + WALLSKULL(WallSkullBlock.class), SKIP(SkullBlock.class, GrindstoneBlock.class, SignBlock.class, AbstractLichenBlock.class, VineBlock.class), DEFAULT; @@ -51,7 +53,7 @@ private static PlacementGuide getGuide(BlockState requiredState) { public static Placement getPlacement(BlockState requiredState) { switch (getGuide(requiredState)) { - case WALLTORCH, ROD, AMETHYST -> { // FIXME check if the wall exists? + case WALLTORCH, ROD, AMETHYST, SHULKER -> { return new Placement(((Direction) getPropertyByName(requiredState, "FACING")).getOpposite(), null, null); @@ -91,7 +93,7 @@ public static Placement getPlacement(BlockState requiredState) { Direction side = switch ((WallMountLocation) getPropertyByName(requiredState, "FACE")) { case FLOOR -> Direction.DOWN; case CEILING -> Direction.UP; - default -> (Direction) getPropertyByName(requiredState, "FACING"); + default -> ((Direction) getPropertyByName(requiredState, "FACING")).getOpposite(); }; Direction look = getPropertyByName(requiredState, "FACE") == WallMountLocation.WALL ? @@ -99,7 +101,7 @@ public static Placement getPlacement(BlockState requiredState) { return new Placement(side, null, - look); + look).setCantPlaceInAir(true); } // case GRINDSTONE -> { // Tese are broken // Direction side = switch ((WallMountLocation) getPropertyByName(requiredState, "FACE")) { @@ -120,11 +122,6 @@ public static Placement getPlacement(BlockState requiredState) { null, (Direction) getPropertyByName(requiredState, "FACING")); } - case SHULKER -> { - return new Placement(requiredState.get(ShulkerBoxBlock.FACING).getOpposite(), - null, - null); - } case BED -> { if (requiredState.get(BedBlock.PART) != BedPart.FOOT) { return new Placement(); @@ -160,6 +157,9 @@ public static Placement getPlacement(BlockState requiredState) { hitModifier, requiredState.get(DoorBlock.FACING)); } + case WALLSKULL -> { + return new Placement(requiredState.get(WallSkullBlock.FACING).getOpposite(), null, null); + } case SKIP -> { return new Placement(); } @@ -207,7 +207,9 @@ public static class Placement { @Nullable public final Direction look; - final boolean sideIsAxis; + boolean sideIsAxis = false; + + boolean cantPlaceInAir = false; boolean skip; public Placement(@Nullable Direction side, @Nullable Vec3d hitModifier, @Nullable Direction look, boolean sideIsAxis) { @@ -227,5 +229,16 @@ public Placement() { this(null, null, null, false); this.skip = true; } + + public Placement setSideIsAxis(boolean sideIsAxis) { + this.sideIsAxis = sideIsAxis; + + return this; + } + + public Placement setCantPlaceInAir(boolean cantPlaceInAir) { + this.cantPlaceInAir = cantPlaceInAir; + return this; + } } } diff --git a/src/main/java/me/aleksilassila/litematica/printer/printer/Printer.java b/src/main/java/me/aleksilassila/litematica/printer/printer/Printer.java index 484324b42..26860e193 100644 --- a/src/main/java/me/aleksilassila/litematica/printer/printer/Printer.java +++ b/src/main/java/me/aleksilassila/litematica/printer/printer/Printer.java @@ -92,7 +92,7 @@ public void onTick() { } else if (shouldPrintHere(pos, placement) && playerHasAccessToItem(requiredState.getBlock().asItem())) { boolean doubleChest = requiredState.contains(ChestBlock.CHEST_TYPE) && requiredState.get(ChestBlock.CHEST_TYPE) != ChestType.SINGLE; Direction side = placement.side == null ? Direction.DOWN : placement.side; - BlockPos neighbor = pos; // If placing in air, there's no neighbor + BlockPos neighbor = placement.cantPlaceInAir ? pos.offset(side) : pos; // If placing in air, there's no neighbor Vec3d hit = Vec3d.ofCenter(pos).add(Vec3d.of(side.getVector()).multiply(0.5));