From ff7c319815dc7573c5ae3f66d76d495dc7e1abe8 Mon Sep 17 00:00:00 2001 From: Aleksi Lassila Date: Tue, 29 Oct 2024 20:46:14 +0200 Subject: [PATCH] chore: Move from multi-version setup to single version, future releases only target latest MC version --- build.gradle.kts | 92 +++++++----- gradle.properties | 17 ++- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle | 7 - .../litematica/printer}/ActionHandler.java | 6 +- .../litematica/printer}/BlockHelper.java | 2 +- .../printer}/LitematicaMixinMod.java | 2 +- .../litematica/printer}/Printer.java | 8 +- .../printer}/SchematicBlockState.java | 2 +- .../litematica/printer}/UpdateChecker.java | 2 +- .../litematica/printer}/actions/Action.java | 2 +- .../printer}/actions/InteractAction.java | 6 +- .../printer}/actions/PrepareAction.java | 4 +- .../printer}/actions/ReleaseShiftAction.java | 2 +- .../litematica/printer}/guides/Guide.java | 8 +- .../litematica/printer}/guides/Guides.java | 8 +- .../litematica/printer}/guides/SkipGuide.java | 6 +- .../interaction/CampfireExtinguishGuide.java | 4 +- .../guides/interaction/CycleStateGuide.java | 4 +- .../guides/interaction/EnderEyeGuide.java | 4 +- .../interaction/FlowerPotFillGuide.java | 4 +- .../guides/interaction/InteractionGuide.java | 18 +-- .../guides/interaction/LightCandleGuide.java | 4 +- .../guides/interaction/LogStrippingGuide.java | 8 +- .../guides/interaction/TillingGuide.java | 6 +- .../BlockIndifferentGuesserGuide.java | 4 +- .../placement/BlockReplacementGuide.java | 8 +- .../printer}/guides/placement/ChestGuide.java | 4 +- .../guides/placement/FallingBlockGuide.java | 4 +- .../guides/placement/FarmlandGuide.java | 4 +- .../guides/placement/FlowerPotGuide.java | 4 +- .../placement/GeneralPlacementGuide.java | 6 +- .../guides/placement/GuesserGuide.java | 8 +- .../printer}/guides/placement/LogGuide.java | 8 +- .../guides/placement/PlacementGuide.java | 20 +-- .../PropertySpecificGuesserGuide.java | 4 +- .../guides/placement/RailGuesserGuide.java | 4 +- .../guides/placement/RotatingBlockGuide.java | 10 +- .../printer}/guides/placement/SlabGuide.java | 4 +- .../printer}/guides/placement/TorchGuide.java | 4 +- .../implementation/BlockHelperImpl.java | 4 +- .../PrinterPlacementContext.java | 2 +- .../actions/InteractActionImpl.java | 6 +- .../mixin/MixinClientPlayerEntity.java | 10 +- .../printer}/mixin/AxeItemAccessor.java | 2 +- .../printer}/mixin/ConfigsMixin.java | 4 +- .../printer}/mixin/GuiConfigsMixin.java | 4 +- .../printer}/mixin/InputHandlerMixin.java | 4 +- .../mixin/PlayerMoveC2SPacketMixin.java | 8 +- .../main/resources/assets/modid/icon.png | Bin .../main/resources/fabric.mod.json | 4 +- ...ematica-printer-implementation.mixins.json | 2 +- .../resources/litematica-printer.mixins.json | 2 +- v1_17/build.gradle.kts | 88 ----------- v1_17/gradle.properties | 15 -- .../printer/v1_17/ActionHandler.java | 57 ------- .../litematica/printer/v1_17/BlockHelper.java | 31 ---- .../printer/v1_17/LitematicaMixinMod.java | 58 -------- .../litematica/printer/v1_17/Printer.java | 110 -------------- .../printer/v1_17/UpdateChecker.java | 49 ------ .../printer/v1_17/actions/InteractAction.java | 33 ----- .../printer/v1_17/actions/PrepareAction.java | 109 -------------- .../v1_17/actions/ReleaseShiftAction.java | 13 -- .../printer/v1_17/guides/Guide.java | 130 ---------------- .../printer/v1_17/guides/SkipGuide.java | 37 ----- .../interaction/CampfireExtinguishGuide.java | 36 ----- .../guides/interaction/CycleStateGuide.java | 45 ------ .../guides/interaction/EnderEyeGuide.java | 33 ----- .../guides/interaction/TillingGuide.java | 39 ----- .../BlockIndifferentGuesserGuide.java | 42 ------ .../placement/BlockReplacementGuide.java | 75 ---------- .../v1_17/guides/placement/ChestGuide.java | 92 ------------ .../guides/placement/FallingBlockGuide.java | 37 ----- .../v1_17/guides/placement/FarmlandGuide.java | 29 ---- .../guides/placement/FlowerPotGuide.java | 20 --- .../placement/GeneralPlacementGuide.java | 119 --------------- .../v1_17/guides/placement/GuesserGuide.java | 110 -------------- .../v1_17/guides/placement/LogGuide.java | 54 ------- .../guides/placement/PlacementGuide.java | 138 ----------------- .../guides/placement/RailGuesserGuide.java | 128 ---------------- .../guides/placement/RotatingBlockGuide.java | 58 -------- .../v1_17/guides/placement/SlabGuide.java | 48 ------ .../v1_17/guides/placement/TorchGuide.java | 31 ---- .../v1_17/implementation/BlockHelperImpl.java | 14 -- .../PrinterPlacementContext.java | 59 -------- .../actions/InteractActionImpl.java | 20 --- .../mixin/MixinClientPlayerEntity.java | 103 ------------- .../printer/v1_17/mixin/AxeItemAccessor.java | 20 --- .../printer/v1_17/mixin/ConfigsMixin.java | 35 ----- .../printer/v1_17/mixin/GuiConfigsMixin.java | 61 -------- .../v1_17/mixin/InputHandlerMixin.java | 25 ---- v1_17/src/main/resources/fabric.mod.json | 38 ----- ...ematica-printer-implementation.mixins.json | 14 -- .../resources/litematica-printer.mixins.json | 18 --- v1_18/build.gradle.kts | 88 ----------- v1_18/gradle.properties | 13 -- .../printer/v1_18/ActionHandler.java | 57 ------- .../litematica/printer/v1_18/BlockHelper.java | 31 ---- .../printer/v1_18/LitematicaMixinMod.java | 58 -------- .../litematica/printer/v1_18/Printer.java | 110 -------------- .../printer/v1_18/SchematicBlockState.java | 42 ------ .../printer/v1_18/UpdateChecker.java | 49 ------ .../printer/v1_18/actions/Action.java | 8 - .../printer/v1_18/actions/InteractAction.java | 33 ----- .../printer/v1_18/actions/PrepareAction.java | 109 -------------- .../v1_18/actions/ReleaseShiftAction.java | 13 -- .../printer/v1_18/guides/Guide.java | 130 ---------------- .../printer/v1_18/guides/Guides.java | 81 ---------- .../printer/v1_18/guides/SkipGuide.java | 37 ----- .../interaction/CampfireExtinguishGuide.java | 36 ----- .../guides/interaction/CycleStateGuide.java | 45 ------ .../guides/interaction/EnderEyeGuide.java | 33 ----- .../interaction/FlowerPotFillGuide.java | 40 ----- .../guides/interaction/InteractionGuide.java | 49 ------ .../guides/interaction/LightCandleGuide.java | 36 ----- .../guides/interaction/LogStrippingGuide.java | 47 ------ .../guides/interaction/TillingGuide.java | 39 ----- .../BlockIndifferentGuesserGuide.java | 42 ------ .../placement/BlockReplacementGuide.java | 75 ---------- .../v1_18/guides/placement/ChestGuide.java | 92 ------------ .../guides/placement/FlowerPotGuide.java | 20 --- .../placement/GeneralPlacementGuide.java | 119 --------------- .../v1_18/guides/placement/GuesserGuide.java | 110 -------------- .../v1_18/guides/placement/LogGuide.java | 54 ------- .../guides/placement/PlacementGuide.java | 138 ----------------- .../PropertySpecificGuesserGuide.java | 52 ------- .../guides/placement/RailGuesserGuide.java | 128 ---------------- .../guides/placement/RotatingBlockGuide.java | 58 -------- .../v1_18/guides/placement/SlabGuide.java | 48 ------ .../v1_18/guides/placement/TorchGuide.java | 31 ---- .../v1_18/implementation/BlockHelperImpl.java | 14 -- .../PrinterPlacementContext.java | 59 -------- .../actions/InteractActionImpl.java | 20 --- .../mixin/MixinClientPlayerEntity.java | 103 ------------- .../printer/v1_18/mixin/AxeItemAccessor.java | 20 --- .../printer/v1_18/mixin/ConfigsMixin.java | 35 ----- .../printer/v1_18/mixin/GuiConfigsMixin.java | 61 -------- .../v1_18/mixin/PlayerMoveC2SPacketMixin.java | 36 ----- v1_18/src/main/resources/fabric.mod.json | 37 ----- .../resources/litematica-printer.mixins.json | 18 --- v1_18/src/main/resources/modid/icon.png | Bin 453 -> 0 bytes v1_19/build.gradle.kts | 88 ----------- v1_19/gradle.properties | 15 -- .../litematica/printer/v1_19/Printer.java | 110 -------------- .../printer/v1_19/SchematicBlockState.java | 42 ------ .../printer/v1_19/UpdateChecker.java | 49 ------ .../printer/v1_19/actions/Action.java | 8 - .../printer/v1_19/guides/Guide.java | 130 ---------------- .../printer/v1_19/guides/Guides.java | 81 ---------- .../interaction/CampfireExtinguishGuide.java | 36 ----- .../interaction/FlowerPotFillGuide.java | 40 ----- .../guides/interaction/InteractionGuide.java | 49 ------ .../guides/interaction/LightCandleGuide.java | 36 ----- .../guides/interaction/LogStrippingGuide.java | 47 ------ .../BlockIndifferentGuesserGuide.java | 42 ------ .../placement/BlockReplacementGuide.java | 75 ---------- .../guides/placement/FallingBlockGuide.java | 37 ----- .../v1_19/guides/placement/FarmlandGuide.java | 29 ---- .../placement/GeneralPlacementGuide.java | 119 --------------- .../v1_19/guides/placement/GuesserGuide.java | 110 -------------- .../guides/placement/PlacementGuide.java | 138 ----------------- .../PropertySpecificGuesserGuide.java | 52 ------- .../guides/placement/RailGuesserGuide.java | 128 ---------------- .../v1_19/implementation/BlockHelperImpl.java | 14 -- .../PrinterPlacementContext.java | 59 -------- .../mixin/MixinClientPlayerEntity.java | 102 ------------- .../v1_19/mixin/InputHandlerMixin.java | 25 ---- .../v1_19/mixin/PlayerMoveC2SPacketMixin.java | 36 ----- .../src/main/resources/assets/modid/icon.png | Bin 453 -> 0 bytes v1_19/src/main/resources/fabric.mod.json | 38 ----- ...ematica-printer-implementation.mixins.json | 14 -- v1_19_3/build.gradle.kts | 88 ----------- v1_19_3/gradle.properties | 13 -- .../printer/v1_19_3/ActionHandler.java | 57 ------- .../printer/v1_19_3/BlockHelper.java | 31 ---- .../printer/v1_19_3/LitematicaMixinMod.java | 58 -------- .../litematica/printer/v1_19_3/Printer.java | 110 -------------- .../printer/v1_19_3/SchematicBlockState.java | 42 ------ .../printer/v1_19_3/UpdateChecker.java | 49 ------ .../printer/v1_19_3/actions/Action.java | 8 - .../v1_19_3/actions/InteractAction.java | 33 ----- .../v1_19_3/actions/PrepareAction.java | 109 -------------- .../v1_19_3/actions/ReleaseShiftAction.java | 13 -- .../printer/v1_19_3/guides/Guide.java | 130 ---------------- .../printer/v1_19_3/guides/Guides.java | 81 ---------- .../printer/v1_19_3/guides/SkipGuide.java | 37 ----- .../interaction/CampfireExtinguishGuide.java | 36 ----- .../guides/interaction/CycleStateGuide.java | 45 ------ .../guides/interaction/EnderEyeGuide.java | 33 ----- .../interaction/FlowerPotFillGuide.java | 40 ----- .../guides/interaction/InteractionGuide.java | 49 ------ .../guides/interaction/LightCandleGuide.java | 36 ----- .../guides/interaction/LogStrippingGuide.java | 47 ------ .../guides/interaction/TillingGuide.java | 39 ----- .../BlockIndifferentGuesserGuide.java | 42 ------ .../placement/BlockReplacementGuide.java | 75 ---------- .../v1_19_3/guides/placement/ChestGuide.java | 92 ------------ .../guides/placement/FallingBlockGuide.java | 37 ----- .../guides/placement/FarmlandGuide.java | 29 ---- .../guides/placement/FlowerPotGuide.java | 20 --- .../placement/GeneralPlacementGuide.java | 119 --------------- .../guides/placement/GuesserGuide.java | 110 -------------- .../v1_19_3/guides/placement/LogGuide.java | 54 ------- .../guides/placement/PlacementGuide.java | 138 ----------------- .../PropertySpecificGuesserGuide.java | 52 ------- .../guides/placement/RailGuesserGuide.java | 128 ---------------- .../guides/placement/RotatingBlockGuide.java | 58 -------- .../v1_19_3/guides/placement/SlabGuide.java | 48 ------ .../v1_19_3/guides/placement/TorchGuide.java | 31 ---- .../implementation/BlockHelperImpl.java | 14 -- .../PrinterPlacementContext.java | 59 -------- .../actions/InteractActionImpl.java | 20 --- .../mixin/MixinClientPlayerEntity.java | 103 ------------- .../v1_19_3/mixin/AxeItemAccessor.java | 20 --- .../printer/v1_19_3/mixin/ConfigsMixin.java | 35 ----- .../v1_19_3/mixin/GuiConfigsMixin.java | 61 -------- .../v1_19_3/mixin/InputHandlerMixin.java | 25 ---- .../mixin/PlayerMoveC2SPacketMixin.java | 36 ----- .../src/main/resources/assets/modid/icon.png | Bin 453 -> 0 bytes v1_19_3/src/main/resources/fabric.mod.json | 38 ----- ...ematica-printer-implementation.mixins.json | 14 -- .../resources/litematica-printer.mixins.json | 18 --- v1_19_4/build.gradle.kts | 88 ----------- v1_19_4/gradle.properties | 13 -- .../printer/v1_19_4/ActionHandler.java | 57 ------- .../printer/v1_19_4/BlockHelper.java | 31 ---- .../printer/v1_19_4/LitematicaMixinMod.java | 58 -------- .../litematica/printer/v1_19_4/Printer.java | 110 -------------- .../printer/v1_19_4/SchematicBlockState.java | 42 ------ .../printer/v1_19_4/UpdateChecker.java | 49 ------ .../printer/v1_19_4/actions/Action.java | 8 - .../v1_19_4/actions/InteractAction.java | 33 ----- .../v1_19_4/actions/PrepareAction.java | 109 -------------- .../v1_19_4/actions/ReleaseShiftAction.java | 13 -- .../printer/v1_19_4/guides/Guide.java | 130 ---------------- .../printer/v1_19_4/guides/Guides.java | 81 ---------- .../printer/v1_19_4/guides/SkipGuide.java | 37 ----- .../interaction/CampfireExtinguishGuide.java | 36 ----- .../guides/interaction/CycleStateGuide.java | 45 ------ .../guides/interaction/EnderEyeGuide.java | 33 ----- .../interaction/FlowerPotFillGuide.java | 40 ----- .../guides/interaction/InteractionGuide.java | 49 ------ .../guides/interaction/LightCandleGuide.java | 36 ----- .../guides/interaction/LogStrippingGuide.java | 47 ------ .../guides/interaction/TillingGuide.java | 39 ----- .../BlockIndifferentGuesserGuide.java | 42 ------ .../placement/BlockReplacementGuide.java | 75 ---------- .../v1_19_4/guides/placement/ChestGuide.java | 92 ------------ .../guides/placement/FallingBlockGuide.java | 37 ----- .../guides/placement/FarmlandGuide.java | 29 ---- .../guides/placement/FlowerPotGuide.java | 20 --- .../placement/GeneralPlacementGuide.java | 119 --------------- .../guides/placement/GuesserGuide.java | 110 -------------- .../v1_19_4/guides/placement/LogGuide.java | 54 ------- .../guides/placement/PlacementGuide.java | 138 ----------------- .../PropertySpecificGuesserGuide.java | 52 ------- .../guides/placement/RailGuesserGuide.java | 128 ---------------- .../guides/placement/RotatingBlockGuide.java | 58 -------- .../v1_19_4/guides/placement/SlabGuide.java | 48 ------ .../v1_19_4/guides/placement/TorchGuide.java | 31 ---- .../implementation/BlockHelperImpl.java | 14 -- .../PrinterPlacementContext.java | 59 -------- .../actions/InteractActionImpl.java | 20 --- .../mixin/MixinClientPlayerEntity.java | 103 ------------- .../v1_19_4/mixin/AxeItemAccessor.java | 20 --- .../printer/v1_19_4/mixin/ConfigsMixin.java | 35 ----- .../v1_19_4/mixin/GuiConfigsMixin.java | 61 -------- .../v1_19_4/mixin/InputHandlerMixin.java | 25 ---- .../mixin/PlayerMoveC2SPacketMixin.java | 36 ----- .../src/main/resources/assets/modid/icon.png | Bin 453 -> 0 bytes v1_19_4/src/main/resources/fabric.mod.json | 38 ----- ...ematica-printer-implementation.mixins.json | 14 -- .../resources/litematica-printer.mixins.json | 18 --- v1_20/build.gradle.kts | 88 ----------- v1_20/gradle.properties | 13 -- .../printer/v1_20/ActionHandler.java | 57 ------- .../litematica/printer/v1_20/BlockHelper.java | 31 ---- .../printer/v1_20/LitematicaMixinMod.java | 58 -------- .../printer/v1_20/SchematicBlockState.java | 42 ------ .../printer/v1_20/UpdateChecker.java | 49 ------ .../printer/v1_20/actions/Action.java | 8 - .../printer/v1_20/actions/InteractAction.java | 33 ----- .../printer/v1_20/actions/PrepareAction.java | 109 -------------- .../v1_20/actions/ReleaseShiftAction.java | 13 -- .../printer/v1_20/guides/Guides.java | 83 ----------- .../printer/v1_20/guides/SkipGuide.java | 37 ----- .../guides/interaction/CycleStateGuide.java | 45 ------ .../guides/interaction/EnderEyeGuide.java | 33 ----- .../interaction/FlowerPotFillGuide.java | 40 ----- .../guides/interaction/InteractionGuide.java | 49 ------ .../guides/interaction/LightCandleGuide.java | 36 ----- .../guides/interaction/LogStrippingGuide.java | 47 ------ .../guides/interaction/TillingGuide.java | 39 ----- .../BlockIndifferentGuesserGuide.java | 42 ------ .../v1_20/guides/placement/ChestGuide.java | 92 ------------ .../guides/placement/FallingBlockGuide.java | 37 ----- .../v1_20/guides/placement/FarmlandGuide.java | 29 ---- .../guides/placement/FlowerPotGuide.java | 20 --- .../v1_20/guides/placement/LogGuide.java | 54 ------- .../PropertySpecificGuesserGuide.java | 52 ------- .../guides/placement/RotatingBlockGuide.java | 58 -------- .../v1_20/guides/placement/SlabGuide.java | 48 ------ .../v1_20/guides/placement/TorchGuide.java | 31 ---- .../actions/InteractActionImpl.java | 20 --- .../printer/v1_20/mixin/AxeItemAccessor.java | 20 --- .../printer/v1_20/mixin/ConfigsMixin.java | 35 ----- .../printer/v1_20/mixin/GuiConfigsMixin.java | 61 -------- .../v1_20/mixin/InputHandlerMixin.java | 25 ---- .../v1_20/mixin/PlayerMoveC2SPacketMixin.java | 36 ----- .../src/main/resources/assets/modid/icon.png | Bin 453 -> 0 bytes ...ematica-printer-implementation.mixins.json | 14 -- .../resources/litematica-printer.mixins.json | 18 --- v1_20_4/build.gradle.kts | 88 ----------- v1_20_4/gradle.properties | 13 -- .../printer/v1_20_4/ActionHandler.java | 57 ------- .../printer/v1_20_4/BlockHelper.java | 31 ---- .../printer/v1_20_4/LitematicaMixinMod.java | 58 -------- .../litematica/printer/v1_20_4/Printer.java | 107 -------------- .../printer/v1_20_4/SchematicBlockState.java | 42 ------ .../printer/v1_20_4/actions/Action.java | 8 - .../v1_20_4/actions/InteractAction.java | 33 ----- .../v1_20_4/actions/PrepareAction.java | 109 -------------- .../v1_20_4/actions/ReleaseShiftAction.java | 13 -- .../printer/v1_20_4/guides/Guide.java | 129 ---------------- .../printer/v1_20_4/guides/Guides.java | 81 ---------- .../printer/v1_20_4/guides/SkipGuide.java | 37 ----- .../interaction/CampfireExtinguishGuide.java | 34 ----- .../guides/interaction/CycleStateGuide.java | 45 ------ .../guides/interaction/EnderEyeGuide.java | 33 ----- .../interaction/FlowerPotFillGuide.java | 40 ----- .../guides/interaction/InteractionGuide.java | 49 ------ .../guides/interaction/LightCandleGuide.java | 36 ----- .../guides/interaction/LogStrippingGuide.java | 47 ------ .../guides/interaction/TillingGuide.java | 39 ----- .../placement/BlockReplacementGuide.java | 76 ---------- .../v1_20_4/guides/placement/ChestGuide.java | 92 ------------ .../guides/placement/FallingBlockGuide.java | 37 ----- .../guides/placement/FarmlandGuide.java | 29 ---- .../guides/placement/FlowerPotGuide.java | 20 --- .../placement/GeneralPlacementGuide.java | 119 --------------- .../guides/placement/GuesserGuide.java | 110 -------------- .../v1_20_4/guides/placement/LogGuide.java | 54 ------- .../guides/placement/PlacementGuide.java | 139 ------------------ .../PropertySpecificGuesserGuide.java | 52 ------- .../guides/placement/RailGuesserGuide.java | 128 ---------------- .../guides/placement/RotatingBlockGuide.java | 58 -------- .../v1_20_4/guides/placement/SlabGuide.java | 48 ------ .../v1_20_4/guides/placement/TorchGuide.java | 31 ---- .../implementation/BlockHelperImpl.java | 14 -- .../PrinterPlacementContext.java | 59 -------- .../actions/InteractActionImpl.java | 20 --- .../mixin/MixinClientPlayerEntity.java | 102 ------------- .../v1_20_4/mixin/AxeItemAccessor.java | 20 --- .../printer/v1_20_4/mixin/ConfigsMixin.java | 35 ----- .../v1_20_4/mixin/GuiConfigsMixin.java | 61 -------- .../v1_20_4/mixin/InputHandlerMixin.java | 25 ---- .../mixin/PlayerMoveC2SPacketMixin.java | 36 ----- .../src/main/resources/assets/modid/icon.png | Bin 453 -> 0 bytes v1_20_4/src/main/resources/fabric.mod.json | 38 ----- ...ematica-printer-implementation.mixins.json | 14 -- .../resources/litematica-printer.mixins.json | 18 --- 361 files changed, 200 insertions(+), 16236 deletions(-) rename {v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19 => src/main/java/me/aleksilassila/litematica/printer}/ActionHandler.java (88%) rename {v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19 => src/main/java/me/aleksilassila/litematica/printer}/BlockHelper.java (96%) rename {v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19 => src/main/java/me/aleksilassila/litematica/printer}/LitematicaMixinMod.java (98%) rename {v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20 => src/main/java/me/aleksilassila/litematica/printer}/Printer.java (94%) rename {v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17 => src/main/java/me/aleksilassila/litematica/printer}/SchematicBlockState.java (96%) rename {v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4 => src/main/java/me/aleksilassila/litematica/printer}/UpdateChecker.java (97%) rename {v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17 => src/main/java/me/aleksilassila/litematica/printer}/actions/Action.java (78%) rename {v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19 => src/main/java/me/aleksilassila/litematica/printer}/actions/InteractAction.java (82%) rename {v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19 => src/main/java/me/aleksilassila/litematica/printer}/actions/PrepareAction.java (96%) rename {v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19 => src/main/java/me/aleksilassila/litematica/printer}/actions/ReleaseShiftAction.java (89%) rename {v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20 => src/main/java/me/aleksilassila/litematica/printer}/guides/Guide.java (93%) rename {v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17 => src/main/java/me/aleksilassila/litematica/printer}/guides/Guides.java (93%) rename {v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19 => src/main/java/me/aleksilassila/litematica/printer}/guides/SkipGuide.java (80%) rename {v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20 => src/main/java/me/aleksilassila/litematica/printer}/guides/interaction/CampfireExtinguishGuide.java (87%) rename {v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19 => src/main/java/me/aleksilassila/litematica/printer}/guides/interaction/CycleStateGuide.java (90%) rename {v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19 => src/main/java/me/aleksilassila/litematica/printer}/guides/interaction/EnderEyeGuide.java (86%) rename {v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17 => src/main/java/me/aleksilassila/litematica/printer}/guides/interaction/FlowerPotFillGuide.java (89%) rename {v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17 => src/main/java/me/aleksilassila/litematica/printer}/guides/interaction/InteractionGuide.java (69%) rename {v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17 => src/main/java/me/aleksilassila/litematica/printer}/guides/interaction/LightCandleGuide.java (88%) rename {v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17 => src/main/java/me/aleksilassila/litematica/printer}/guides/interaction/LogStrippingGuide.java (82%) rename {v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19 => src/main/java/me/aleksilassila/litematica/printer}/guides/interaction/TillingGuide.java (82%) rename {v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4 => src/main/java/me/aleksilassila/litematica/printer}/guides/placement/BlockIndifferentGuesserGuide.java (92%) rename {v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20 => src/main/java/me/aleksilassila/litematica/printer}/guides/placement/BlockReplacementGuide.java (90%) rename {v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19 => src/main/java/me/aleksilassila/litematica/printer}/guides/placement/ChestGuide.java (96%) rename {v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18 => src/main/java/me/aleksilassila/litematica/printer}/guides/placement/FallingBlockGuide.java (86%) rename {v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18 => src/main/java/me/aleksilassila/litematica/printer}/guides/placement/FarmlandGuide.java (84%) rename {v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19 => src/main/java/me/aleksilassila/litematica/printer}/guides/placement/FlowerPotGuide.java (77%) rename {v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20 => src/main/java/me/aleksilassila/litematica/printer}/guides/placement/GeneralPlacementGuide.java (94%) rename {v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20 => src/main/java/me/aleksilassila/litematica/printer}/guides/placement/GuesserGuide.java (93%) rename {v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19 => src/main/java/me/aleksilassila/litematica/printer}/guides/placement/LogGuide.java (83%) rename {v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20 => src/main/java/me/aleksilassila/litematica/printer}/guides/placement/PlacementGuide.java (87%) rename {v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17 => src/main/java/me/aleksilassila/litematica/printer}/guides/placement/PropertySpecificGuesserGuide.java (92%) rename {v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20 => src/main/java/me/aleksilassila/litematica/printer}/guides/placement/RailGuesserGuide.java (97%) rename {v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19 => src/main/java/me/aleksilassila/litematica/printer}/guides/placement/RotatingBlockGuide.java (83%) rename {v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19 => src/main/java/me/aleksilassila/litematica/printer}/guides/placement/SlabGuide.java (92%) rename {v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19 => src/main/java/me/aleksilassila/litematica/printer}/guides/placement/TorchGuide.java (86%) rename {v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20 => src/main/java/me/aleksilassila/litematica/printer}/implementation/BlockHelperImpl.java (64%) rename {v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20 => src/main/java/me/aleksilassila/litematica/printer}/implementation/PrinterPlacementContext.java (97%) rename {v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19 => src/main/java/me/aleksilassila/litematica/printer}/implementation/actions/InteractActionImpl.java (72%) rename {v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20 => src/main/java/me/aleksilassila/litematica/printer}/implementation/mixin/MixinClientPlayerEntity.java (92%) rename {v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19 => src/main/java/me/aleksilassila/litematica/printer}/mixin/AxeItemAccessor.java (88%) rename {v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19 => src/main/java/me/aleksilassila/litematica/printer}/mixin/ConfigsMixin.java (92%) rename {v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19 => src/main/java/me/aleksilassila/litematica/printer}/mixin/GuiConfigsMixin.java (93%) rename {v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18 => src/main/java/me/aleksilassila/litematica/printer}/mixin/InputHandlerMixin.java (87%) rename {v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17 => src/main/java/me/aleksilassila/litematica/printer}/mixin/PlayerMoveC2SPacketMixin.java (83%) rename {v1_17/src => src}/main/resources/assets/modid/icon.png (100%) rename {v1_20/src => src}/main/resources/fabric.mod.json (89%) rename {v1_18/src => src}/main/resources/litematica-printer-implementation.mixins.json (71%) rename {v1_19/src => src}/main/resources/litematica-printer.mixins.json (81%) delete mode 100644 v1_17/build.gradle.kts delete mode 100644 v1_17/gradle.properties delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/ActionHandler.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/BlockHelper.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/LitematicaMixinMod.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/Printer.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/UpdateChecker.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/actions/InteractAction.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/actions/PrepareAction.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/actions/ReleaseShiftAction.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/Guide.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/SkipGuide.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/CampfireExtinguishGuide.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/CycleStateGuide.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/EnderEyeGuide.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/TillingGuide.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/BlockIndifferentGuesserGuide.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/BlockReplacementGuide.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/ChestGuide.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/FallingBlockGuide.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/FarmlandGuide.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/FlowerPotGuide.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/GeneralPlacementGuide.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/GuesserGuide.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/LogGuide.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/PlacementGuide.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/RailGuesserGuide.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/RotatingBlockGuide.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/SlabGuide.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/TorchGuide.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/implementation/BlockHelperImpl.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/implementation/PrinterPlacementContext.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/implementation/actions/InteractActionImpl.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/implementation/mixin/MixinClientPlayerEntity.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/mixin/AxeItemAccessor.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/mixin/ConfigsMixin.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/mixin/GuiConfigsMixin.java delete mode 100644 v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/mixin/InputHandlerMixin.java delete mode 100644 v1_17/src/main/resources/fabric.mod.json delete mode 100644 v1_17/src/main/resources/litematica-printer-implementation.mixins.json delete mode 100644 v1_17/src/main/resources/litematica-printer.mixins.json delete mode 100644 v1_18/build.gradle.kts delete mode 100644 v1_18/gradle.properties delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/ActionHandler.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/BlockHelper.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/LitematicaMixinMod.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/Printer.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/SchematicBlockState.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/UpdateChecker.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/actions/Action.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/actions/InteractAction.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/actions/PrepareAction.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/actions/ReleaseShiftAction.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/Guide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/Guides.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/SkipGuide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/CampfireExtinguishGuide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/CycleStateGuide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/EnderEyeGuide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/FlowerPotFillGuide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/InteractionGuide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/LightCandleGuide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/LogStrippingGuide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/TillingGuide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/BlockIndifferentGuesserGuide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/BlockReplacementGuide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/ChestGuide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/FlowerPotGuide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/GeneralPlacementGuide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/GuesserGuide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/LogGuide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/PlacementGuide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/PropertySpecificGuesserGuide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/RailGuesserGuide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/RotatingBlockGuide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/SlabGuide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/TorchGuide.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/implementation/BlockHelperImpl.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/implementation/PrinterPlacementContext.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/implementation/actions/InteractActionImpl.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/implementation/mixin/MixinClientPlayerEntity.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/mixin/AxeItemAccessor.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/mixin/ConfigsMixin.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/mixin/GuiConfigsMixin.java delete mode 100644 v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/mixin/PlayerMoveC2SPacketMixin.java delete mode 100644 v1_18/src/main/resources/fabric.mod.json delete mode 100644 v1_18/src/main/resources/litematica-printer.mixins.json delete mode 100644 v1_18/src/main/resources/modid/icon.png delete mode 100644 v1_19/build.gradle.kts delete mode 100644 v1_19/gradle.properties delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/Printer.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/SchematicBlockState.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/UpdateChecker.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/actions/Action.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/Guide.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/Guides.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/CampfireExtinguishGuide.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/FlowerPotFillGuide.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/InteractionGuide.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/LightCandleGuide.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/LogStrippingGuide.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/BlockIndifferentGuesserGuide.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/BlockReplacementGuide.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/FallingBlockGuide.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/FarmlandGuide.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/GeneralPlacementGuide.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/GuesserGuide.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/PlacementGuide.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/PropertySpecificGuesserGuide.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/RailGuesserGuide.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/implementation/BlockHelperImpl.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/implementation/PrinterPlacementContext.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/implementation/mixin/MixinClientPlayerEntity.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/mixin/InputHandlerMixin.java delete mode 100644 v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/mixin/PlayerMoveC2SPacketMixin.java delete mode 100644 v1_19/src/main/resources/assets/modid/icon.png delete mode 100644 v1_19/src/main/resources/fabric.mod.json delete mode 100644 v1_19/src/main/resources/litematica-printer-implementation.mixins.json delete mode 100644 v1_19_3/build.gradle.kts delete mode 100644 v1_19_3/gradle.properties delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/ActionHandler.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/BlockHelper.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/LitematicaMixinMod.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/Printer.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/SchematicBlockState.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/UpdateChecker.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/actions/Action.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/actions/InteractAction.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/actions/PrepareAction.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/actions/ReleaseShiftAction.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/Guide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/Guides.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/SkipGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/CampfireExtinguishGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/CycleStateGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/EnderEyeGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/FlowerPotFillGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/InteractionGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/LightCandleGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/LogStrippingGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/TillingGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/BlockIndifferentGuesserGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/BlockReplacementGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/ChestGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/FallingBlockGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/FarmlandGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/FlowerPotGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/GeneralPlacementGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/GuesserGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/LogGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/PlacementGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/PropertySpecificGuesserGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/RailGuesserGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/RotatingBlockGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/SlabGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/TorchGuide.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/implementation/BlockHelperImpl.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/implementation/PrinterPlacementContext.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/implementation/actions/InteractActionImpl.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/implementation/mixin/MixinClientPlayerEntity.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/mixin/AxeItemAccessor.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/mixin/ConfigsMixin.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/mixin/GuiConfigsMixin.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/mixin/InputHandlerMixin.java delete mode 100644 v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/mixin/PlayerMoveC2SPacketMixin.java delete mode 100644 v1_19_3/src/main/resources/assets/modid/icon.png delete mode 100644 v1_19_3/src/main/resources/fabric.mod.json delete mode 100644 v1_19_3/src/main/resources/litematica-printer-implementation.mixins.json delete mode 100644 v1_19_3/src/main/resources/litematica-printer.mixins.json delete mode 100644 v1_19_4/build.gradle.kts delete mode 100644 v1_19_4/gradle.properties delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/ActionHandler.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/BlockHelper.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/LitematicaMixinMod.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/Printer.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/SchematicBlockState.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/UpdateChecker.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/actions/Action.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/actions/InteractAction.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/actions/PrepareAction.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/actions/ReleaseShiftAction.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/Guide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/Guides.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/SkipGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/CampfireExtinguishGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/CycleStateGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/EnderEyeGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/FlowerPotFillGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/InteractionGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/LightCandleGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/LogStrippingGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/TillingGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/BlockIndifferentGuesserGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/BlockReplacementGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/ChestGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/FallingBlockGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/FarmlandGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/FlowerPotGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/GeneralPlacementGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/GuesserGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/LogGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/PlacementGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/PropertySpecificGuesserGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/RailGuesserGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/RotatingBlockGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/SlabGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/TorchGuide.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/implementation/BlockHelperImpl.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/implementation/PrinterPlacementContext.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/implementation/actions/InteractActionImpl.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/implementation/mixin/MixinClientPlayerEntity.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/mixin/AxeItemAccessor.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/mixin/ConfigsMixin.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/mixin/GuiConfigsMixin.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/mixin/InputHandlerMixin.java delete mode 100644 v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/mixin/PlayerMoveC2SPacketMixin.java delete mode 100644 v1_19_4/src/main/resources/assets/modid/icon.png delete mode 100644 v1_19_4/src/main/resources/fabric.mod.json delete mode 100644 v1_19_4/src/main/resources/litematica-printer-implementation.mixins.json delete mode 100644 v1_19_4/src/main/resources/litematica-printer.mixins.json delete mode 100644 v1_20/build.gradle.kts delete mode 100644 v1_20/gradle.properties delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/ActionHandler.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/BlockHelper.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/LitematicaMixinMod.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/SchematicBlockState.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/UpdateChecker.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/actions/Action.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/actions/InteractAction.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/actions/PrepareAction.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/actions/ReleaseShiftAction.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/Guides.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/SkipGuide.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/CycleStateGuide.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/EnderEyeGuide.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/FlowerPotFillGuide.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/InteractionGuide.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/LightCandleGuide.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/LogStrippingGuide.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/TillingGuide.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/BlockIndifferentGuesserGuide.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/ChestGuide.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/FallingBlockGuide.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/FarmlandGuide.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/FlowerPotGuide.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/LogGuide.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/PropertySpecificGuesserGuide.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/RotatingBlockGuide.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/SlabGuide.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/TorchGuide.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/implementation/actions/InteractActionImpl.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/mixin/AxeItemAccessor.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/mixin/ConfigsMixin.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/mixin/GuiConfigsMixin.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/mixin/InputHandlerMixin.java delete mode 100644 v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/mixin/PlayerMoveC2SPacketMixin.java delete mode 100644 v1_20/src/main/resources/assets/modid/icon.png delete mode 100644 v1_20/src/main/resources/litematica-printer-implementation.mixins.json delete mode 100644 v1_20/src/main/resources/litematica-printer.mixins.json delete mode 100644 v1_20_4/build.gradle.kts delete mode 100644 v1_20_4/gradle.properties delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/ActionHandler.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/BlockHelper.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/LitematicaMixinMod.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/Printer.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/SchematicBlockState.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/actions/Action.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/actions/InteractAction.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/actions/PrepareAction.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/actions/ReleaseShiftAction.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/Guide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/Guides.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/SkipGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/CampfireExtinguishGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/CycleStateGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/EnderEyeGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/FlowerPotFillGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/InteractionGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/LightCandleGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/LogStrippingGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/TillingGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/BlockReplacementGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/ChestGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/FallingBlockGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/FarmlandGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/FlowerPotGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/GeneralPlacementGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/GuesserGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/LogGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/PlacementGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/PropertySpecificGuesserGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/RailGuesserGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/RotatingBlockGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/SlabGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/TorchGuide.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/implementation/BlockHelperImpl.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/implementation/PrinterPlacementContext.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/implementation/actions/InteractActionImpl.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/implementation/mixin/MixinClientPlayerEntity.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/mixin/AxeItemAccessor.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/mixin/ConfigsMixin.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/mixin/GuiConfigsMixin.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/mixin/InputHandlerMixin.java delete mode 100644 v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/mixin/PlayerMoveC2SPacketMixin.java delete mode 100644 v1_20_4/src/main/resources/assets/modid/icon.png delete mode 100644 v1_20_4/src/main/resources/fabric.mod.json delete mode 100644 v1_20_4/src/main/resources/litematica-printer-implementation.mixins.json delete mode 100644 v1_20_4/src/main/resources/litematica-printer.mixins.json diff --git a/build.gradle.kts b/build.gradle.kts index 1cac5cd50..909397bc5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,48 +1,68 @@ plugins { - id("java") + id("fabric-loom").version("1.6-SNAPSHOT") + id("maven-publish") } -subprojects { - apply() +//subprojects { +//apply() - repositories { - mavenLocal() - mavenCentral() - } - - java { - sourceCompatibility = JavaVersion.VERSION_16 - targetCompatibility = JavaVersion.VERSION_16 - } -} +val minecraft_version: String by project +val yarn_mappings: String by project +val loader_version: String by project +val fabric_version: String by project +val malilib_version: String by project +val litematica_projectid: String by project +val litematica_fileid: String by project val archives_base_name: String by project val mod_version: String by project -val buildAll = tasks.create("buildAll") { - dependsOn(":v1_17:build") - dependsOn(":v1_18:build") - dependsOn(":v1_19:build") - dependsOn(":v1_19_3:build") - dependsOn(":v1_19_4:build") - // This isn't working.... you still have to run each build individually - tasks.findByName(":v1_19_3:build")?.mustRunAfter(":v1_19_4:build") - tasks.findByName(":v1_19:build")?.mustRunAfter(":v1_19_3:build") - tasks.findByName(":v1_18:build")?.mustRunAfter(":v1_19:build") - tasks.findByName(":v1_17:build")?.mustRunAfter(":v1_18:build") +java { + withSourcesJar() + + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 +} +//} + +repositories { + mavenLocal() + mavenCentral() + maven("https://masa.dy.fi/maven") + maven("https://www.cursemaven.com") +} + +dependencies { +// implementation(project(":common")) + minecraft("com.mojang:minecraft:${minecraft_version}") + mappings("net.fabricmc:yarn:${yarn_mappings}:v2") + modImplementation("net.fabricmc:fabric-loader:${loader_version}") + modImplementation("net.fabricmc.fabric-api:fabric-api:${fabric_version}") + modImplementation("fi.dy.masa.malilib:malilib-fabric-${malilib_version}") + modImplementation("curse.maven:litematica-${litematica_projectid}:${litematica_fileid}") +} + +tasks.withType { + inputs.property("version", mod_version) + + filesMatching("fabric.mod.json") { + expand(mapOf("version" to mod_version)) + } +} + +tasks.register("copyJar") { + // Specify that this task runs after the 'build' task + dependsOn("build") + + // Specify the task's action doLast { - println("Copying files...") - file("v1_19_4/build/libs/v1_19_4.jar").copyTo( - file("build/${archives_base_name}-1.19.4-${mod_version}.jar"), - true - ) - file("v1_19_3/build/libs/v1_19_3.jar").copyTo( - file("build/${archives_base_name}-1.19.3-${mod_version}.jar"), - true - ) - file("v1_19/build/libs/v1_19.jar").copyTo(file("build/${archives_base_name}-1.19-${mod_version}.jar"), true) - file("v1_18/build/libs/v1_18.jar").copyTo(file("build/${archives_base_name}-1.18-${mod_version}.jar"), true) - file("v1_17/build/libs/v1_17.jar").copyTo(file("build/${archives_base_name}-1.17-${mod_version}.jar"), true) + val destination = file("build/${archives_base_name}-${minecraft_version}-${mod_version}.jar") + file("build/libs/litematica-printer.jar").copyTo(destination, true) + println("Copied output to ${destination.absolutePath}") } } + +tasks.build { + finalizedBy("copyJar") +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 6b568eaa1..b65fe8c1a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,18 @@ # Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx2G -org.gradle.parallel=false +org.gradle.jvmargs=-Xmx1G +#org.gradle.parallel=false # Mod Properties -mod_version=3.2 +mod_version=3.2.1 maven_group=net.fabricmc archives_base_name=litematica-printer +# https://masa.dy.fi/maven/fi/dy/masa/malilib/ +malilib_version=1.20.4:0.18.0 +# https://www.curseforge.com/minecraft/mc-mods/litematica/files +litematica_fileid=4946471 +litematica_projectid=308892 +# Fabric Properties: https://fabricmc.net/develop/ +minecraft_version=1.20.4 +yarn_mappings=1.20.4+build.3 +loader_version=0.15.3 +#Fabric api +fabric_version=0.91.3+1.20.4 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c30b486a8..2617362fd 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index 656e22725..b02216baa 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,10 +8,3 @@ pluginManagement { gradlePluginPortal() } } -include 'v1_20_4' -//include 'v1_20' -//include 'v1_19_4' -//include 'v1_19_3' -//include 'v1_19' -//include 'v1_18' -//include 'v1_17' diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/ActionHandler.java b/src/main/java/me/aleksilassila/litematica/printer/ActionHandler.java similarity index 88% rename from v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/ActionHandler.java rename to src/main/java/me/aleksilassila/litematica/printer/ActionHandler.java index 4d1066bd0..74290c5ea 100644 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/ActionHandler.java +++ b/src/main/java/me/aleksilassila/litematica/printer/ActionHandler.java @@ -1,7 +1,7 @@ -package me.aleksilassila.litematica.printer.v1_19; +package me.aleksilassila.litematica.printer; -import me.aleksilassila.litematica.printer.v1_19.actions.Action; -import me.aleksilassila.litematica.printer.v1_19.actions.PrepareAction; +import me.aleksilassila.litematica.printer.actions.Action; +import me.aleksilassila.litematica.printer.actions.PrepareAction; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/BlockHelper.java b/src/main/java/me/aleksilassila/litematica/printer/BlockHelper.java similarity index 96% rename from v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/BlockHelper.java rename to src/main/java/me/aleksilassila/litematica/printer/BlockHelper.java index 7f3f2d170..1e9ee3f2f 100644 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/BlockHelper.java +++ b/src/main/java/me/aleksilassila/litematica/printer/BlockHelper.java @@ -1,4 +1,4 @@ -package me.aleksilassila.litematica.printer.v1_19; +package me.aleksilassila.litematica.printer; import net.minecraft.block.*; import net.minecraft.item.Item; diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/LitematicaMixinMod.java b/src/main/java/me/aleksilassila/litematica/printer/LitematicaMixinMod.java similarity index 98% rename from v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/LitematicaMixinMod.java rename to src/main/java/me/aleksilassila/litematica/printer/LitematicaMixinMod.java index 0ede14a64..aea262b94 100644 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/LitematicaMixinMod.java +++ b/src/main/java/me/aleksilassila/litematica/printer/LitematicaMixinMod.java @@ -1,4 +1,4 @@ -package me.aleksilassila.litematica.printer.v1_19; +package me.aleksilassila.litematica.printer; import com.google.common.collect.ImmutableList; import fi.dy.masa.litematica.config.Configs; diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/Printer.java b/src/main/java/me/aleksilassila/litematica/printer/Printer.java similarity index 94% rename from v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/Printer.java rename to src/main/java/me/aleksilassila/litematica/printer/Printer.java index 738292ab1..0b893413f 100644 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/Printer.java +++ b/src/main/java/me/aleksilassila/litematica/printer/Printer.java @@ -1,12 +1,12 @@ -package me.aleksilassila.litematica.printer.v1_20; +package me.aleksilassila.litematica.printer; import fi.dy.masa.litematica.data.DataManager; import fi.dy.masa.litematica.util.RayTraceUtils; import fi.dy.masa.litematica.world.SchematicWorldHandler; import fi.dy.masa.litematica.world.WorldSchematic; -import me.aleksilassila.litematica.printer.v1_20.actions.Action; -import me.aleksilassila.litematica.printer.v1_20.guides.Guide; -import me.aleksilassila.litematica.printer.v1_20.guides.Guides; +import me.aleksilassila.litematica.printer.actions.Action; +import me.aleksilassila.litematica.printer.guides.Guide; +import me.aleksilassila.litematica.printer.guides.Guides; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.entity.player.PlayerAbilities; diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/SchematicBlockState.java b/src/main/java/me/aleksilassila/litematica/printer/SchematicBlockState.java similarity index 96% rename from v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/SchematicBlockState.java rename to src/main/java/me/aleksilassila/litematica/printer/SchematicBlockState.java index a489944bc..4fb409d19 100644 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/SchematicBlockState.java +++ b/src/main/java/me/aleksilassila/litematica/printer/SchematicBlockState.java @@ -1,4 +1,4 @@ -package me.aleksilassila.litematica.printer.v1_17; +package me.aleksilassila.litematica.printer; import fi.dy.masa.litematica.world.WorldSchematic; import net.minecraft.block.BlockState; diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/UpdateChecker.java b/src/main/java/me/aleksilassila/litematica/printer/UpdateChecker.java similarity index 97% rename from v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/UpdateChecker.java rename to src/main/java/me/aleksilassila/litematica/printer/UpdateChecker.java index d4c7c83ec..6e19cd95e 100644 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/UpdateChecker.java +++ b/src/main/java/me/aleksilassila/litematica/printer/UpdateChecker.java @@ -1,4 +1,4 @@ -package me.aleksilassila.litematica.printer.v1_20_4; +package me.aleksilassila.litematica.printer; import com.google.gson.JsonArray; import com.google.gson.JsonObject; diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/actions/Action.java b/src/main/java/me/aleksilassila/litematica/printer/actions/Action.java similarity index 78% rename from v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/actions/Action.java rename to src/main/java/me/aleksilassila/litematica/printer/actions/Action.java index a520e0b92..2572e251e 100644 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/actions/Action.java +++ b/src/main/java/me/aleksilassila/litematica/printer/actions/Action.java @@ -1,4 +1,4 @@ -package me.aleksilassila.litematica.printer.v1_17.actions; +package me.aleksilassila.litematica.printer.actions; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/actions/InteractAction.java b/src/main/java/me/aleksilassila/litematica/printer/actions/InteractAction.java similarity index 82% rename from v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/actions/InteractAction.java rename to src/main/java/me/aleksilassila/litematica/printer/actions/InteractAction.java index 3d152ccd5..a074dec68 100644 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/actions/InteractAction.java +++ b/src/main/java/me/aleksilassila/litematica/printer/actions/InteractAction.java @@ -1,7 +1,7 @@ -package me.aleksilassila.litematica.printer.v1_19.actions; +package me.aleksilassila.litematica.printer.actions; -import me.aleksilassila.litematica.printer.v1_19.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_19.implementation.PrinterPlacementContext; +import me.aleksilassila.litematica.printer.LitematicaMixinMod; +import me.aleksilassila.litematica.printer.implementation.PrinterPlacementContext; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.util.Hand; diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/actions/PrepareAction.java b/src/main/java/me/aleksilassila/litematica/printer/actions/PrepareAction.java similarity index 96% rename from v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/actions/PrepareAction.java rename to src/main/java/me/aleksilassila/litematica/printer/actions/PrepareAction.java index 0f4aab0c1..de195a8dc 100644 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/actions/PrepareAction.java +++ b/src/main/java/me/aleksilassila/litematica/printer/actions/PrepareAction.java @@ -1,6 +1,6 @@ -package me.aleksilassila.litematica.printer.v1_19.actions; +package me.aleksilassila.litematica.printer.actions; -import me.aleksilassila.litematica.printer.v1_19.implementation.PrinterPlacementContext; +import me.aleksilassila.litematica.printer.implementation.PrinterPlacementContext; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.entity.player.PlayerInventory; diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/actions/ReleaseShiftAction.java b/src/main/java/me/aleksilassila/litematica/printer/actions/ReleaseShiftAction.java similarity index 89% rename from v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/actions/ReleaseShiftAction.java rename to src/main/java/me/aleksilassila/litematica/printer/actions/ReleaseShiftAction.java index c5d723e58..425ccfc87 100644 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/actions/ReleaseShiftAction.java +++ b/src/main/java/me/aleksilassila/litematica/printer/actions/ReleaseShiftAction.java @@ -1,4 +1,4 @@ -package me.aleksilassila.litematica.printer.v1_19.actions; +package me.aleksilassila.litematica.printer.actions; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/Guide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/Guide.java similarity index 93% rename from v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/Guide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/Guide.java index e85fe900b..77c593b31 100644 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/Guide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/Guide.java @@ -1,8 +1,8 @@ -package me.aleksilassila.litematica.printer.v1_20.guides; +package me.aleksilassila.litematica.printer.guides; -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_20.actions.Action; -import me.aleksilassila.litematica.printer.v1_20.implementation.BlockHelperImpl; +import me.aleksilassila.litematica.printer.SchematicBlockState; +import me.aleksilassila.litematica.printer.actions.Action; +import me.aleksilassila.litematica.printer.implementation.BlockHelperImpl; import net.minecraft.block.BlockState; import net.minecraft.block.CoralBlock; import net.minecraft.client.network.ClientPlayerEntity; diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/Guides.java b/src/main/java/me/aleksilassila/litematica/printer/guides/Guides.java similarity index 93% rename from v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/Guides.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/Guides.java index f681fdd83..4ac057be2 100644 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/Guides.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/Guides.java @@ -1,8 +1,8 @@ -package me.aleksilassila.litematica.printer.v1_17.guides; +package me.aleksilassila.litematica.printer.guides; -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_17.guides.interaction.*; -import me.aleksilassila.litematica.printer.v1_17.guides.placement.*; +import me.aleksilassila.litematica.printer.SchematicBlockState; +import me.aleksilassila.litematica.printer.guides.interaction.*; +import me.aleksilassila.litematica.printer.guides.placement.*; import net.minecraft.block.*; import net.minecraft.util.Pair; diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/SkipGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/SkipGuide.java similarity index 80% rename from v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/SkipGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/SkipGuide.java index 1f74d92b7..41ac9ce6e 100644 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/SkipGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/SkipGuide.java @@ -1,7 +1,7 @@ -package me.aleksilassila.litematica.printer.v1_19.guides; +package me.aleksilassila.litematica.printer.guides; -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19.actions.Action; +import me.aleksilassila.litematica.printer.SchematicBlockState; +import me.aleksilassila.litematica.printer.actions.Action; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.NotNull; diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/CampfireExtinguishGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/interaction/CampfireExtinguishGuide.java similarity index 87% rename from v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/CampfireExtinguishGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/interaction/CampfireExtinguishGuide.java index 7c366d111..8855e9a67 100644 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/CampfireExtinguishGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/interaction/CampfireExtinguishGuide.java @@ -1,6 +1,6 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.interaction; +package me.aleksilassila.litematica.printer.guides.interaction; -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; +import me.aleksilassila.litematica.printer.SchematicBlockState; import net.minecraft.block.CampfireBlock; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.item.ItemStack; diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/CycleStateGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/interaction/CycleStateGuide.java similarity index 90% rename from v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/CycleStateGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/interaction/CycleStateGuide.java index 0040bc032..db27f39ee 100644 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/CycleStateGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/interaction/CycleStateGuide.java @@ -1,6 +1,6 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.interaction; +package me.aleksilassila.litematica.printer.guides.interaction; -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; +import me.aleksilassila.litematica.printer.SchematicBlockState; import net.minecraft.block.BlockState; import net.minecraft.block.LeverBlock; import net.minecraft.client.network.ClientPlayerEntity; diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/EnderEyeGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/interaction/EnderEyeGuide.java similarity index 86% rename from v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/EnderEyeGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/interaction/EnderEyeGuide.java index 45d72da9b..a9c647cb4 100644 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/EnderEyeGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/interaction/EnderEyeGuide.java @@ -1,6 +1,6 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.interaction; +package me.aleksilassila.litematica.printer.guides.interaction; -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; +import me.aleksilassila.litematica.printer.SchematicBlockState; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/FlowerPotFillGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/interaction/FlowerPotFillGuide.java similarity index 89% rename from v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/FlowerPotFillGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/interaction/FlowerPotFillGuide.java index 8afaa9309..cc5153b8e 100644 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/FlowerPotFillGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/interaction/FlowerPotFillGuide.java @@ -1,6 +1,6 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.interaction; +package me.aleksilassila.litematica.printer.guides.interaction; -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; +import me.aleksilassila.litematica.printer.SchematicBlockState; import net.minecraft.block.Block; import net.minecraft.block.FlowerPotBlock; import net.minecraft.client.network.ClientPlayerEntity; diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/InteractionGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/interaction/InteractionGuide.java similarity index 69% rename from v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/InteractionGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/interaction/InteractionGuide.java index 892b51a81..2a0d5348e 100644 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/InteractionGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/interaction/InteractionGuide.java @@ -1,12 +1,12 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_17.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_17.actions.Action; -import me.aleksilassila.litematica.printer.v1_17.actions.PrepareAction; -import me.aleksilassila.litematica.printer.v1_17.actions.ReleaseShiftAction; -import me.aleksilassila.litematica.printer.v1_17.guides.Guide; -import me.aleksilassila.litematica.printer.v1_17.implementation.actions.InteractActionImpl; +package me.aleksilassila.litematica.printer.guides.interaction; + +import me.aleksilassila.litematica.printer.implementation.PrinterPlacementContext; +import me.aleksilassila.litematica.printer.SchematicBlockState; +import me.aleksilassila.litematica.printer.actions.Action; +import me.aleksilassila.litematica.printer.actions.PrepareAction; +import me.aleksilassila.litematica.printer.actions.ReleaseShiftAction; +import me.aleksilassila.litematica.printer.guides.Guide; +import me.aleksilassila.litematica.printer.implementation.actions.InteractActionImpl; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.hit.BlockHitResult; diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/LightCandleGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/interaction/LightCandleGuide.java similarity index 88% rename from v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/LightCandleGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/interaction/LightCandleGuide.java index a4d09b886..ada714dd1 100644 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/LightCandleGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/interaction/LightCandleGuide.java @@ -1,6 +1,6 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.interaction; +package me.aleksilassila.litematica.printer.guides.interaction; -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; +import me.aleksilassila.litematica.printer.SchematicBlockState; import net.minecraft.block.AbstractCandleBlock; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.item.ItemStack; diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/LogStrippingGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/interaction/LogStrippingGuide.java similarity index 82% rename from v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/LogStrippingGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/interaction/LogStrippingGuide.java index a93f1ac6e..baab5dc36 100644 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/LogStrippingGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/interaction/LogStrippingGuide.java @@ -1,8 +1,8 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.interaction; +package me.aleksilassila.litematica.printer.guides.interaction; -import me.aleksilassila.litematica.printer.v1_17.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_17.mixin.AxeItemAccessor; +import me.aleksilassila.litematica.printer.LitematicaMixinMod; +import me.aleksilassila.litematica.printer.SchematicBlockState; +import me.aleksilassila.litematica.printer.mixin.AxeItemAccessor; import net.minecraft.block.Block; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.item.Item; diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/TillingGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/interaction/TillingGuide.java similarity index 82% rename from v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/TillingGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/interaction/TillingGuide.java index c9f69b459..0c44e660a 100644 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/TillingGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/interaction/TillingGuide.java @@ -1,7 +1,7 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.interaction; +package me.aleksilassila.litematica.printer.guides.interaction; -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19.guides.placement.FarmlandGuide; +import me.aleksilassila.litematica.printer.SchematicBlockState; +import me.aleksilassila.litematica.printer.guides.placement.FarmlandGuide; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/BlockIndifferentGuesserGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/BlockIndifferentGuesserGuide.java similarity index 92% rename from v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/BlockIndifferentGuesserGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/placement/BlockIndifferentGuesserGuide.java index aea14bb9e..8ca832c72 100644 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/BlockIndifferentGuesserGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/BlockIndifferentGuesserGuide.java @@ -1,6 +1,6 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.placement; +package me.aleksilassila.litematica.printer.guides.placement; -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; +import me.aleksilassila.litematica.printer.SchematicBlockState; import net.minecraft.block.*; public class BlockIndifferentGuesserGuide extends GuesserGuide { diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/BlockReplacementGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/BlockReplacementGuide.java similarity index 90% rename from v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/BlockReplacementGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/placement/BlockReplacementGuide.java index 3d26bc277..9bac734b3 100644 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/BlockReplacementGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/BlockReplacementGuide.java @@ -1,8 +1,8 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.placement; +package me.aleksilassila.litematica.printer.guides.placement; -import me.aleksilassila.litematica.printer.v1_20.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_20.guides.Guide; +import me.aleksilassila.litematica.printer.implementation.PrinterPlacementContext; +import me.aleksilassila.litematica.printer.SchematicBlockState; +import me.aleksilassila.litematica.printer.guides.Guide; import net.minecraft.block.CandleBlock; import net.minecraft.block.SeaPickleBlock; import net.minecraft.block.SlabBlock; diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/ChestGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/ChestGuide.java similarity index 96% rename from v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/ChestGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/placement/ChestGuide.java index a0930e16e..44c7288b9 100644 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/ChestGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/ChestGuide.java @@ -1,6 +1,6 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.placement; +package me.aleksilassila.litematica.printer.guides.placement; -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; +import me.aleksilassila.litematica.printer.SchematicBlockState; import net.minecraft.block.BlockState; import net.minecraft.block.ChestBlock; import net.minecraft.block.enums.ChestType; diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/FallingBlockGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/FallingBlockGuide.java similarity index 86% rename from v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/FallingBlockGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/placement/FallingBlockGuide.java index 48892857f..1660d5843 100644 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/FallingBlockGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/FallingBlockGuide.java @@ -1,6 +1,6 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.placement; +package me.aleksilassila.litematica.printer.guides.placement; -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; +import me.aleksilassila.litematica.printer.SchematicBlockState; import net.minecraft.block.BlockState; import net.minecraft.block.FallingBlock; import net.minecraft.client.network.ClientPlayerEntity; diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/FarmlandGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/FarmlandGuide.java similarity index 84% rename from v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/FarmlandGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/placement/FarmlandGuide.java index d291bc011..65df69173 100644 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/FarmlandGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/FarmlandGuide.java @@ -1,6 +1,6 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.placement; +package me.aleksilassila.litematica.printer.guides.placement; -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; +import me.aleksilassila.litematica.printer.SchematicBlockState; import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.item.ItemStack; diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/FlowerPotGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/FlowerPotGuide.java similarity index 77% rename from v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/FlowerPotGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/placement/FlowerPotGuide.java index 4500d4421..334e7893c 100644 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/FlowerPotGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/FlowerPotGuide.java @@ -1,6 +1,6 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.placement; +package me.aleksilassila.litematica.printer.guides.placement; -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; +import me.aleksilassila.litematica.printer.SchematicBlockState; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import org.jetbrains.annotations.NotNull; diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/GeneralPlacementGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/GeneralPlacementGuide.java similarity index 94% rename from v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/GeneralPlacementGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/placement/GeneralPlacementGuide.java index 1fb2e2677..26ac31e0e 100644 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/GeneralPlacementGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/GeneralPlacementGuide.java @@ -1,7 +1,7 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.placement; +package me.aleksilassila.litematica.printer.guides.placement; -import me.aleksilassila.litematica.printer.v1_20.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; +import me.aleksilassila.litematica.printer.implementation.PrinterPlacementContext; +import me.aleksilassila.litematica.printer.SchematicBlockState; import net.minecraft.block.SlabBlock; import net.minecraft.block.enums.SlabType; import net.minecraft.client.network.ClientPlayerEntity; diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/GuesserGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/GuesserGuide.java similarity index 93% rename from v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/GuesserGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/placement/GuesserGuide.java index 6a7b9d03d..3b82c3299 100644 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/GuesserGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/GuesserGuide.java @@ -1,8 +1,8 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.placement; +package me.aleksilassila.litematica.printer.guides.placement; -import me.aleksilassila.litematica.printer.v1_20.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_20.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; +import me.aleksilassila.litematica.printer.LitematicaMixinMod; +import me.aleksilassila.litematica.printer.implementation.PrinterPlacementContext; +import me.aleksilassila.litematica.printer.SchematicBlockState; import net.minecraft.block.BlockState; import net.minecraft.block.ChestBlock; import net.minecraft.block.SlabBlock; diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/LogGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/LogGuide.java similarity index 83% rename from v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/LogGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/placement/LogGuide.java index 2fef25af1..7607bbc09 100644 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/LogGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/LogGuide.java @@ -1,8 +1,8 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.placement; +package me.aleksilassila.litematica.printer.guides.placement; -import me.aleksilassila.litematica.printer.v1_19.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19.guides.interaction.LogStrippingGuide; +import me.aleksilassila.litematica.printer.LitematicaMixinMod; +import me.aleksilassila.litematica.printer.SchematicBlockState; +import me.aleksilassila.litematica.printer.guides.interaction.LogStrippingGuide; import net.minecraft.block.Block; import net.minecraft.block.PillarBlock; import net.minecraft.client.network.ClientPlayerEntity; diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/PlacementGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/PlacementGuide.java similarity index 87% rename from v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/PlacementGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/placement/PlacementGuide.java index 2a9133dad..0d94fceca 100644 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/PlacementGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/PlacementGuide.java @@ -1,13 +1,13 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_20.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_20.actions.Action; -import me.aleksilassila.litematica.printer.v1_20.actions.PrepareAction; -import me.aleksilassila.litematica.printer.v1_20.actions.ReleaseShiftAction; -import me.aleksilassila.litematica.printer.v1_20.guides.Guide; -import me.aleksilassila.litematica.printer.v1_20.implementation.actions.InteractActionImpl; +package me.aleksilassila.litematica.printer.guides.placement; + +import me.aleksilassila.litematica.printer.LitematicaMixinMod; +import me.aleksilassila.litematica.printer.implementation.PrinterPlacementContext; +import me.aleksilassila.litematica.printer.SchematicBlockState; +import me.aleksilassila.litematica.printer.actions.Action; +import me.aleksilassila.litematica.printer.actions.PrepareAction; +import me.aleksilassila.litematica.printer.actions.ReleaseShiftAction; +import me.aleksilassila.litematica.printer.guides.Guide; +import me.aleksilassila.litematica.printer.implementation.actions.InteractActionImpl; import net.minecraft.block.*; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.item.BlockItem; diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/PropertySpecificGuesserGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/PropertySpecificGuesserGuide.java similarity index 92% rename from v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/PropertySpecificGuesserGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/placement/PropertySpecificGuesserGuide.java index cf3166dbc..e1ec61eb7 100644 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/PropertySpecificGuesserGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/PropertySpecificGuesserGuide.java @@ -1,6 +1,6 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.placement; +package me.aleksilassila.litematica.printer.guides.placement; -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; +import me.aleksilassila.litematica.printer.SchematicBlockState; import net.minecraft.block.*; import net.minecraft.state.property.Properties; import net.minecraft.state.property.Property; diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/RailGuesserGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/RailGuesserGuide.java similarity index 97% rename from v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/RailGuesserGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/placement/RailGuesserGuide.java index 4b8dba3d3..3df297065 100644 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/RailGuesserGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/RailGuesserGuide.java @@ -1,6 +1,6 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.placement; +package me.aleksilassila.litematica.printer.guides.placement; -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; +import me.aleksilassila.litematica.printer.SchematicBlockState; import net.minecraft.block.BlockState; import net.minecraft.block.enums.RailShape; import net.minecraft.state.property.Properties; diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/RotatingBlockGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/RotatingBlockGuide.java similarity index 83% rename from v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/RotatingBlockGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/placement/RotatingBlockGuide.java index 615d57529..cd5a1ccff 100644 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/RotatingBlockGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/RotatingBlockGuide.java @@ -1,9 +1,9 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.placement; +package me.aleksilassila.litematica.printer.guides.placement; -import me.aleksilassila.litematica.printer.v1_19.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19.actions.Action; -import me.aleksilassila.litematica.printer.v1_19.actions.PrepareAction; +import me.aleksilassila.litematica.printer.implementation.PrinterPlacementContext; +import me.aleksilassila.litematica.printer.SchematicBlockState; +import me.aleksilassila.litematica.printer.actions.Action; +import me.aleksilassila.litematica.printer.actions.PrepareAction; import net.minecraft.block.*; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.state.property.Properties; diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/SlabGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/SlabGuide.java similarity index 92% rename from v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/SlabGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/placement/SlabGuide.java index f3b7e4640..ff9a03f68 100644 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/SlabGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/SlabGuide.java @@ -1,6 +1,6 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.placement; +package me.aleksilassila.litematica.printer.guides.placement; -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; +import me.aleksilassila.litematica.printer.SchematicBlockState; import net.minecraft.block.BlockState; import net.minecraft.block.SlabBlock; import net.minecraft.block.enums.SlabType; diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/TorchGuide.java b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/TorchGuide.java similarity index 86% rename from v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/TorchGuide.java rename to src/main/java/me/aleksilassila/litematica/printer/guides/placement/TorchGuide.java index 1550b6b01..aebb90a69 100644 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/TorchGuide.java +++ b/src/main/java/me/aleksilassila/litematica/printer/guides/placement/TorchGuide.java @@ -1,6 +1,6 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.placement; +package me.aleksilassila.litematica.printer.guides.placement; -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; +import me.aleksilassila.litematica.printer.SchematicBlockState; import net.minecraft.block.Block; import net.minecraft.block.HorizontalFacingBlock; import net.minecraft.client.network.ClientPlayerEntity; diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/implementation/BlockHelperImpl.java b/src/main/java/me/aleksilassila/litematica/printer/implementation/BlockHelperImpl.java similarity index 64% rename from v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/implementation/BlockHelperImpl.java rename to src/main/java/me/aleksilassila/litematica/printer/implementation/BlockHelperImpl.java index 8b8c83a56..3ce987171 100644 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/implementation/BlockHelperImpl.java +++ b/src/main/java/me/aleksilassila/litematica/printer/implementation/BlockHelperImpl.java @@ -1,6 +1,6 @@ -package me.aleksilassila.litematica.printer.v1_20.implementation; +package me.aleksilassila.litematica.printer.implementation; -import me.aleksilassila.litematica.printer.v1_20.BlockHelper; +import me.aleksilassila.litematica.printer.BlockHelper; import net.minecraft.block.ButtonBlock; import java.util.Arrays; diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/implementation/PrinterPlacementContext.java b/src/main/java/me/aleksilassila/litematica/printer/implementation/PrinterPlacementContext.java similarity index 97% rename from v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/implementation/PrinterPlacementContext.java rename to src/main/java/me/aleksilassila/litematica/printer/implementation/PrinterPlacementContext.java index 26fcd96fa..7198b8749 100644 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/implementation/PrinterPlacementContext.java +++ b/src/main/java/me/aleksilassila/litematica/printer/implementation/PrinterPlacementContext.java @@ -1,4 +1,4 @@ -package me.aleksilassila.litematica.printer.v1_20.implementation; +package me.aleksilassila.litematica.printer.implementation; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemPlacementContext; diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/implementation/actions/InteractActionImpl.java b/src/main/java/me/aleksilassila/litematica/printer/implementation/actions/InteractActionImpl.java similarity index 72% rename from v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/implementation/actions/InteractActionImpl.java rename to src/main/java/me/aleksilassila/litematica/printer/implementation/actions/InteractActionImpl.java index 187c7b533..b32e155c1 100644 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/implementation/actions/InteractActionImpl.java +++ b/src/main/java/me/aleksilassila/litematica/printer/implementation/actions/InteractActionImpl.java @@ -1,7 +1,7 @@ -package me.aleksilassila.litematica.printer.v1_19.implementation.actions; +package me.aleksilassila.litematica.printer.implementation.actions; -import me.aleksilassila.litematica.printer.v1_19.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_19.actions.InteractAction; +import me.aleksilassila.litematica.printer.implementation.PrinterPlacementContext; +import me.aleksilassila.litematica.printer.actions.InteractAction; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.util.Hand; diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/implementation/mixin/MixinClientPlayerEntity.java b/src/main/java/me/aleksilassila/litematica/printer/implementation/mixin/MixinClientPlayerEntity.java similarity index 92% rename from v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/implementation/mixin/MixinClientPlayerEntity.java rename to src/main/java/me/aleksilassila/litematica/printer/implementation/mixin/MixinClientPlayerEntity.java index 90d02a848..d72e82001 100644 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/implementation/mixin/MixinClientPlayerEntity.java +++ b/src/main/java/me/aleksilassila/litematica/printer/implementation/mixin/MixinClientPlayerEntity.java @@ -1,12 +1,12 @@ -package me.aleksilassila.litematica.printer.v1_20.implementation.mixin; +package me.aleksilassila.litematica.printer.implementation.mixin; import com.mojang.authlib.GameProfile; import fi.dy.masa.litematica.world.SchematicWorldHandler; import fi.dy.masa.litematica.world.WorldSchematic; -import me.aleksilassila.litematica.printer.v1_20.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_20.Printer; -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_20.UpdateChecker; +import me.aleksilassila.litematica.printer.LitematicaMixinMod; +import me.aleksilassila.litematica.printer.Printer; +import me.aleksilassila.litematica.printer.SchematicBlockState; +import me.aleksilassila.litematica.printer.UpdateChecker; import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.SignBlockEntity; import net.minecraft.client.MinecraftClient; diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/mixin/AxeItemAccessor.java b/src/main/java/me/aleksilassila/litematica/printer/mixin/AxeItemAccessor.java similarity index 88% rename from v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/mixin/AxeItemAccessor.java rename to src/main/java/me/aleksilassila/litematica/printer/mixin/AxeItemAccessor.java index 45f94767f..2f3f20c28 100644 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/mixin/AxeItemAccessor.java +++ b/src/main/java/me/aleksilassila/litematica/printer/mixin/AxeItemAccessor.java @@ -1,4 +1,4 @@ -package me.aleksilassila.litematica.printer.v1_19.mixin; +package me.aleksilassila.litematica.printer.mixin; import net.minecraft.block.Block; import net.minecraft.item.AxeItem; diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/mixin/ConfigsMixin.java b/src/main/java/me/aleksilassila/litematica/printer/mixin/ConfigsMixin.java similarity index 92% rename from v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/mixin/ConfigsMixin.java rename to src/main/java/me/aleksilassila/litematica/printer/mixin/ConfigsMixin.java index d61440a68..1e838df59 100644 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/mixin/ConfigsMixin.java +++ b/src/main/java/me/aleksilassila/litematica/printer/mixin/ConfigsMixin.java @@ -1,10 +1,10 @@ -package me.aleksilassila.litematica.printer.v1_19.mixin; +package me.aleksilassila.litematica.printer.mixin; import com.google.common.collect.ImmutableList; import fi.dy.masa.litematica.config.Configs; import fi.dy.masa.malilib.config.IConfigBase; import fi.dy.masa.malilib.config.options.ConfigHotkey; -import me.aleksilassila.litematica.printer.v1_19.LitematicaMixinMod; +import me.aleksilassila.litematica.printer.LitematicaMixinMod; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/mixin/GuiConfigsMixin.java b/src/main/java/me/aleksilassila/litematica/printer/mixin/GuiConfigsMixin.java similarity index 93% rename from v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/mixin/GuiConfigsMixin.java rename to src/main/java/me/aleksilassila/litematica/printer/mixin/GuiConfigsMixin.java index 3c457504c..23cbeed72 100644 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/mixin/GuiConfigsMixin.java +++ b/src/main/java/me/aleksilassila/litematica/printer/mixin/GuiConfigsMixin.java @@ -1,10 +1,10 @@ -package me.aleksilassila.litematica.printer.v1_19.mixin; +package me.aleksilassila.litematica.printer.mixin; import com.google.common.collect.ImmutableList; import fi.dy.masa.litematica.gui.GuiConfigs; import fi.dy.masa.malilib.config.IConfigBase; import fi.dy.masa.malilib.config.options.ConfigHotkey; -import me.aleksilassila.litematica.printer.v1_19.LitematicaMixinMod; +import me.aleksilassila.litematica.printer.LitematicaMixinMod; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/mixin/InputHandlerMixin.java b/src/main/java/me/aleksilassila/litematica/printer/mixin/InputHandlerMixin.java similarity index 87% rename from v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/mixin/InputHandlerMixin.java rename to src/main/java/me/aleksilassila/litematica/printer/mixin/InputHandlerMixin.java index 476188e22..d50cd9e07 100644 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/mixin/InputHandlerMixin.java +++ b/src/main/java/me/aleksilassila/litematica/printer/mixin/InputHandlerMixin.java @@ -1,8 +1,8 @@ -package me.aleksilassila.litematica.printer.v1_18.mixin; +package me.aleksilassila.litematica.printer.mixin; import fi.dy.masa.litematica.event.InputHandler; import fi.dy.masa.malilib.config.options.ConfigHotkey; -import me.aleksilassila.litematica.printer.v1_18.LitematicaMixinMod; +import me.aleksilassila.litematica.printer.LitematicaMixinMod; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/mixin/PlayerMoveC2SPacketMixin.java b/src/main/java/me/aleksilassila/litematica/printer/mixin/PlayerMoveC2SPacketMixin.java similarity index 83% rename from v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/mixin/PlayerMoveC2SPacketMixin.java rename to src/main/java/me/aleksilassila/litematica/printer/mixin/PlayerMoveC2SPacketMixin.java index a9a17a12f..7ffc3725d 100644 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/mixin/PlayerMoveC2SPacketMixin.java +++ b/src/main/java/me/aleksilassila/litematica/printer/mixin/PlayerMoveC2SPacketMixin.java @@ -1,8 +1,8 @@ -package me.aleksilassila.litematica.printer.v1_17.mixin; +package me.aleksilassila.litematica.printer.mixin; -import me.aleksilassila.litematica.printer.v1_17.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_17.Printer; -import me.aleksilassila.litematica.printer.v1_17.actions.PrepareAction; +import me.aleksilassila.litematica.printer.LitematicaMixinMod; +import me.aleksilassila.litematica.printer.Printer; +import me.aleksilassila.litematica.printer.actions.PrepareAction; import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; diff --git a/v1_17/src/main/resources/assets/modid/icon.png b/src/main/resources/assets/modid/icon.png similarity index 100% rename from v1_17/src/main/resources/assets/modid/icon.png rename to src/main/resources/assets/modid/icon.png diff --git a/v1_20/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json similarity index 89% rename from v1_20/src/main/resources/fabric.mod.json rename to src/main/resources/fabric.mod.json index f9ba8bf68..e957f1102 100644 --- a/v1_20/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -16,7 +16,7 @@ "environment": "*", "entrypoints": { "main": [ - "me.aleksilassila.litematica.printer.v1_20.LitematicaMixinMod" + "me.aleksilassila.litematica.printer.LitematicaMixinMod" ] }, "mixins": [ @@ -26,7 +26,7 @@ "depends": { "fabricloader": ">=0.14.7", "fabric": "*", - "minecraft": "1.20.1", + "minecraft": ">=1.20.1", "java": ">=17" }, "custom": { diff --git a/v1_18/src/main/resources/litematica-printer-implementation.mixins.json b/src/main/resources/litematica-printer-implementation.mixins.json similarity index 71% rename from v1_18/src/main/resources/litematica-printer-implementation.mixins.json rename to src/main/resources/litematica-printer-implementation.mixins.json index 3c868f579..281263662 100644 --- a/v1_18/src/main/resources/litematica-printer-implementation.mixins.json +++ b/src/main/resources/litematica-printer-implementation.mixins.json @@ -1,7 +1,7 @@ { "required": true, "minVersion": "0.8", - "package": "me.aleksilassila.litematica.printer.v1_18.implementation.mixin", + "package": "me.aleksilassila.litematica.printer.implementation.mixin", "compatibilityLevel": "JAVA_16", "mixins": [ ], diff --git a/v1_19/src/main/resources/litematica-printer.mixins.json b/src/main/resources/litematica-printer.mixins.json similarity index 81% rename from v1_19/src/main/resources/litematica-printer.mixins.json rename to src/main/resources/litematica-printer.mixins.json index 6a14babbd..196b235f9 100644 --- a/v1_19/src/main/resources/litematica-printer.mixins.json +++ b/src/main/resources/litematica-printer.mixins.json @@ -1,7 +1,7 @@ { "required": true, "minVersion": "0.8", - "package": "me.aleksilassila.litematica.printer.v1_19.mixin", + "package": "me.aleksilassila.litematica.printer.mixin", "compatibilityLevel": "JAVA_16", "mixins": [ ], diff --git a/v1_17/build.gradle.kts b/v1_17/build.gradle.kts deleted file mode 100644 index bac7d6314..000000000 --- a/v1_17/build.gradle.kts +++ /dev/null @@ -1,88 +0,0 @@ -plugins { - id("fabric-loom").version("1.0-SNAPSHOT") - id("maven-publish") -} - -java.sourceCompatibility = JavaVersion.VERSION_16 -java.targetCompatibility = JavaVersion.VERSION_16 - -val archives_base_name: String by project -val minecraft_version: String by project -val yarn_mappings: String by project -val loader_version: String by project -val fabric_version: String by project -val malilib_version: String by project -val litematica_projectid: String by project -val litematica_fileid: String by project - -val mod_version: String by project - -dependencies { -// implementation(project(":common")) - minecraft("com.mojang:minecraft:${minecraft_version}") - mappings("net.fabricmc:yarn:${yarn_mappings}:v2") - - modImplementation("net.fabricmc:fabric-loader:${loader_version}") - modImplementation("net.fabricmc.fabric-api:fabric-api:${fabric_version}") - modImplementation("fi.dy.masa.malilib:malilib-fabric-${minecraft_version}:${malilib_version}") - modImplementation("curse.maven:litematica-${litematica_projectid}:${litematica_fileid}") -} - -repositories { - maven("https://masa.dy.fi/maven") - maven("https://www.cursemaven.com") -} - -// Process resources -tasks.withType { - inputs.property("version", mod_version) - - filesMatching("fabric.mod.json") { - expand(mapOf("version" to mod_version)) - } -} - -val sourceModule = "v1_17" -val targetModules = arrayOf("v1_18", "v1_19", "v1_19_3", "v1_19_4",) - -fun copyFile(source: File) { - for (targetModule in targetModules) { - val destination = file(source.absolutePath.replace(sourceModule, targetModule)) - println("Copying ${source.absolutePath} to ${destination.absolutePath}") - destination.parentFile.mkdirs() - source.copyTo(destination, true) - destination.writeText(destination.readText().replace(sourceModule, targetModule)) - } -} - -fun deleteOldFiles(sourceBase: File) { - for (targetModule in targetModules) { - val targetBase = file(sourceBase.absolutePath.replace(sourceModule, targetModule)) - - for (file in targetBase.listFiles()) { - if (file.name.equals("implementation")) continue - println("Deleting recursively ${file.absolutePath}") - file.deleteRecursively() - } - } -} - -val syncImplementations = tasks.create("syncImplementations") { - doFirst { - val sourceStart = - this.project.projectDir.absolutePath + "/src/main/java/me/aleksilassila/litematica/printer/" + sourceModule - val sourceDir = file(sourceStart) - - deleteOldFiles(sourceDir) - - for (sourceFile in sourceDir.listFiles()) { - if (sourceFile.name.equals("implementation")) continue - - sourceFile.walk() - .filter { it.isFile } - .forEach { - copyFile(it) - } - } - } -} diff --git a/v1_17/gradle.properties b/v1_17/gradle.properties deleted file mode 100644 index e7f4e3d76..000000000 --- a/v1_17/gradle.properties +++ /dev/null @@ -1,15 +0,0 @@ -# Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx1G - -# Fabric Properties - # check these on https://fabricmc.net/use - minecraft_version=1.17.1 - yarn_mappings=1.17.1+build.65 - loader_version=0.14.10 - - malilib_version = 0.10.0-dev.23 - litematica_fileid=3379278 - litematica_projectid=308892 - -# Dependencies - fabric_version=0.46.1+1.17 diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/ActionHandler.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/ActionHandler.java deleted file mode 100644 index 246028218..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/ActionHandler.java +++ /dev/null @@ -1,57 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17; - -import me.aleksilassila.litematica.printer.v1_17.actions.Action; -import me.aleksilassila.litematica.printer.v1_17.actions.PrepareAction; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; - -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; - -public class ActionHandler { - private final MinecraftClient client; - private final ClientPlayerEntity player; - - private final Queue actionQueue = new LinkedList<>(); - public PrepareAction lookAction = null; - - public ActionHandler(MinecraftClient client, ClientPlayerEntity player) { - this.client = client; - this.player = player; - } - - private int tick = 0; - - public void onGameTick() { - int tickRate = LitematicaMixinMod.PRINTING_INTERVAL.getIntegerValue(); - - tick = tick % tickRate == tickRate - 1 ? 0 : tick + 1; - if (tick % tickRate != 0) { - return; - } - - Action nextAction = actionQueue.poll(); - if (nextAction != null) { - if (LitematicaMixinMod.DEBUG) System.out.println("Sending action " + nextAction); - nextAction.send(client, player); - } else { - lookAction = null; - } - } - - public boolean acceptsActions() { - return actionQueue.isEmpty(); - } - - public void addActions(Action... actions) { - if (!acceptsActions()) return; - - for (Action action : actions) { - if (action instanceof PrepareAction) - lookAction = (PrepareAction) action; - } - - actionQueue.addAll(List.of(actions)); - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/BlockHelper.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/BlockHelper.java deleted file mode 100644 index 3a28caaf9..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/BlockHelper.java +++ /dev/null @@ -1,31 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17; - -import net.minecraft.block.*; -import net.minecraft.item.Item; -import net.minecraft.item.Items; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -abstract public class BlockHelper { - public static List> interactiveBlocks = new ArrayList<>(Arrays.asList( - AbstractChestBlock.class, AbstractFurnaceBlock.class, CraftingTableBlock.class, LeverBlock.class, - DoorBlock.class, TrapdoorBlock.class, BedBlock.class, RedstoneWireBlock.class, ScaffoldingBlock.class, - HopperBlock.class, EnchantingTableBlock.class, NoteBlock.class, JukeboxBlock.class, CakeBlock.class, - FenceGateBlock.class, BrewingStandBlock.class, DragonEggBlock.class, CommandBlock.class, - BeaconBlock.class, AnvilBlock.class, ComparatorBlock.class, RepeaterBlock.class, - DropperBlock.class, DispenserBlock.class, ShulkerBoxBlock.class, LecternBlock.class, - FlowerPotBlock.class, BarrelBlock.class, BellBlock.class, SmithingTableBlock.class, - LoomBlock.class, CartographyTableBlock.class, GrindstoneBlock.class, - StonecutterBlock.class, AbstractSignBlock.class, AbstractCandleBlock.class)); - - public static final Item[] SHOVEL_ITEMS = new Item[]{ - Items.NETHERITE_SHOVEL, - Items.DIAMOND_SHOVEL, - Items.GOLDEN_SHOVEL, - Items.IRON_SHOVEL, - Items.STONE_SHOVEL, - Items.WOODEN_SHOVEL - }; -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/LitematicaMixinMod.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/LitematicaMixinMod.java deleted file mode 100644 index 5f48b9a4e..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/LitematicaMixinMod.java +++ /dev/null @@ -1,58 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17; - -import com.google.common.collect.ImmutableList; -import fi.dy.masa.litematica.config.Configs; -import fi.dy.masa.litematica.config.Hotkeys; -import fi.dy.masa.malilib.config.IConfigBase; -import fi.dy.masa.malilib.config.options.ConfigBoolean; -import fi.dy.masa.malilib.config.options.ConfigDouble; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import fi.dy.masa.malilib.config.options.ConfigInteger; -import fi.dy.masa.malilib.hotkeys.KeyCallbackToggleBooleanConfigWithMessage; -import fi.dy.masa.malilib.hotkeys.KeybindSettings; -import net.fabricmc.api.ModInitializer; - -import java.util.List; - -public class LitematicaMixinMod implements ModInitializer { - - public static Printer printer; - public static boolean DEBUG = false; - // Config settings - public static final ConfigInteger PRINTING_INTERVAL = new ConfigInteger("printingInterval", 12, 1, 40, "Printing interval. Lower values mean faster printing speed.\nIf the printer creates \"ghost blocks\" or blocks are facing the wrong way, raise this value."); - public static final ConfigDouble PRINTING_RANGE = new ConfigDouble("printingRange", 5, 2.5, 5, "Printing block place range\nLower values are recommended for servers."); - // public static final ConfigBoolean PRINT_WATER = new ConfigBoolean("printWater", false, "Whether the printer should place water\n source blocks or make blocks waterlogged."); -// public static final ConfigBoolean PRINT_IN_AIR = new ConfigBoolean("printInAir", true, "Whether or not the printer should place blocks without anything to build on.\nBe aware that some anti-cheat plugins might notice this."); - public static final ConfigBoolean PRINT_MODE = new ConfigBoolean("printingMode", false, "Autobuild / print loaded selection.\nBe aware that some servers and anticheat plugins do not allow printing."); - public static final ConfigBoolean REPLACE_FLUIDS_SOURCE_BLOCKS = new ConfigBoolean("replaceFluidSourceBlocks", true, "Whether or not fluid source blocks should be replaced by the printer."); - public static final ConfigBoolean STRIP_LOGS = new ConfigBoolean("stripLogs", true, "Whether or not the printer should use normal logs if stripped\nversions are not available and then strip them with an axe."); - - public static ImmutableList getConfigList() { - List list = new java.util.ArrayList<>(Configs.Generic.OPTIONS); - list.add(PRINT_MODE); - list.add(PRINTING_INTERVAL); - list.add(PRINTING_RANGE); -// list.add(PRINT_IN_AIR); - list.add(REPLACE_FLUIDS_SOURCE_BLOCKS); - list.add(STRIP_LOGS); - - return ImmutableList.copyOf(list); - } - - // Hotkeys - public static final ConfigHotkey PRINT = new ConfigHotkey("print", "V", KeybindSettings.PRESS_ALLOWEXTRA_EMPTY, "Prints while pressed"); - public static final ConfigHotkey TOGGLE_PRINTING_MODE = new ConfigHotkey("togglePrintingMode", "CAPS_LOCK", KeybindSettings.PRESS_ALLOWEXTRA_EMPTY, "Allows quickly toggling on/off Printing mode"); - - public static List getHotkeyList() { - List list = new java.util.ArrayList<>(Hotkeys.HOTKEY_LIST); - list.add(PRINT); - list.add(TOGGLE_PRINTING_MODE); - - return ImmutableList.copyOf(list); - } - - @Override - public void onInitialize() { - TOGGLE_PRINTING_MODE.getKeybind().setCallback(new KeyCallbackToggleBooleanConfigWithMessage(PRINT_MODE)); - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/Printer.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/Printer.java deleted file mode 100644 index ff44b95c7..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/Printer.java +++ /dev/null @@ -1,110 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17; - -import fi.dy.masa.litematica.data.DataManager; -import fi.dy.masa.litematica.util.RayTraceUtils; -import fi.dy.masa.litematica.world.SchematicWorldHandler; -import fi.dy.masa.litematica.world.WorldSchematic; -import me.aleksilassila.litematica.printer.v1_17.actions.Action; -import me.aleksilassila.litematica.printer.v1_17.guides.Guide; -import me.aleksilassila.litematica.printer.v1_17.guides.Guides; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerAbilities; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.RaycastContext; -import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -public class Printer { - @NotNull - public final ClientPlayerEntity player; - - public final ActionHandler actionHandler; - - private final Guides interactionGuides = new Guides(); - - public Printer(@NotNull MinecraftClient client, @NotNull ClientPlayerEntity player) { - this.player = player; - - this.actionHandler = new ActionHandler(client, player); - } - - public boolean onGameTick() { - WorldSchematic worldSchematic = SchematicWorldHandler.getSchematicWorld(); - - if (!actionHandler.acceptsActions()) return false; - - if (worldSchematic == null) return false; - - if (!LitematicaMixinMod.PRINT_MODE.getBooleanValue() && !LitematicaMixinMod.PRINT.getKeybind().isPressed()) - return false; - - PlayerAbilities abilities = player.getAbilities(); - if (!abilities.allowModifyWorld) - return false; - - List positions = getReachablePositions(); - findBlock: - for (BlockPos position : positions) { - SchematicBlockState state = new SchematicBlockState(player.world, worldSchematic, position); - if (state.targetState.equals(state.currentState) || state.targetState.isAir()) continue; - - Guide[] guides = interactionGuides.getInteractionGuides(state); - - BlockHitResult result = RayTraceUtils.traceToSchematicWorld(player, 10, true, true); - boolean isCurrentlyLookingSchematic = result != null && result.getBlockPos().equals(position); - - for (Guide guide : guides) { - if (guide.canExecute(player)) { - System.out.println("Executing " + guide + " for " + state); - List actions = guide.execute(player); - actionHandler.addActions(actions.toArray(Action[]::new)); - return true; - } - if (guide.skipOtherGuides()) continue findBlock; - } - } - - return false; - } - - private List getReachablePositions() { - int maxReach = (int) Math.ceil(LitematicaMixinMod.PRINTING_RANGE.getDoubleValue()); - double maxReachSquared = MathHelper.square(LitematicaMixinMod.PRINTING_RANGE.getDoubleValue()); - - ArrayList positions = new ArrayList<>(); - - for (int y = -maxReach; y < maxReach + 1; y++) { - for (int x = -maxReach; x < maxReach + 1; x++) { - for (int z = -maxReach; z < maxReach + 1; z++) { - BlockPos blockPos = player.getBlockPos().north(x).west(z).up(y); - - if (!DataManager.getRenderLayerRange().isPositionWithinRange(blockPos)) continue; - if (this.player.getEyePos().squaredDistanceTo(Vec3d.ofCenter(blockPos)) > maxReachSquared) { - continue; - } - - positions.add(blockPos); - } - } - } - - return positions.stream() - .filter(p -> { - Vec3d vec = Vec3d.ofCenter(p); - return this.player.getPos().squaredDistanceTo(vec) > 1 && this.player.getEyePos().squaredDistanceTo(vec) > 1; - }) - .sorted((a, b) -> { - double aDistance = this.player.getPos().squaredDistanceTo(Vec3d.ofCenter(a)); - double bDistance = this.player.getPos().squaredDistanceTo(Vec3d.ofCenter(b)); - return Double.compare(aDistance, bDistance); - }).toList(); - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/UpdateChecker.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/UpdateChecker.java deleted file mode 100644 index ccce81bcb..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/UpdateChecker.java +++ /dev/null @@ -1,49 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import org.apache.commons.io.IOUtils; - -import java.io.BufferedReader; -import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.util.Scanner; - -public class UpdateChecker { - public static final String version = "v3.2"; - - // Try to get this to work at some point -// static { -// try (InputStream in = UpdateChecker.class.getResourceAsStream("/fabric.mod.json")) { -// String jsonString = IOUtils.toString(in, StandardCharsets.UTF_8); -// JsonObject json = JsonParser.parseString(jsonString).getAsJsonObject(); -// System.out.println("JSON object: " + json); -// System.out.println("Raw json: " + jsonString); -// System.out.println("File: " + new File(UpdateChecker.class.getResource("/fabric.mod.json").getFile())); -// String version = json.get("version").getAsString(); -// System.out.println("Reading fabric.mod.json"); -// System.out.println("Parsed version: " + version); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } - - @SuppressWarnings("deprecation") - public static String getPrinterVersion() { - try (InputStream inputStream = new URL("https://api.github.com/repos/aleksilassila/litematica-printer/tags").openStream(); Scanner scanner = new Scanner(inputStream)) { - if (scanner.hasNext()) { - JsonArray tags = new JsonParser().parse(scanner.next()).getAsJsonArray(); - return ((JsonObject) tags.get(0)).get("name").getAsString(); - } - } catch (Exception exception) { - System.out.println("Cannot look for updates: " + exception.getMessage()); - } - - return ""; - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/actions/InteractAction.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/actions/InteractAction.java deleted file mode 100644 index 6edc99015..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/actions/InteractAction.java +++ /dev/null @@ -1,33 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.actions; - -import me.aleksilassila.litematica.printer.v1_17.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_17.implementation.PrinterPlacementContext; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; - -abstract public class InteractAction extends Action { - public final PrinterPlacementContext context; - - public InteractAction(PrinterPlacementContext context) { - this.context = context; - } - - protected abstract void interact(MinecraftClient client, ClientPlayerEntity player, Hand hand, BlockHitResult hitResult); - - @Override - public void send(MinecraftClient client, ClientPlayerEntity player) { - interact(client, player, Hand.MAIN_HAND, context.hitResult); - - if (LitematicaMixinMod.DEBUG) - System.out.println("InteractAction.send: Blockpos: " + context.getBlockPos() + " Side: " + context.getSide() + " HitPos: " + context.getHitPos()); - } - - @Override - public String toString() { - return "InteractAction{" + - "context=" + context + - '}'; - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/actions/PrepareAction.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/actions/PrepareAction.java deleted file mode 100644 index cf4d8bd22..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/actions/PrepareAction.java +++ /dev/null @@ -1,109 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.actions; - -import me.aleksilassila.litematica.printer.v1_17.implementation.PrinterPlacementContext; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; -import net.minecraft.util.Hand; -import net.minecraft.util.math.Direction; - -public class PrepareAction extends Action { -// public final Direction lookDirection; -// public final boolean requireSneaking; -// public final Item item; - -// public PrepareAction(Direction lookDirection, boolean requireSneaking, Item item) { -// this.lookDirection = lookDirection; -// this.requireSneaking = requireSneaking; -// this.item = item; -// } -// -// public PrepareAction(Direction lookDirection, boolean requireSneaking, BlockState requiredState) { -// this(lookDirection, requireSneaking, requiredState.getBlock().asItem()); -// } - - public final PrinterPlacementContext context; - - public boolean modifyYaw = true; - public boolean modifyPitch = true; - public float yaw = 0; - public float pitch = 0; - - public PrepareAction(PrinterPlacementContext context) { - this.context = context; - - Direction lookDirection = context.lookDirection; - - if (lookDirection != null && lookDirection.getAxis().isHorizontal()) { - this.yaw = lookDirection.asRotation(); - } else { - this.modifyYaw = false; - } - - if (lookDirection == Direction.UP) { - this.pitch = -90; - } else if (lookDirection == Direction.DOWN) { - this.pitch = 90; - } else if (lookDirection != null) { - this.pitch = 0; - } else { - this.modifyPitch = false; - } - } - - public PrepareAction(PrinterPlacementContext context, float yaw, float pitch) { - this.context = context; - - this.yaw = yaw; - this.pitch = pitch; - } - - @Override - public void send(MinecraftClient client, ClientPlayerEntity player) { - ItemStack itemStack = context.getStack(); - int slot = context.requiredItemSlot; - - if (itemStack != null) { - PlayerInventory inventory = player.getInventory(); - - // This thing is straight from MinecraftClient#doItemPick() - if (player.getAbilities().creativeMode) { - inventory.addPickBlock(itemStack); - client.interactionManager.clickCreativeStack(player.getStackInHand(Hand.MAIN_HAND), 36 + inventory.selectedSlot); - } else if (slot != -1) { - if (PlayerInventory.isValidHotbarIndex(slot)) { - inventory.selectedSlot = slot; - } else { - client.interactionManager.pickFromInventory(slot); - } - } - } - - if (modifyPitch || modifyYaw) { - float yaw = modifyYaw ? this.yaw : player.getYaw(); - float pitch = modifyPitch ? this.pitch : player.getPitch(); - - PlayerMoveC2SPacket packet = new PlayerMoveC2SPacket.Full(player.getX(), player.getY(), player.getZ(), yaw, pitch, player.isOnGround()); - - player.networkHandler.sendPacket(packet); - } - - if (context.shouldSneak) { - player.input.sneaking = true; - player.networkHandler.sendPacket(new ClientCommandC2SPacket(player, ClientCommandC2SPacket.Mode.PRESS_SHIFT_KEY)); - } else { - player.input.sneaking = false; - player.networkHandler.sendPacket(new ClientCommandC2SPacket(player, ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY)); - } - } - - @Override - public String toString() { - return "PrepareAction{" + - "context=" + context + - '}'; - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/actions/ReleaseShiftAction.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/actions/ReleaseShiftAction.java deleted file mode 100644 index c45bbb178..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/actions/ReleaseShiftAction.java +++ /dev/null @@ -1,13 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.actions; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; - -public class ReleaseShiftAction extends Action { - @Override - public void send(MinecraftClient client, ClientPlayerEntity player) { - player.input.sneaking = false; - player.networkHandler.sendPacket(new ClientCommandC2SPacket(player, ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY)); - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/Guide.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/Guide.java deleted file mode 100644 index 0dc9d011b..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/Guide.java +++ /dev/null @@ -1,130 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.guides; - -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_17.actions.Action; -import me.aleksilassila.litematica.printer.v1_17.implementation.BlockHelperImpl; -import net.minecraft.block.BlockState; -import net.minecraft.block.CoralBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.state.property.Properties; -import net.minecraft.state.property.Property; -import org.jetbrains.annotations.NotNull; - -import java.util.List; -import java.util.Optional; - -abstract public class Guide extends BlockHelperImpl { - protected final SchematicBlockState state; - protected final BlockState currentState; - protected final BlockState targetState; - - public Guide(SchematicBlockState state) { - this.state = state; - - this.currentState = state.currentState; - this.targetState = state.targetState; - } - - protected boolean playerHasRightItem(ClientPlayerEntity player) { - return getRequiredItemStackSlot(player) != -1; - } - - protected int getSlotWithItem(ClientPlayerEntity player, ItemStack itemStack) { - PlayerInventory inventory = player.getInventory(); - - for (int i = 0; i < inventory.main.size(); ++i) { - if (itemStack.isEmpty() && inventory.main.get(i).isOf(itemStack.getItem())) return i; - if (!inventory.main.get(i).isEmpty() && inventory.main.get(i).isItemEqual(itemStack)) { - return i; - } - } - - return -1; - } - - protected int getRequiredItemStackSlot(ClientPlayerEntity player) { - if (player.getAbilities().creativeMode) { - return player.getInventory().selectedSlot; - } - - Optional requiredItem = getRequiredItem(player); - if (requiredItem.isEmpty()) return -1; - - return getSlotWithItem(player, requiredItem.get()); - } - - public boolean canExecute(ClientPlayerEntity player) { - if (!playerHasRightItem(player)) return false; - - BlockState targetState = state.targetState; - BlockState currentState = state.currentState; - - return !statesEqual(targetState, currentState); - } - - abstract public @NotNull List execute(ClientPlayerEntity player); - - abstract protected @NotNull List getRequiredItems(); - - /** - * Returns the first required item that player has access to, - * or empty if the items are inaccessible. - */ - protected Optional getRequiredItem(ClientPlayerEntity player) { - List requiredItems = getRequiredItems(); - - for (ItemStack requiredItem : requiredItems) { - if (player.getAbilities().creativeMode) return Optional.of(requiredItem); - - int slot = getSlotWithItem(player, requiredItem); - if (slot > -1) - return Optional.of(requiredItem); - } - - return Optional.empty(); - } - - protected boolean statesEqualIgnoreProperties(BlockState state1, BlockState state2, Property... propertiesToIgnore) { - if (state1.getBlock() != state2.getBlock()) return false; - - loop: - for (Property property : state1.getProperties()) { - if (property == Properties.WATERLOGGED && !(state1.getBlock() instanceof CoralBlock)) continue; - - for (Property ignoredProperty : propertiesToIgnore) { - if (property == ignoredProperty) continue loop; - } - - try { - if (state1.get(property) != state2.get(property)) { - return false; - } - } catch (Exception e) { - return false; - } - } - - return true; - } - - protected static > Optional getProperty(BlockState blockState, Property property) { - if (blockState.contains(property)) { - return Optional.of(blockState.get(property)); - } - return Optional.empty(); - } - - /** - * Returns true if - */ - protected boolean statesEqual(BlockState state1, BlockState state2) { - return statesEqualIgnoreProperties(state1, state2); - } - - public boolean skipOtherGuides() { - return false; - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/SkipGuide.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/SkipGuide.java deleted file mode 100644 index 3ed79a5c3..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/SkipGuide.java +++ /dev/null @@ -1,37 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.guides; - -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_17.actions.Action; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class SkipGuide extends Guide { - public SkipGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - return false; - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - return new ArrayList<>(); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(ItemStack.EMPTY); - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/CampfireExtinguishGuide.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/CampfireExtinguishGuide.java deleted file mode 100644 index 81346f426..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/CampfireExtinguishGuide.java +++ /dev/null @@ -1,36 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import net.minecraft.block.CampfireBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; - -public class CampfireExtinguishGuide extends InteractionGuide { - boolean shouldBeLit; - boolean isLit; - - public CampfireExtinguishGuide(SchematicBlockState state) { - super(state); - - shouldBeLit = getProperty(targetState, CampfireBlock.LIT).orElse(false); - isLit = getProperty(currentState, CampfireBlock.LIT).orElse(false); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return (currentState.getBlock() instanceof CampfireBlock) && !shouldBeLit && isLit; - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(SHOVEL_ITEMS).map(ItemStack::new).toList(); - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/CycleStateGuide.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/CycleStateGuide.java deleted file mode 100644 index 97b36daf2..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/CycleStateGuide.java +++ /dev/null @@ -1,45 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.LeverBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.state.property.Properties; -import net.minecraft.state.property.Property; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class CycleStateGuide extends InteractionGuide { - private static final Property[] propertiesToIgnore = new Property[]{ - Properties.POWERED, - Properties.LIT - }; - - public CycleStateGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return targetState.getBlock() == currentState.getBlock(); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(ItemStack.EMPTY); - } - - @Override - protected boolean statesEqual(BlockState state1, BlockState state2) { - if (state2.getBlock() instanceof LeverBlock) { - return super.statesEqual(state1, state2); - } - - return statesEqualIgnoreProperties(state1, state2, propertiesToIgnore); - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/EnderEyeGuide.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/EnderEyeGuide.java deleted file mode 100644 index 45b9a8ce8..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/EnderEyeGuide.java +++ /dev/null @@ -1,33 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.state.property.Properties; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class EnderEyeGuide extends InteractionGuide { - public EnderEyeGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - if (currentState.contains(Properties.EYE) && targetState.contains(Properties.EYE)) { - return !currentState.get(Properties.EYE) && targetState.get(Properties.EYE); - } - - return false; - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(new ItemStack(Items.ENDER_EYE)); - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/TillingGuide.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/TillingGuide.java deleted file mode 100644 index 3a559a3bf..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/interaction/TillingGuide.java +++ /dev/null @@ -1,39 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_17.guides.placement.FarmlandGuide; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; - -public class TillingGuide extends InteractionGuide { - public static final Item[] HOE_ITEMS = new Item[]{ - Items.NETHERITE_HOE, - Items.DIAMOND_HOE, - Items.GOLDEN_HOE, - Items.IRON_HOE, - Items.STONE_HOE, - Items.WOODEN_HOE - }; - - public TillingGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return Arrays.stream(FarmlandGuide.TILLABLE_BLOCKS).anyMatch(b -> b == currentState.getBlock()); - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(HOE_ITEMS).map(ItemStack::new).toList(); - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/BlockIndifferentGuesserGuide.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/BlockIndifferentGuesserGuide.java deleted file mode 100644 index 655905229..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/BlockIndifferentGuesserGuide.java +++ /dev/null @@ -1,42 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.placement; - -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import net.minecraft.block.*; - -public class BlockIndifferentGuesserGuide extends GuesserGuide { - public BlockIndifferentGuesserGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected boolean statesEqual(BlockState resultState, BlockState targetState) { - Block targetBlock = targetState.getBlock(); - Block resultBlock = resultState.getBlock(); - - if (targetBlock instanceof BambooBlock) { - return resultBlock instanceof BambooBlock || resultBlock instanceof BambooSaplingBlock; - } - - if (targetBlock instanceof BigDripleafStemBlock) { - if (resultBlock instanceof BigDripleafBlock || resultBlock instanceof BigDripleafStemBlock) { - return resultState.get(HorizontalFacingBlock.FACING) == targetState.get(HorizontalFacingBlock.FACING); - } - } - - if (targetBlock instanceof TwistingVinesPlantBlock) { - if (resultBlock instanceof TwistingVinesBlock) { - return true; - } else if (resultBlock instanceof TwistingVinesPlantBlock) { - return statesEqualIgnoreProperties(resultState, targetState, TwistingVinesBlock.AGE); - } - } - - if (targetBlock instanceof TripwireBlock && resultBlock instanceof TripwireBlock) { - return statesEqualIgnoreProperties(resultState, targetState, - TripwireBlock.ATTACHED, TripwireBlock.DISARMED, TripwireBlock.POWERED, TripwireBlock.NORTH, - TripwireBlock.EAST, TripwireBlock.SOUTH, TripwireBlock.WEST); - } - - return super.statesEqual(resultState, targetState); - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/BlockReplacementGuide.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/BlockReplacementGuide.java deleted file mode 100644 index 4232848a8..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/BlockReplacementGuide.java +++ /dev/null @@ -1,75 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.placement; - -import me.aleksilassila.litematica.printer.v1_17.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import net.minecraft.block.CandleBlock; -import net.minecraft.block.SeaPickleBlock; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.SnowBlock; -import net.minecraft.block.enums.SlabType; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.state.property.IntProperty; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.Nullable; - -import java.util.HashMap; -import java.util.Optional; - -public class BlockReplacementGuide extends PlacementGuide { - private static final HashMap increasingProperties = new HashMap<>(); - - static { - increasingProperties.put(SnowBlock.LAYERS, null); - increasingProperties.put(SeaPickleBlock.PICKLES, null); - increasingProperties.put(CandleBlock.CANDLES, null); - } - - private Integer currentLevel = null; - private Integer targetLevel = null; - private IntProperty increasingProperty = null; - - public BlockReplacementGuide(SchematicBlockState state) { - super(state); - - for (IntProperty property : increasingProperties.keySet()) { - if (targetState.contains(property) && currentState.contains(property)) { - currentLevel = currentState.get(property); - targetLevel = targetState.get(property); - increasingProperty = property; - break; - } - } - } - - @Override - protected boolean getUseShift(SchematicBlockState state) { - return false; - } - - @Override - public @Nullable PrinterPlacementContext getPlacementContext(ClientPlayerEntity player) { - Optional requiredItem = getRequiredItem(player); - int slot = getRequiredItemStackSlot(player); - if (requiredItem.isEmpty() || slot == -1) return null; - - BlockHitResult hitResult = new BlockHitResult(Vec3d.ofCenter(state.blockPos), Direction.UP, state.blockPos, false); - return new PrinterPlacementContext(player, hitResult, requiredItem.get(), slot); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (getProperty(targetState, SlabBlock.TYPE).orElse(null) == SlabType.DOUBLE && getProperty(currentState, SlabBlock.TYPE).orElse(SlabType.DOUBLE) != SlabType.DOUBLE) { - return super.canExecute(player); - } - - if (currentLevel == null || targetLevel == null || increasingProperty == null) return false; - if (!statesEqualIgnoreProperties(currentState, targetState, CandleBlock.LIT, increasingProperty)) return false; - if (currentLevel >= targetLevel) return false; - - return super.canExecute(player); - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/ChestGuide.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/ChestGuide.java deleted file mode 100644 index 32c5f8eca..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/ChestGuide.java +++ /dev/null @@ -1,92 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.placement; - -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.ChestBlock; -import net.minecraft.block.enums.ChestType; -import net.minecraft.util.math.Direction; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -/** - * Whilst making this guide, I learned that chests are much like humans. - * Some prefer to stay single, and some want to connect with another of its kind. - * Also that reversing chest connection logic is an enormous pain in the ass. I spent way too long on this. - * Thanks for coming to my ted talk - */ -public class ChestGuide extends GeneralPlacementGuide { - public ChestGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected boolean getRequiresExplicitShift() { - return true; - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - protected Optional getLookDirection() { - return getProperty(targetState, ChestBlock.FACING) - .flatMap(facing -> Optional.of(facing.getOpposite())); - } - - @Override - protected List getPossibleSides() { - ChestType targetType = getProperty(targetState, ChestBlock.CHEST_TYPE).orElse(null); - Direction targetFacing = getProperty(targetState, ChestBlock.FACING).orElse(null); - - List sides = new ArrayList<>(); - - if (targetFacing == null || targetType == null) return sides; - - for (Direction direction : Direction.values()) { - if (targetType == ChestType.SINGLE && !willConnectToSide(state, direction)) { - sides.add(direction); - } else if (wantsToConnectToSide(state, direction) && willConnectToSide(state, direction)) { // :D - sides.add(direction); - } - } - - // Place single chests if cannot connect any existing chests - if (sides.isEmpty()) { - for (Direction direction : Direction.values()) { - if (!wantsToConnectToSide(state, direction) && !willConnectToSide(state, direction)) { - sides.add(direction); - } - } - } - - return sides; - } - - private boolean willConnectToSide(SchematicBlockState state, Direction neighborDirection) { - BlockState neighbor = state.offset(neighborDirection).currentState; - ChestType neighborType = getProperty(neighbor, ChestBlock.CHEST_TYPE).orElse(null); - Direction neighborFacing = getProperty(neighbor, ChestBlock.FACING).orElse(null); - Direction facing = getProperty(state.targetState, ChestBlock.FACING).orElse(null); - - if (neighborType == null || neighborFacing == null || facing == null) return false; - - if (facing.getAxis() == neighborDirection.getAxis() || neighborDirection.getAxis() == Direction.Axis.Y) - return false; - - return neighborType == ChestType.SINGLE && neighborFacing == facing && state.targetState.getBlock() == neighbor.getBlock(); - } - - private boolean wantsToConnectToSide(SchematicBlockState state, Direction direction) { - ChestType type = getProperty(state.targetState, ChestBlock.CHEST_TYPE).orElse(null); - Direction facing = getProperty(state.targetState, ChestBlock.FACING).orElse(null); - if (type == null || facing == null || type == ChestType.SINGLE) return false; - - Direction neighborDirection = type == ChestType.LEFT ? facing.rotateYClockwise() : facing.rotateYCounterclockwise(); - - return direction == neighborDirection; - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/FallingBlockGuide.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/FallingBlockGuide.java deleted file mode 100644 index 16de9eaf9..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/FallingBlockGuide.java +++ /dev/null @@ -1,37 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.placement; - -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.FallingBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.math.Direction; - -public class FallingBlockGuide extends GuesserGuide { - - public FallingBlockGuide(SchematicBlockState state) { - super(state); - } - - boolean blockPlacement() { - if (targetState.getBlock() instanceof FallingBlock) { - BlockState below = state.world.getBlockState(state.blockPos.offset(Direction.DOWN)); - return FallingBlock.canFallThrough(below); - } - - return false; - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (blockPlacement()) return false; - - return super.canExecute(player); - } - - @Override - public boolean skipOtherGuides() { - if (blockPlacement()) return true; - - return super.skipOtherGuides(); - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/FarmlandGuide.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/FarmlandGuide.java deleted file mode 100644 index e76700b6f..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/FarmlandGuide.java +++ /dev/null @@ -1,29 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.placement; - -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; - -public class FarmlandGuide extends GeneralPlacementGuide { - public static final Block[] TILLABLE_BLOCKS = new Block[]{ - Blocks.DIRT, - Blocks.GRASS_BLOCK, - Blocks.COARSE_DIRT, - Blocks.ROOTED_DIRT, - Blocks.DIRT_PATH, - }; - - public FarmlandGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(TILLABLE_BLOCKS).map(b -> getBlockItem(b.getDefaultState())).toList(); - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/FlowerPotGuide.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/FlowerPotGuide.java deleted file mode 100644 index 5f7088a90..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/FlowerPotGuide.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.placement; - -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class FlowerPotGuide extends GeneralPlacementGuide { - public FlowerPotGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(new ItemStack(Items.FLOWER_POT)); - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/GeneralPlacementGuide.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/GeneralPlacementGuide.java deleted file mode 100644 index e0f88cc35..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/GeneralPlacementGuide.java +++ /dev/null @@ -1,119 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.placement; - -import me.aleksilassila.litematica.printer.v1_17.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.enums.SlabType; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -/** - * An old school guide where there are defined specific conditions - * for player state depending on the block being placed. - */ -public class GeneralPlacementGuide extends PlacementGuide { - public GeneralPlacementGuide(SchematicBlockState state) { - super(state); - } - - protected List getPossibleSides() { - return Arrays.asList(Direction.values()); - } - - protected Optional getLookDirection() { - return Optional.empty(); - } - - protected boolean getRequiresSupport() { - return false; - } - - protected boolean getRequiresExplicitShift() { - return false; - } - - protected Vec3d getHitModifier(Direction validSide) { - return new Vec3d(0, 0, 0); - } - - private Optional getValidSide(SchematicBlockState state) { - boolean printInAir = false; // LitematicaMixinMod.PRINT_IN_AIR.getBooleanValue(); - - List sides = getPossibleSides(); - - if (sides.isEmpty()) { - return Optional.empty(); - } - - List validSides = new ArrayList<>(); - for (Direction side : sides) { - if (printInAir && !getRequiresSupport()) { - return Optional.of(side); - } else { - SchematicBlockState neighborState = state.offset(side); - - if (getProperty(neighborState.currentState, SlabBlock.TYPE).orElse(null) == SlabType.DOUBLE) { - validSides.add(side); - continue; - } - - if (canBeClicked(neighborState.world, neighborState.blockPos) && // Handle unclickable grass for example - !neighborState.currentState.getMaterial().isReplaceable()) - validSides.add(side); - } - } - - for (Direction validSide : validSides) { - if (!isInteractive(state.offset(validSide).currentState.getBlock())) { - return Optional.of(validSide); - } - } - - return validSides.isEmpty() ? Optional.empty() : Optional.of(validSides.get(0)); - } - - protected boolean getUseShift(SchematicBlockState state) { - if (getRequiresExplicitShift()) return true; - - Direction clickSide = getValidSide(state).orElse(null); - if (clickSide == null) return false; - return isInteractive(state.offset(clickSide).currentState.getBlock()); - } - - private Optional getHitVector(SchematicBlockState state) { - return getValidSide(state).map(side -> Vec3d.ofCenter(state.blockPos) - .add(Vec3d.of(side.getVector()).multiply(0.5)) - .add(getHitModifier(side))); - } - - @Nullable - public PrinterPlacementContext getPlacementContext(ClientPlayerEntity player) { - try { - Optional validSide = getValidSide(state); - Optional hitVec = getHitVector(state); - Optional requiredItem = getRequiredItem(player); - int requiredSlot = getRequiredItemStackSlot(player); - - if (validSide.isEmpty() || hitVec.isEmpty() || requiredItem.isEmpty() || requiredSlot == -1) return null; - - Optional lookDirection = getLookDirection(); - boolean requiresShift = getUseShift(state); - - BlockHitResult blockHitResult = new BlockHitResult(hitVec.get(), validSide.get().getOpposite(), state.blockPos.offset(validSide.get()), false); - - return new PrinterPlacementContext(player, blockHitResult, requiredItem.get(), requiredSlot, lookDirection.orElse(null), requiresShift); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/GuesserGuide.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/GuesserGuide.java deleted file mode 100644 index 02695fe87..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/GuesserGuide.java +++ /dev/null @@ -1,110 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.placement; - -import me.aleksilassila.litematica.printer.v1_17.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_17.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.ChestBlock; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.enums.ChestType; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.Nullable; - -/** - * This is the placement guide that most blocks will use. - * It will try to predict the correct player state for producing the right blockState - * by brute forcing the correct hit vector and look direction. - */ -public class GuesserGuide extends GeneralPlacementGuide { - private PrinterPlacementContext contextCache = null; - - protected static Direction[] directionsToTry = new Direction[]{ - Direction.NORTH, - Direction.SOUTH, - Direction.EAST, - Direction.WEST, - Direction.UP, - Direction.DOWN - }; - protected static Vec3d[] hitVecsToTry = new Vec3d[]{ - new Vec3d(-0.25, -0.25, -0.25), - new Vec3d(+0.25, -0.25, -0.25), - new Vec3d(-0.25, +0.25, -0.25), - new Vec3d(-0.25, -0.25, +0.25), - new Vec3d(+0.25, +0.25, -0.25), - new Vec3d(-0.25, +0.25, +0.25), - new Vec3d(+0.25, -0.25, +0.25), - new Vec3d(+0.25, +0.25, +0.25), - }; - - public GuesserGuide(SchematicBlockState state) { - super(state); - } - - @Nullable - @Override - public PrinterPlacementContext getPlacementContext(ClientPlayerEntity player) { - if (contextCache != null && !LitematicaMixinMod.DEBUG) return contextCache; - - ItemStack requiredItem = getRequiredItem(player).orElse(ItemStack.EMPTY); - int slot = getRequiredItemStackSlot(player); - - if (slot == -1) return null; - - for (Direction lookDirection : directionsToTry) { - for (Direction side : directionsToTry) { - BlockPos neighborPos = state.blockPos.offset(side); - BlockState neighborState = state.world.getBlockState(neighborPos); - boolean requiresShift = getRequiresExplicitShift() || isInteractive(neighborState.getBlock()); - - if (!canBeClicked(state.world, neighborPos) || // Handle unclickable grass for example - neighborState.getMaterial().isReplaceable()) - continue; - - Vec3d hitVec = Vec3d.ofCenter(state.blockPos) - .add(Vec3d.of(side.getVector()).multiply(0.5)); - - for (Vec3d hitVecToTry : hitVecsToTry) { - Vec3d multiplier = Vec3d.of(side.getVector()); - multiplier = new Vec3d(multiplier.x == 0 ? 1 : 0, multiplier.y == 0 ? 1 : 0, multiplier.z == 0 ? 1 : 0); - - BlockHitResult hitResult = new BlockHitResult(hitVec.add(hitVecToTry.multiply(multiplier)), side.getOpposite(), neighborPos, false); - PrinterPlacementContext context = new PrinterPlacementContext(player, hitResult, requiredItem, slot, lookDirection, requiresShift); - BlockState result = getRequiredItemAsBlock(player) - .orElse(targetState.getBlock()) - .getPlacementState(context); // FIXME torch shift clicks another torch and getPlacementState is the clicked block, which is true - - if (result != null && (statesEqual(result, targetState) || correctChestPlacement(targetState, result))) { - contextCache = context; - return context; - } - } - } - } - - return null; - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (targetState.getBlock() instanceof SlabBlock) return false; // Slabs are a special case - - return super.canExecute(player); - } - - private boolean correctChestPlacement(BlockState targetState, BlockState result) { - if (targetState.contains(ChestBlock.CHEST_TYPE) && result.contains(ChestBlock.CHEST_TYPE) && result.get(ChestBlock.FACING) == targetState.get(ChestBlock.FACING)) { - ChestType targetChestType = targetState.get(ChestBlock.CHEST_TYPE); - ChestType resultChestType = result.get(ChestBlock.CHEST_TYPE); - - return targetChestType != ChestType.SINGLE && resultChestType == ChestType.SINGLE; - } - - return false; - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/LogGuide.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/LogGuide.java deleted file mode 100644 index 8a0144bf9..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/LogGuide.java +++ /dev/null @@ -1,54 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.placement; - -import me.aleksilassila.litematica.printer.v1_17.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_17.guides.interaction.LogStrippingGuide; -import net.minecraft.block.Block; -import net.minecraft.block.PillarBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.Direction; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -public class LogGuide extends GeneralPlacementGuide { - public LogGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - if (targetState.contains(PillarBlock.AXIS)) { - Direction.Axis axis = targetState.get(PillarBlock.AXIS); - return Arrays.stream(Direction.values()).filter(d -> d.getAxis() == axis).toList(); - } - - return new ArrayList<>(); - } - - @Override - protected @NotNull List getRequiredItems() { - for (Block log : LogStrippingGuide.STRIPPED_BLOCKS.keySet()) { - if (targetState.getBlock() == LogStrippingGuide.STRIPPED_BLOCKS.get(log)) { - return Collections.singletonList(new ItemStack(log)); - } - } - - return super.getRequiredItems(); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!LitematicaMixinMod.STRIP_LOGS.getBooleanValue()) return false; - - if (LogStrippingGuide.STRIPPED_BLOCKS.containsValue(targetState.getBlock())) { - return super.canExecute(player); - } - - return false; - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/PlacementGuide.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/PlacementGuide.java deleted file mode 100644 index 527f16f5c..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/PlacementGuide.java +++ /dev/null @@ -1,138 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.placement; - -import me.aleksilassila.litematica.printer.v1_17.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_17.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_17.actions.Action; -import me.aleksilassila.litematica.printer.v1_17.actions.PrepareAction; -import me.aleksilassila.litematica.printer.v1_17.actions.ReleaseShiftAction; -import me.aleksilassila.litematica.printer.v1_17.guides.Guide; -import me.aleksilassila.litematica.printer.v1_17.implementation.actions.InteractActionImpl; -import net.minecraft.block.*; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.World; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -/** - * Guide that clicks its neighbors to create a placement in target position. - */ -abstract public class PlacementGuide extends Guide { - public PlacementGuide(SchematicBlockState state) { - super(state); - } - - protected ItemStack getBlockItem(BlockState state) { - return state.getBlock().getPickStack(this.state.world, this.state.blockPos, state); - } - - protected Optional getRequiredItemAsBlock(ClientPlayerEntity player) { - Optional requiredItem = getRequiredItem(player); - - if (requiredItem.isEmpty()) { - return Optional.empty(); - } else { - ItemStack itemStack = requiredItem.get(); - - if (itemStack.getItem() instanceof BlockItem) - return Optional.of(((BlockItem) itemStack.getItem()).getBlock()); - else return Optional.empty(); - } - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(getBlockItem(state.targetState)); - } - - abstract protected boolean getUseShift(SchematicBlockState state); - - @Nullable - abstract public PrinterPlacementContext getPlacementContext(ClientPlayerEntity player); - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - List requiredItems = getRequiredItems(); - if (requiredItems.isEmpty() || requiredItems.stream().allMatch(i -> i.isOf(Items.AIR))) - return false; - - ItemPlacementContext ctx = getPlacementContext(player); - if (ctx == null || !ctx.canPlace()) return false; -// if (!state.currentState.getMaterial().isReplaceable()) return false; - if (!LitematicaMixinMod.REPLACE_FLUIDS_SOURCE_BLOCKS.getBooleanValue() - && getProperty(state.currentState, FluidBlock.LEVEL).orElse(1) == 0) - return false; - - BlockState resultState = getRequiredItemAsBlock(player) - .orElse(targetState.getBlock()) - .getPlacementState(ctx); - - if (resultState != null) { - if (!resultState.canPlaceAt(state.world, state.blockPos)) return false; - return !(currentState.getBlock() instanceof FluidBlock) || canPlaceInWater(resultState); - } else { - return false; - } - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - List actions = new ArrayList<>(); - PrinterPlacementContext ctx = getPlacementContext(player); - - if (ctx == null) return actions; - actions.add(new PrepareAction(ctx)); - actions.add(new InteractActionImpl(ctx)); - if (ctx.shouldSneak) actions.add(new ReleaseShiftAction()); - - return actions; - } - - protected static boolean canBeClicked(World world, BlockPos pos) { - return getOutlineShape(world, pos) != VoxelShapes.empty() && !(world.getBlockState(pos).getBlock() instanceof AbstractSignBlock); // FIXME signs - } - - private static VoxelShape getOutlineShape(World world, BlockPos pos) { - return world.getBlockState(pos).getOutlineShape(world, pos); - } - - public boolean isInteractive(Block block) { - for (Class clazz : interactiveBlocks) { - if (clazz.isInstance(block)) { - return true; - } - } - - return false; - } - - private boolean canPlaceInWater(BlockState blockState) { - Block block = blockState.getBlock(); - if (block instanceof FluidFillable) { - return true; - } else if (!(block instanceof DoorBlock) && !(blockState.getBlock() instanceof AbstractSignBlock) && !blockState.isOf(Blocks.LADDER) && !blockState.isOf(Blocks.SUGAR_CANE) && !blockState.isOf(Blocks.BUBBLE_COLUMN)) { - Material material = blockState.getMaterial(); - if (material != Material.PORTAL && material != Material.STRUCTURE_VOID && material != Material.UNDERWATER_PLANT && material != Material.REPLACEABLE_UNDERWATER_PLANT) { - return material.blocksMovement(); - } else { - return true; - } - } - - return true; - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/RailGuesserGuide.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/RailGuesserGuide.java deleted file mode 100644 index d8251d4f0..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/RailGuesserGuide.java +++ /dev/null @@ -1,128 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.placement; - -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.enums.RailShape; -import net.minecraft.state.property.Properties; -import net.minecraft.util.math.Direction; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -public class RailGuesserGuide extends GuesserGuide { - static final RailShape[] STRAIGHT_RAIL_SHAPES = new RailShape[]{ - RailShape.NORTH_SOUTH, - RailShape.EAST_WEST - }; - - public RailGuesserGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - protected boolean statesEqual(BlockState resultState, BlockState targetState) { - if (!wouldConnectCorrectly()) return false; -// if (wouldBlockAnotherConnection()) return false; - /*TODO: Fully working rail guesser - * If has a neighbor that: - * - Has not been placed yet - * - OR Has been placed but can change shape - * - AND this placement should connect to only one rail, that is not the neighbor - * Then return false - * */ - - if (getRailShape(resultState).isPresent()) { - if (Arrays.stream(STRAIGHT_RAIL_SHAPES).anyMatch(shape -> shape == getRailShape(resultState).orElse(null))) { - return super.statesEqualIgnoreProperties(resultState, targetState, Properties.RAIL_SHAPE, Properties.STRAIGHT_RAIL_SHAPE, Properties.POWERED); - } - } - - return super.statesEqual(resultState, targetState); - } - - private boolean wouldConnectCorrectly() { - RailShape targetShape = getRailShape(state.targetState).orElse(null); - if (targetShape == null) return false; - - List allowedConnections = getRailDirections(targetShape); - - List possibleConnections = new ArrayList<>(); - for (Direction d : Direction.values()) { - if (d.getAxis().isVertical()) continue; - SchematicBlockState neighbor = state.offset(d); - - if (hasFreeConnections(neighbor)) { - possibleConnections.add(d); - } - } - - if (possibleConnections.size() > 2) return false; - - return allowedConnections.containsAll(possibleConnections); - } - -// private boolean wouldBlockAnotherConnection() { -// List possibleConnections = new ArrayList<>(); -// -// for (Direction d : Direction.values()) { -// if (d.getAxis().isVertical()) continue; -// SchematicBlockState neighbor = state.offset(d); -// -// if (couldConnectWrongly(neighbor)) { -// possibleConnections.add(d); -// } -// } -// -// return possibleConnections.size() > 1; -// } - - private boolean hasFreeConnections(SchematicBlockState state) { - List possibleConnections = getRailDirections(state); - if (possibleConnections.isEmpty()) return false; - - for (Direction d : possibleConnections) { - SchematicBlockState neighbor = state.offset(d); - if (neighbor.currentState.getBlock() != neighbor.currentState.getBlock()) { - return false; - } - } - - return possibleConnections.stream().anyMatch(possibleDirection -> { - SchematicBlockState neighbor = state.offset(possibleDirection); - return !getRailDirections(neighbor).contains(possibleDirection.getOpposite()); - }); - } - - private List getRailDirections(SchematicBlockState state) { - RailShape shape = getRailShape(state.currentState).orElse(null); - if (shape == null) return new ArrayList<>(); - - return getRailDirections(shape); - } - - private List getRailDirections(RailShape railShape) { - String name = railShape.getName(); - - if (railShape.isAscending()) { - Direction d = Direction.valueOf(name.replace("ascending_", "").toUpperCase()); - return Arrays.asList(d, d.getOpposite()); - } else { - Direction d1 = Direction.valueOf(name.split("_")[0].toUpperCase()); - Direction d2 = Direction.valueOf(name.split("_")[1].toUpperCase()); - return Arrays.asList(d1, d2); - } - } - - Optional getRailShape(BlockState state) { - Optional shape = getProperty(state, Properties.RAIL_SHAPE); - if (shape.isEmpty()) return getProperty(state, Properties.STRAIGHT_RAIL_SHAPE); - return shape; - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/RotatingBlockGuide.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/RotatingBlockGuide.java deleted file mode 100644 index b72cf5c7e..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/RotatingBlockGuide.java +++ /dev/null @@ -1,58 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.placement; - -import me.aleksilassila.litematica.printer.v1_17.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_17.actions.Action; -import me.aleksilassila.litematica.printer.v1_17.actions.PrepareAction; -import net.minecraft.block.*; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.state.property.Properties; -import net.minecraft.util.math.Direction; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -public class RotatingBlockGuide extends GeneralPlacementGuide { - public RotatingBlockGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - Block block = state.targetState.getBlock(); - if (block instanceof WallSkullBlock || block instanceof WallSignBlock || block instanceof WallBannerBlock) { - Optional side = getProperty(state.targetState, Properties.HORIZONTAL_FACING).map(Direction::getOpposite); - return side.map(Collections::singletonList).orElseGet(Collections::emptyList); - } - - return Collections.singletonList(Direction.DOWN); - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - PrinterPlacementContext ctx = getPlacementContext(player); - - if (ctx == null) return new ArrayList<>(); - - int rotation = getProperty(state.targetState, Properties.ROTATION).orElse(0); - if (targetState.getBlock() instanceof BannerBlock || targetState.getBlock() instanceof SignBlock) { - rotation = (rotation + 8) % 16; - } - - int distTo0 = rotation > 8 ? 16 - rotation : rotation; - float yaw = Math.round(distTo0 / 8f * 180f * (rotation > 8 ? -1 : 1)); - - List actions = super.execute(player); - actions.set(0, new PrepareAction(ctx, yaw, 0)); - - return actions; - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/SlabGuide.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/SlabGuide.java deleted file mode 100644 index 845013221..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/SlabGuide.java +++ /dev/null @@ -1,48 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.placement; - -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.enums.SlabType; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; - -import java.util.Arrays; -import java.util.List; - -public class SlabGuide extends GeneralPlacementGuide { - public SlabGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - return Arrays.stream(Direction.values()) - .filter(d -> d != (getRequiredHalf(state).getOpposite()) && - getProperty(state.offset(d).currentState, SlabBlock.TYPE).orElse(SlabType.DOUBLE) == SlabType.DOUBLE) - .toList(); - } - - @Override - protected Vec3d getHitModifier(Direction validSide) { - Direction requiredHalf = getRequiredHalf(state); - if (validSide.getHorizontal() != -1) { - return new Vec3d(0, requiredHalf.getOffsetY() * 0.25, 0); - } else { - return new Vec3d(0, 0, 0); - } - } - - private Direction getRequiredHalf(SchematicBlockState state) { - BlockState targetState = state.targetState; - BlockState currentState = state.currentState; - - if (!currentState.contains(SlabBlock.TYPE)) { - return targetState.get(SlabBlock.TYPE) == SlabType.TOP ? Direction.UP : Direction.DOWN; - } else if (currentState.get(SlabBlock.TYPE) != targetState.get(SlabBlock.TYPE)) { - return currentState.get(SlabBlock.TYPE) == SlabType.TOP ? Direction.DOWN : Direction.UP; - } else { - return Direction.DOWN; - } - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/TorchGuide.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/TorchGuide.java deleted file mode 100644 index 329053946..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/guides/placement/TorchGuide.java +++ /dev/null @@ -1,31 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.guides.placement; - -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import net.minecraft.block.Block; -import net.minecraft.block.HorizontalFacingBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.math.Direction; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -public class TorchGuide extends GeneralPlacementGuide { - public TorchGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - Optional facing = getProperty(targetState, HorizontalFacingBlock.FACING); - - return facing - .map(direction -> Collections.singletonList(direction.getOpposite())) - .orElseGet(() -> Collections.singletonList(Direction.DOWN)); - } - - @Override - protected Optional getRequiredItemAsBlock(ClientPlayerEntity player) { - return Optional.of(state.targetState.getBlock()); - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/implementation/BlockHelperImpl.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/implementation/BlockHelperImpl.java deleted file mode 100644 index e9761f6f0..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/implementation/BlockHelperImpl.java +++ /dev/null @@ -1,14 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.implementation; - -import me.aleksilassila.litematica.printer.v1_17.BlockHelper; -import net.minecraft.block.AbstractButtonBlock; - -import java.util.Arrays; - -public class BlockHelperImpl extends BlockHelper { - static { - interactiveBlocks.addAll(Arrays.asList( - AbstractButtonBlock.class - )); - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/implementation/PrinterPlacementContext.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/implementation/PrinterPlacementContext.java deleted file mode 100644 index 16260c87f..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/implementation/PrinterPlacementContext.java +++ /dev/null @@ -1,59 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.implementation; - -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import org.jetbrains.annotations.Nullable; - -public class PrinterPlacementContext extends ItemPlacementContext { - public final @Nullable Direction lookDirection; - public final boolean shouldSneak; - public final BlockHitResult hitResult; - public final int requiredItemSlot; - - public PrinterPlacementContext(PlayerEntity player, BlockHitResult hitResult, ItemStack requiredItem, int requiredItemSlot) { - this(player, hitResult, requiredItem, requiredItemSlot, null, false); - } - - public PrinterPlacementContext(PlayerEntity player, BlockHitResult hitResult, ItemStack requiredItem, int requiredItemSlot, @Nullable Direction lookDirection, boolean requiresSneaking) { - super(player, Hand.MAIN_HAND, requiredItem, hitResult); - - this.lookDirection = lookDirection; - this.shouldSneak = requiresSneaking; - this.hitResult = hitResult; - this.requiredItemSlot = requiredItemSlot; - } - - @Override - public Direction getPlayerLookDirection() { - return lookDirection == null ? super.getPlayerLookDirection() : lookDirection; - } - - @Override - public Direction getVerticalPlayerLookDirection() { - if (lookDirection != null && lookDirection.getOpposite() == super.getVerticalPlayerLookDirection()) - return lookDirection; - return super.getVerticalPlayerLookDirection(); - } - - @Override - public Direction getPlayerFacing() { - if (lookDirection == null || !lookDirection.getAxis().isHorizontal()) return super.getPlayerFacing(); - - return lookDirection; - } - - @Override - public String toString() { - return "PrinterPlacementContext{" + - "lookDirection=" + lookDirection + - ", requiresSneaking=" + shouldSneak + - ", blockPos=" + hitResult.getBlockPos() + - ", side=" + hitResult.getSide() + -// ", hitVec=" + hitResult + - '}'; - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/implementation/actions/InteractActionImpl.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/implementation/actions/InteractActionImpl.java deleted file mode 100644 index 1349c01d0..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/implementation/actions/InteractActionImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.implementation.actions; - -import me.aleksilassila.litematica.printer.v1_17.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_17.actions.InteractAction; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; - -public class InteractActionImpl extends InteractAction { - public InteractActionImpl(PrinterPlacementContext context) { - super(context); - } - - @Override - protected void interact(MinecraftClient client, ClientPlayerEntity player, Hand hand, BlockHitResult hitResult) { - client.interactionManager.interactBlock(player, client.world, hand, hitResult); - client.interactionManager.interactItem(player, client.world, hand); - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/implementation/mixin/MixinClientPlayerEntity.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/implementation/mixin/MixinClientPlayerEntity.java deleted file mode 100644 index 1f6185d36..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/implementation/mixin/MixinClientPlayerEntity.java +++ /dev/null @@ -1,103 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.implementation.mixin; - -import com.mojang.authlib.GameProfile; -import fi.dy.masa.litematica.world.SchematicWorldHandler; -import fi.dy.masa.litematica.world.WorldSchematic; -import me.aleksilassila.litematica.printer.v1_17.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_17.Printer; -import me.aleksilassila.litematica.printer.v1_17.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_17.UpdateChecker; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.block.entity.SignBlockEntity; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.AbstractClientPlayerEntity; -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.network.MessageType; -import net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket; -import net.minecraft.text.LiteralText; -import org.spongepowered.asm.mixin.Mixin; -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; - -import java.util.Optional; - -@Mixin(ClientPlayerEntity.class) -public class MixinClientPlayerEntity extends AbstractClientPlayerEntity { - private static boolean didCheckForUpdates = false; - - public MixinClientPlayerEntity(ClientWorld world, GameProfile profile) { - super(world, profile); - } - - @Shadow - protected MinecraftClient client; - @Shadow - public ClientPlayNetworkHandler networkHandler; - - @Inject(at = @At("TAIL"), method = "tick") - public void tick(CallbackInfo ci) { - ClientPlayerEntity clientPlayer = (ClientPlayerEntity) (Object) this; - if (!didCheckForUpdates) { - didCheckForUpdates = true; - - checkForUpdates(); - } - - if (LitematicaMixinMod.printer == null || LitematicaMixinMod.printer.player != clientPlayer) { - System.out.println("Initializing printer, player: " + clientPlayer + ", client: " + client); - LitematicaMixinMod.printer = new Printer(client, clientPlayer); - } - - // Dirty optimization - boolean didFindPlacement = true; - for (int i = 0; i < 10; i++) { - if (didFindPlacement) { - didFindPlacement = LitematicaMixinMod.printer.onGameTick(); - } - LitematicaMixinMod.printer.actionHandler.onGameTick(); - } - } - - public void checkForUpdates() { - new Thread(() -> { - String version = UpdateChecker.version; - String newVersion = UpdateChecker.getPrinterVersion(); - - if (!version.equals(newVersion)) { - client.inGameHud.addChatMessage(MessageType.SYSTEM, - new LiteralText("New version of Litematica Printer available in https://github.com/aleksilassila/litematica-printer/releases"), - null); - } - }).start(); - } - - @Inject(method = "openEditSignScreen", at = @At("HEAD"), cancellable = true) - public void openEditSignScreen(SignBlockEntity sign, CallbackInfo ci) { - getTargetSignEntity(sign).ifPresent(signBlockEntity -> { - UpdateSignC2SPacket packet = new UpdateSignC2SPacket(sign.getPos(), - signBlockEntity.getTextOnRow(0, false).getString(), - signBlockEntity.getTextOnRow(1, false).getString(), - signBlockEntity.getTextOnRow(2, false).getString(), - signBlockEntity.getTextOnRow(3, false).getString()); - this.networkHandler.sendPacket(packet); - ci.cancel(); - }); - } - - private Optional getTargetSignEntity(SignBlockEntity sign) { - WorldSchematic worldSchematic = SchematicWorldHandler.getSchematicWorld(); - SchematicBlockState state = new SchematicBlockState(sign.getWorld(), worldSchematic, sign.getPos()); - - BlockEntity targetBlockEntity = worldSchematic.getBlockEntity(state.blockPos); - - if (targetBlockEntity instanceof SignBlockEntity targetSignEntity) { - return Optional.of(targetSignEntity); - } - - return Optional.empty(); - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/mixin/AxeItemAccessor.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/mixin/AxeItemAccessor.java deleted file mode 100644 index 36c77bf35..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/mixin/AxeItemAccessor.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.mixin; - -import net.minecraft.block.Block; -import net.minecraft.item.AxeItem; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.util.Map; - -/** - * This class apparently fixes an issue with Quilt. - */ -@Mixin(AxeItem.class) -public interface AxeItemAccessor { - @Accessor("STRIPPED_BLOCKS") - static Map getStrippedBlocks() { - throw new AssertionError("Untransformed @Accessor"); - } - -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/mixin/ConfigsMixin.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/mixin/ConfigsMixin.java deleted file mode 100644 index ba3b69a3a..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/mixin/ConfigsMixin.java +++ /dev/null @@ -1,35 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.mixin; - -import com.google.common.collect.ImmutableList; -import fi.dy.masa.litematica.config.Configs; -import fi.dy.masa.malilib.config.IConfigBase; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import me.aleksilassila.litematica.printer.v1_17.LitematicaMixinMod; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.List; - -@Mixin(value = Configs.class, remap = false) -public class ConfigsMixin { - @Redirect(method = "loadFromFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Configs$Generic;OPTIONS:Lcom/google/common/collect/ImmutableList;")) - private static ImmutableList moreOptions() { - return LitematicaMixinMod.getConfigList(); - } - - @Redirect(method = "saveToFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Configs$Generic;OPTIONS:Lcom/google/common/collect/ImmutableList;")) - private static ImmutableList moreeOptions() { - return LitematicaMixinMod.getConfigList(); - } - - @Redirect(method = "loadFromFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private static List moreHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } - - @Redirect(method = "saveToFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private static List moreeHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/mixin/GuiConfigsMixin.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/mixin/GuiConfigsMixin.java deleted file mode 100644 index 13f5e2126..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/mixin/GuiConfigsMixin.java +++ /dev/null @@ -1,61 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.mixin; - -import com.google.common.collect.ImmutableList; -import fi.dy.masa.litematica.gui.GuiConfigs; -import fi.dy.masa.malilib.config.IConfigBase; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import me.aleksilassila.litematica.printer.v1_17.LitematicaMixinMod; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.List; - -@Mixin(value = GuiConfigs.class, remap = false) -public class GuiConfigsMixin { - - /*@Overwrite - public List getConfigs() - { - List configs; - ConfigGuiTab tab = DataManager.getConfigGuiTab(); - - if (tab == ConfigGuiTab.GENERIC) - { - configs = LitematicaMixinMod.betterConfigList; - } - else if (tab == ConfigGuiTab.INFO_OVERLAYS) - { - configs = Configs.InfoOverlays.OPTIONS; - } - else if (tab == ConfigGuiTab.VISUALS) - { - configs = Configs.Visuals.OPTIONS; - } - else if (tab == ConfigGuiTab.COLORS) - { - configs = Configs.Colors.OPTIONS; - } - else if (tab == ConfigGuiTab.HOTKEYS) - { - configs = LitematicaMixinMod.betterHotkeyList; - } - else - { - return Collections.emptyList(); - } - - return ConfigOptionWrapper.createFor(configs); - }*/ - - - @Redirect(method = "getConfigs", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Configs$Generic;OPTIONS:Lcom/google/common/collect/ImmutableList;")) - private ImmutableList moreOptions() { - return LitematicaMixinMod.getConfigList(); - } - - @Redirect(method = "getConfigs", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private List moreHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } -} diff --git a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/mixin/InputHandlerMixin.java b/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/mixin/InputHandlerMixin.java deleted file mode 100644 index 115784d8d..000000000 --- a/v1_17/src/main/java/me/aleksilassila/litematica/printer/v1_17/mixin/InputHandlerMixin.java +++ /dev/null @@ -1,25 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_17.mixin; - -import fi.dy.masa.litematica.event.InputHandler; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import me.aleksilassila.litematica.printer.v1_17.LitematicaMixinMod; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.List; - -@Mixin(value = InputHandler.class, remap = false) -public class InputHandlerMixin { - - @Redirect(method = "addHotkeys", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private List moreHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } - - @Redirect(method = "addKeysToMap", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private List moreeHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } - -} diff --git a/v1_17/src/main/resources/fabric.mod.json b/v1_17/src/main/resources/fabric.mod.json deleted file mode 100644 index 00b458672..000000000 --- a/v1_17/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "schemaVersion": 1, - "id": "litematica_printer", - "version": "${version}", - "name": "Litematica Printer", - "description": "A fork of Litematica that adds the missing printer functionality", - "authors": [ - "aleksilassila" - ], - "contact": { - "homepage": "https://github.com/aleksilassila/litematica-printer", - "sources": "https://github.com/aleksilassila/litematica-printer" - }, - "license": "CC0-1.0", - "icon": "assets/modid/icon.png", - "environment": "*", - "entrypoints": { - "main": [ - "me.aleksilassila.litematica.printer.v1_17.LitematicaMixinMod" - ] - }, - "mixins": [ - "litematica-printer.mixins.json", - "litematica-printer-implementation.mixins.json" - ], - "depends": { - "fabricloader": ">=0.11.3", - "fabric": "*", - "minecraft": "1.17.x", - "java": ">=16" - }, - "custom": { - "modmenu": { - "parent": "carpet" - } - } -} - diff --git a/v1_17/src/main/resources/litematica-printer-implementation.mixins.json b/v1_17/src/main/resources/litematica-printer-implementation.mixins.json deleted file mode 100644 index 50cdceaec..000000000 --- a/v1_17/src/main/resources/litematica-printer-implementation.mixins.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "me.aleksilassila.litematica.printer.v1_17.implementation.mixin", - "compatibilityLevel": "JAVA_16", - "mixins": [ - ], - "client": [ - "MixinClientPlayerEntity" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/v1_17/src/main/resources/litematica-printer.mixins.json b/v1_17/src/main/resources/litematica-printer.mixins.json deleted file mode 100644 index 436058457..000000000 --- a/v1_17/src/main/resources/litematica-printer.mixins.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "me.aleksilassila.litematica.printer.v1_17.mixin", - "compatibilityLevel": "JAVA_16", - "mixins": [ - ], - "client": [ - "ConfigsMixin", - "GuiConfigsMixin", - "InputHandlerMixin", - "PlayerMoveC2SPacketMixin", - "AxeItemAccessor" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/v1_18/build.gradle.kts b/v1_18/build.gradle.kts deleted file mode 100644 index 2fecfc72b..000000000 --- a/v1_18/build.gradle.kts +++ /dev/null @@ -1,88 +0,0 @@ -plugins { - id("fabric-loom").version("1.0-SNAPSHOT") - id("maven-publish") -} - -java.sourceCompatibility = JavaVersion.VERSION_17 -java.targetCompatibility = JavaVersion.VERSION_17 - -val archives_base_name: String by project -val minecraft_version: String by project -val yarn_mappings: String by project -val loader_version: String by project -val fabric_version: String by project -val malilib_version: String by project -val litematica_projectid: String by project -val litematica_fileid: String by project - -val mod_version: String by project - -dependencies { -// implementation(project(":common")) - minecraft("com.mojang:minecraft:${minecraft_version}") - mappings("net.fabricmc:yarn:${yarn_mappings}:v2") - - modImplementation("net.fabricmc:fabric-loader:${loader_version}") - modImplementation("net.fabricmc.fabric-api:fabric-api:${fabric_version}") - modImplementation("fi.dy.masa.malilib:malilib-fabric-${malilib_version}") - modImplementation("curse.maven:litematica-${litematica_projectid}:${litematica_fileid}") -} - -repositories { - maven("https://masa.dy.fi/maven") - maven("https://www.cursemaven.com") -} - -// Process resources -tasks.withType { - inputs.property("version", mod_version) - - filesMatching("fabric.mod.json") { - expand(mapOf("version" to mod_version)) - } -} - -val sourceModule = "v1_18" -val targetModules = arrayOf("v1_17", "v1_19", "v1_19_3", "v1_19_4") - -fun copyFile(source: File) { - for (targetModule in targetModules) { - val destination = file(source.absolutePath.replace(sourceModule, targetModule)) - println("Copying ${source.absolutePath} to ${destination.absolutePath}") - destination.parentFile.mkdirs() - source.copyTo(destination, true) - destination.writeText(destination.readText().replace(sourceModule, targetModule)) - } -} - -fun deleteOldFiles(sourceBase: File) { - for (targetModule in targetModules) { - val targetBase = file(sourceBase.absolutePath.replace(sourceModule, targetModule)) - - for (file in targetBase.listFiles()) { - if (file.name.equals("implementation")) continue - println("Deleting recursively ${file.absolutePath}") - file.deleteRecursively() - } - } -} - -val syncImplementations = tasks.create("syncImplementations") { - doFirst { - val sourceStart = - this.project.projectDir.absolutePath + "/src/main/java/me/aleksilassila/litematica/printer/" + sourceModule - val sourceDir = file(sourceStart) - - deleteOldFiles(sourceDir) - - for (sourceFile in sourceDir.listFiles()) { - if (sourceFile.name.equals("implementation")) continue - - sourceFile.walk() - .filter { it.isFile } - .forEach { - copyFile(it) - } - } - } -} diff --git a/v1_18/gradle.properties b/v1_18/gradle.properties deleted file mode 100644 index af9398990..000000000 --- a/v1_18/gradle.properties +++ /dev/null @@ -1,13 +0,0 @@ -# Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx1G -# Fabric Properties https://fabricmc.net/versions.html -minecraft_version=1.18.2 -yarn_mappings=1.18.2+build.4 -loader_version=0.14.19 -#Fabric api -fabric_version=0.76.0+1.18.2 -# https://masa.dy.fi/maven/fi/dy/masa/malilib/ -malilib_version = 1.18.2:0.12.0 -# https://www.curseforge.com/minecraft/mc-mods/litematica/files -litematica_fileid=3783909 -litematica_projectid=308892 \ No newline at end of file diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/ActionHandler.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/ActionHandler.java deleted file mode 100644 index f1f60a8b8..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/ActionHandler.java +++ /dev/null @@ -1,57 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18; - -import me.aleksilassila.litematica.printer.v1_18.actions.Action; -import me.aleksilassila.litematica.printer.v1_18.actions.PrepareAction; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; - -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; - -public class ActionHandler { - private final MinecraftClient client; - private final ClientPlayerEntity player; - - private final Queue actionQueue = new LinkedList<>(); - public PrepareAction lookAction = null; - - public ActionHandler(MinecraftClient client, ClientPlayerEntity player) { - this.client = client; - this.player = player; - } - - private int tick = 0; - - public void onGameTick() { - int tickRate = LitematicaMixinMod.PRINTING_INTERVAL.getIntegerValue(); - - tick = tick % tickRate == tickRate - 1 ? 0 : tick + 1; - if (tick % tickRate != 0) { - return; - } - - Action nextAction = actionQueue.poll(); - if (nextAction != null) { - if (LitematicaMixinMod.DEBUG) System.out.println("Sending action " + nextAction); - nextAction.send(client, player); - } else { - lookAction = null; - } - } - - public boolean acceptsActions() { - return actionQueue.isEmpty(); - } - - public void addActions(Action... actions) { - if (!acceptsActions()) return; - - for (Action action : actions) { - if (action instanceof PrepareAction) - lookAction = (PrepareAction) action; - } - - actionQueue.addAll(List.of(actions)); - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/BlockHelper.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/BlockHelper.java deleted file mode 100644 index 11ae1699f..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/BlockHelper.java +++ /dev/null @@ -1,31 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18; - -import net.minecraft.block.*; -import net.minecraft.item.Item; -import net.minecraft.item.Items; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -abstract public class BlockHelper { - public static List> interactiveBlocks = new ArrayList<>(Arrays.asList( - AbstractChestBlock.class, AbstractFurnaceBlock.class, CraftingTableBlock.class, LeverBlock.class, - DoorBlock.class, TrapdoorBlock.class, BedBlock.class, RedstoneWireBlock.class, ScaffoldingBlock.class, - HopperBlock.class, EnchantingTableBlock.class, NoteBlock.class, JukeboxBlock.class, CakeBlock.class, - FenceGateBlock.class, BrewingStandBlock.class, DragonEggBlock.class, CommandBlock.class, - BeaconBlock.class, AnvilBlock.class, ComparatorBlock.class, RepeaterBlock.class, - DropperBlock.class, DispenserBlock.class, ShulkerBoxBlock.class, LecternBlock.class, - FlowerPotBlock.class, BarrelBlock.class, BellBlock.class, SmithingTableBlock.class, - LoomBlock.class, CartographyTableBlock.class, GrindstoneBlock.class, - StonecutterBlock.class, AbstractSignBlock.class, AbstractCandleBlock.class)); - - public static final Item[] SHOVEL_ITEMS = new Item[]{ - Items.NETHERITE_SHOVEL, - Items.DIAMOND_SHOVEL, - Items.GOLDEN_SHOVEL, - Items.IRON_SHOVEL, - Items.STONE_SHOVEL, - Items.WOODEN_SHOVEL - }; -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/LitematicaMixinMod.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/LitematicaMixinMod.java deleted file mode 100644 index 0ecc2818c..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/LitematicaMixinMod.java +++ /dev/null @@ -1,58 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18; - -import com.google.common.collect.ImmutableList; -import fi.dy.masa.litematica.config.Configs; -import fi.dy.masa.litematica.config.Hotkeys; -import fi.dy.masa.malilib.config.IConfigBase; -import fi.dy.masa.malilib.config.options.ConfigBoolean; -import fi.dy.masa.malilib.config.options.ConfigDouble; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import fi.dy.masa.malilib.config.options.ConfigInteger; -import fi.dy.masa.malilib.hotkeys.KeyCallbackToggleBooleanConfigWithMessage; -import fi.dy.masa.malilib.hotkeys.KeybindSettings; -import net.fabricmc.api.ModInitializer; - -import java.util.List; - -public class LitematicaMixinMod implements ModInitializer { - - public static Printer printer; - public static boolean DEBUG = false; - // Config settings - public static final ConfigInteger PRINTING_INTERVAL = new ConfigInteger("printingInterval", 12, 1, 40, "Printing interval. Lower values mean faster printing speed.\nIf the printer creates \"ghost blocks\" or blocks are facing the wrong way, raise this value."); - public static final ConfigDouble PRINTING_RANGE = new ConfigDouble("printingRange", 5, 2.5, 5, "Printing block place range\nLower values are recommended for servers."); - // public static final ConfigBoolean PRINT_WATER = new ConfigBoolean("printWater", false, "Whether the printer should place water\n source blocks or make blocks waterlogged."); -// public static final ConfigBoolean PRINT_IN_AIR = new ConfigBoolean("printInAir", true, "Whether or not the printer should place blocks without anything to build on.\nBe aware that some anti-cheat plugins might notice this."); - public static final ConfigBoolean PRINT_MODE = new ConfigBoolean("printingMode", false, "Autobuild / print loaded selection.\nBe aware that some servers and anticheat plugins do not allow printing."); - public static final ConfigBoolean REPLACE_FLUIDS_SOURCE_BLOCKS = new ConfigBoolean("replaceFluidSourceBlocks", true, "Whether or not fluid source blocks should be replaced by the printer."); - public static final ConfigBoolean STRIP_LOGS = new ConfigBoolean("stripLogs", true, "Whether or not the printer should use normal logs if stripped\nversions are not available and then strip them with an axe."); - - public static ImmutableList getConfigList() { - List list = new java.util.ArrayList<>(Configs.Generic.OPTIONS); - list.add(PRINT_MODE); - list.add(PRINTING_INTERVAL); - list.add(PRINTING_RANGE); -// list.add(PRINT_IN_AIR); - list.add(REPLACE_FLUIDS_SOURCE_BLOCKS); - list.add(STRIP_LOGS); - - return ImmutableList.copyOf(list); - } - - // Hotkeys - public static final ConfigHotkey PRINT = new ConfigHotkey("print", "V", KeybindSettings.PRESS_ALLOWEXTRA_EMPTY, "Prints while pressed"); - public static final ConfigHotkey TOGGLE_PRINTING_MODE = new ConfigHotkey("togglePrintingMode", "CAPS_LOCK", KeybindSettings.PRESS_ALLOWEXTRA_EMPTY, "Allows quickly toggling on/off Printing mode"); - - public static List getHotkeyList() { - List list = new java.util.ArrayList<>(Hotkeys.HOTKEY_LIST); - list.add(PRINT); - list.add(TOGGLE_PRINTING_MODE); - - return ImmutableList.copyOf(list); - } - - @Override - public void onInitialize() { - TOGGLE_PRINTING_MODE.getKeybind().setCallback(new KeyCallbackToggleBooleanConfigWithMessage(PRINT_MODE)); - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/Printer.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/Printer.java deleted file mode 100644 index a6190617c..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/Printer.java +++ /dev/null @@ -1,110 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18; - -import fi.dy.masa.litematica.data.DataManager; -import fi.dy.masa.litematica.util.RayTraceUtils; -import fi.dy.masa.litematica.world.SchematicWorldHandler; -import fi.dy.masa.litematica.world.WorldSchematic; -import me.aleksilassila.litematica.printer.v1_18.actions.Action; -import me.aleksilassila.litematica.printer.v1_18.guides.Guide; -import me.aleksilassila.litematica.printer.v1_18.guides.Guides; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerAbilities; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.RaycastContext; -import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -public class Printer { - @NotNull - public final ClientPlayerEntity player; - - public final ActionHandler actionHandler; - - private final Guides interactionGuides = new Guides(); - - public Printer(@NotNull MinecraftClient client, @NotNull ClientPlayerEntity player) { - this.player = player; - - this.actionHandler = new ActionHandler(client, player); - } - - public boolean onGameTick() { - WorldSchematic worldSchematic = SchematicWorldHandler.getSchematicWorld(); - - if (!actionHandler.acceptsActions()) return false; - - if (worldSchematic == null) return false; - - if (!LitematicaMixinMod.PRINT_MODE.getBooleanValue() && !LitematicaMixinMod.PRINT.getKeybind().isPressed()) - return false; - - PlayerAbilities abilities = player.getAbilities(); - if (!abilities.allowModifyWorld) - return false; - - List positions = getReachablePositions(); - findBlock: - for (BlockPos position : positions) { - SchematicBlockState state = new SchematicBlockState(player.world, worldSchematic, position); - if (state.targetState.equals(state.currentState) || state.targetState.isAir()) continue; - - Guide[] guides = interactionGuides.getInteractionGuides(state); - - BlockHitResult result = RayTraceUtils.traceToSchematicWorld(player, 10, true, true); - boolean isCurrentlyLookingSchematic = result != null && result.getBlockPos().equals(position); - - for (Guide guide : guides) { - if (guide.canExecute(player)) { - System.out.println("Executing " + guide + " for " + state); - List actions = guide.execute(player); - actionHandler.addActions(actions.toArray(Action[]::new)); - return true; - } - if (guide.skipOtherGuides()) continue findBlock; - } - } - - return false; - } - - private List getReachablePositions() { - int maxReach = (int) Math.ceil(LitematicaMixinMod.PRINTING_RANGE.getDoubleValue()); - double maxReachSquared = MathHelper.square(LitematicaMixinMod.PRINTING_RANGE.getDoubleValue()); - - ArrayList positions = new ArrayList<>(); - - for (int y = -maxReach; y < maxReach + 1; y++) { - for (int x = -maxReach; x < maxReach + 1; x++) { - for (int z = -maxReach; z < maxReach + 1; z++) { - BlockPos blockPos = player.getBlockPos().north(x).west(z).up(y); - - if (!DataManager.getRenderLayerRange().isPositionWithinRange(blockPos)) continue; - if (this.player.getEyePos().squaredDistanceTo(Vec3d.ofCenter(blockPos)) > maxReachSquared) { - continue; - } - - positions.add(blockPos); - } - } - } - - return positions.stream() - .filter(p -> { - Vec3d vec = Vec3d.ofCenter(p); - return this.player.getPos().squaredDistanceTo(vec) > 1 && this.player.getEyePos().squaredDistanceTo(vec) > 1; - }) - .sorted((a, b) -> { - double aDistance = this.player.getPos().squaredDistanceTo(Vec3d.ofCenter(a)); - double bDistance = this.player.getPos().squaredDistanceTo(Vec3d.ofCenter(b)); - return Double.compare(aDistance, bDistance); - }).toList(); - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/SchematicBlockState.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/SchematicBlockState.java deleted file mode 100644 index 8f72c1811..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/SchematicBlockState.java +++ /dev/null @@ -1,42 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18; - -import fi.dy.masa.litematica.world.WorldSchematic; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.World; - -public class SchematicBlockState { - public final World world; - public final WorldSchematic schematic; - - public final BlockPos blockPos; - - public final BlockState targetState; - public final BlockState currentState; - - public SchematicBlockState(World world, WorldSchematic schematic, BlockPos blockPos) { - this.world = world; - this.schematic = schematic; - - this.blockPos = blockPos; - - this.targetState = schematic.getBlockState(blockPos); - this.currentState = world.getBlockState(blockPos); - } - - public SchematicBlockState offset(Direction direction) { - return new SchematicBlockState(world, schematic, blockPos.offset(direction)); - } - - @Override - public String toString() { - return "SchematicBlockState{" + - "world=" + world + - ", schematic=" + schematic + - ", blockPos=" + blockPos + - ", targetState=" + targetState + - ", currentState=" + currentState + - '}'; - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/UpdateChecker.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/UpdateChecker.java deleted file mode 100644 index bf4613499..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/UpdateChecker.java +++ /dev/null @@ -1,49 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import org.apache.commons.io.IOUtils; - -import java.io.BufferedReader; -import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.util.Scanner; - -public class UpdateChecker { - public static final String version = "v3.2"; - - // Try to get this to work at some point -// static { -// try (InputStream in = UpdateChecker.class.getResourceAsStream("/fabric.mod.json")) { -// String jsonString = IOUtils.toString(in, StandardCharsets.UTF_8); -// JsonObject json = JsonParser.parseString(jsonString).getAsJsonObject(); -// System.out.println("JSON object: " + json); -// System.out.println("Raw json: " + jsonString); -// System.out.println("File: " + new File(UpdateChecker.class.getResource("/fabric.mod.json").getFile())); -// String version = json.get("version").getAsString(); -// System.out.println("Reading fabric.mod.json"); -// System.out.println("Parsed version: " + version); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } - - @SuppressWarnings("deprecation") - public static String getPrinterVersion() { - try (InputStream inputStream = new URL("https://api.github.com/repos/aleksilassila/litematica-printer/tags").openStream(); Scanner scanner = new Scanner(inputStream)) { - if (scanner.hasNext()) { - JsonArray tags = new JsonParser().parse(scanner.next()).getAsJsonArray(); - return ((JsonObject) tags.get(0)).get("name").getAsString(); - } - } catch (Exception exception) { - System.out.println("Cannot look for updates: " + exception.getMessage()); - } - - return ""; - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/actions/Action.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/actions/Action.java deleted file mode 100644 index ff46a932a..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/actions/Action.java +++ /dev/null @@ -1,8 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.actions; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; - -public abstract class Action { - abstract public void send(MinecraftClient client, ClientPlayerEntity player); -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/actions/InteractAction.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/actions/InteractAction.java deleted file mode 100644 index be525a18a..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/actions/InteractAction.java +++ /dev/null @@ -1,33 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.actions; - -import me.aleksilassila.litematica.printer.v1_18.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_18.implementation.PrinterPlacementContext; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; - -abstract public class InteractAction extends Action { - public final PrinterPlacementContext context; - - public InteractAction(PrinterPlacementContext context) { - this.context = context; - } - - protected abstract void interact(MinecraftClient client, ClientPlayerEntity player, Hand hand, BlockHitResult hitResult); - - @Override - public void send(MinecraftClient client, ClientPlayerEntity player) { - interact(client, player, Hand.MAIN_HAND, context.hitResult); - - if (LitematicaMixinMod.DEBUG) - System.out.println("InteractAction.send: Blockpos: " + context.getBlockPos() + " Side: " + context.getSide() + " HitPos: " + context.getHitPos()); - } - - @Override - public String toString() { - return "InteractAction{" + - "context=" + context + - '}'; - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/actions/PrepareAction.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/actions/PrepareAction.java deleted file mode 100644 index af86b45a7..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/actions/PrepareAction.java +++ /dev/null @@ -1,109 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.actions; - -import me.aleksilassila.litematica.printer.v1_18.implementation.PrinterPlacementContext; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; -import net.minecraft.util.Hand; -import net.minecraft.util.math.Direction; - -public class PrepareAction extends Action { -// public final Direction lookDirection; -// public final boolean requireSneaking; -// public final Item item; - -// public PrepareAction(Direction lookDirection, boolean requireSneaking, Item item) { -// this.lookDirection = lookDirection; -// this.requireSneaking = requireSneaking; -// this.item = item; -// } -// -// public PrepareAction(Direction lookDirection, boolean requireSneaking, BlockState requiredState) { -// this(lookDirection, requireSneaking, requiredState.getBlock().asItem()); -// } - - public final PrinterPlacementContext context; - - public boolean modifyYaw = true; - public boolean modifyPitch = true; - public float yaw = 0; - public float pitch = 0; - - public PrepareAction(PrinterPlacementContext context) { - this.context = context; - - Direction lookDirection = context.lookDirection; - - if (lookDirection != null && lookDirection.getAxis().isHorizontal()) { - this.yaw = lookDirection.asRotation(); - } else { - this.modifyYaw = false; - } - - if (lookDirection == Direction.UP) { - this.pitch = -90; - } else if (lookDirection == Direction.DOWN) { - this.pitch = 90; - } else if (lookDirection != null) { - this.pitch = 0; - } else { - this.modifyPitch = false; - } - } - - public PrepareAction(PrinterPlacementContext context, float yaw, float pitch) { - this.context = context; - - this.yaw = yaw; - this.pitch = pitch; - } - - @Override - public void send(MinecraftClient client, ClientPlayerEntity player) { - ItemStack itemStack = context.getStack(); - int slot = context.requiredItemSlot; - - if (itemStack != null) { - PlayerInventory inventory = player.getInventory(); - - // This thing is straight from MinecraftClient#doItemPick() - if (player.getAbilities().creativeMode) { - inventory.addPickBlock(itemStack); - client.interactionManager.clickCreativeStack(player.getStackInHand(Hand.MAIN_HAND), 36 + inventory.selectedSlot); - } else if (slot != -1) { - if (PlayerInventory.isValidHotbarIndex(slot)) { - inventory.selectedSlot = slot; - } else { - client.interactionManager.pickFromInventory(slot); - } - } - } - - if (modifyPitch || modifyYaw) { - float yaw = modifyYaw ? this.yaw : player.getYaw(); - float pitch = modifyPitch ? this.pitch : player.getPitch(); - - PlayerMoveC2SPacket packet = new PlayerMoveC2SPacket.Full(player.getX(), player.getY(), player.getZ(), yaw, pitch, player.isOnGround()); - - player.networkHandler.sendPacket(packet); - } - - if (context.shouldSneak) { - player.input.sneaking = true; - player.networkHandler.sendPacket(new ClientCommandC2SPacket(player, ClientCommandC2SPacket.Mode.PRESS_SHIFT_KEY)); - } else { - player.input.sneaking = false; - player.networkHandler.sendPacket(new ClientCommandC2SPacket(player, ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY)); - } - } - - @Override - public String toString() { - return "PrepareAction{" + - "context=" + context + - '}'; - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/actions/ReleaseShiftAction.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/actions/ReleaseShiftAction.java deleted file mode 100644 index a771c1eb9..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/actions/ReleaseShiftAction.java +++ /dev/null @@ -1,13 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.actions; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; - -public class ReleaseShiftAction extends Action { - @Override - public void send(MinecraftClient client, ClientPlayerEntity player) { - player.input.sneaking = false; - player.networkHandler.sendPacket(new ClientCommandC2SPacket(player, ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY)); - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/Guide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/Guide.java deleted file mode 100644 index 961f04750..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/Guide.java +++ /dev/null @@ -1,130 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides; - -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_18.actions.Action; -import me.aleksilassila.litematica.printer.v1_18.implementation.BlockHelperImpl; -import net.minecraft.block.BlockState; -import net.minecraft.block.CoralBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.state.property.Properties; -import net.minecraft.state.property.Property; -import org.jetbrains.annotations.NotNull; - -import java.util.List; -import java.util.Optional; - -abstract public class Guide extends BlockHelperImpl { - protected final SchematicBlockState state; - protected final BlockState currentState; - protected final BlockState targetState; - - public Guide(SchematicBlockState state) { - this.state = state; - - this.currentState = state.currentState; - this.targetState = state.targetState; - } - - protected boolean playerHasRightItem(ClientPlayerEntity player) { - return getRequiredItemStackSlot(player) != -1; - } - - protected int getSlotWithItem(ClientPlayerEntity player, ItemStack itemStack) { - PlayerInventory inventory = player.getInventory(); - - for (int i = 0; i < inventory.main.size(); ++i) { - if (itemStack.isEmpty() && inventory.main.get(i).isOf(itemStack.getItem())) return i; - if (!inventory.main.get(i).isEmpty() && inventory.main.get(i).isItemEqual(itemStack)) { - return i; - } - } - - return -1; - } - - protected int getRequiredItemStackSlot(ClientPlayerEntity player) { - if (player.getAbilities().creativeMode) { - return player.getInventory().selectedSlot; - } - - Optional requiredItem = getRequiredItem(player); - if (requiredItem.isEmpty()) return -1; - - return getSlotWithItem(player, requiredItem.get()); - } - - public boolean canExecute(ClientPlayerEntity player) { - if (!playerHasRightItem(player)) return false; - - BlockState targetState = state.targetState; - BlockState currentState = state.currentState; - - return !statesEqual(targetState, currentState); - } - - abstract public @NotNull List execute(ClientPlayerEntity player); - - abstract protected @NotNull List getRequiredItems(); - - /** - * Returns the first required item that player has access to, - * or empty if the items are inaccessible. - */ - protected Optional getRequiredItem(ClientPlayerEntity player) { - List requiredItems = getRequiredItems(); - - for (ItemStack requiredItem : requiredItems) { - if (player.getAbilities().creativeMode) return Optional.of(requiredItem); - - int slot = getSlotWithItem(player, requiredItem); - if (slot > -1) - return Optional.of(requiredItem); - } - - return Optional.empty(); - } - - protected boolean statesEqualIgnoreProperties(BlockState state1, BlockState state2, Property... propertiesToIgnore) { - if (state1.getBlock() != state2.getBlock()) return false; - - loop: - for (Property property : state1.getProperties()) { - if (property == Properties.WATERLOGGED && !(state1.getBlock() instanceof CoralBlock)) continue; - - for (Property ignoredProperty : propertiesToIgnore) { - if (property == ignoredProperty) continue loop; - } - - try { - if (state1.get(property) != state2.get(property)) { - return false; - } - } catch (Exception e) { - return false; - } - } - - return true; - } - - protected static > Optional getProperty(BlockState blockState, Property property) { - if (blockState.contains(property)) { - return Optional.of(blockState.get(property)); - } - return Optional.empty(); - } - - /** - * Returns true if - */ - protected boolean statesEqual(BlockState state1, BlockState state2) { - return statesEqualIgnoreProperties(state1, state2); - } - - public boolean skipOtherGuides() { - return false; - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/Guides.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/Guides.java deleted file mode 100644 index f63448c1f..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/Guides.java +++ /dev/null @@ -1,81 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides; - -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_18.guides.interaction.*; -import me.aleksilassila.litematica.printer.v1_18.guides.placement.*; -import net.minecraft.block.*; -import net.minecraft.util.Pair; - -import java.util.ArrayList; - -public class Guides { - protected final static ArrayList, Class[]>> guides = new ArrayList<>(); - - @SafeVarargs - protected static void registerGuide(Class guideClass, Class... blocks) { - guides.add(new Pair<>(guideClass, blocks)); - } - - static { -// registerGuide(SkipGuide.class, AbstractSignBlock.class, SkullBlock.class, BannerBlock.class); - - registerGuide(RotatingBlockGuide.class, AbstractSkullBlock.class, AbstractSignBlock.class, AbstractBannerBlock.class); - registerGuide(SlabGuide.class, SlabBlock.class); - registerGuide(TorchGuide.class, TorchBlock.class); - registerGuide(FarmlandGuide.class, FarmlandBlock.class); - registerGuide(TillingGuide.class, FarmlandBlock.class); - registerGuide(RailGuesserGuide.class, AbstractRailBlock.class); - registerGuide(ChestGuide.class, ChestBlock.class); - registerGuide(FlowerPotGuide.class, FlowerPotBlock.class); - registerGuide(FlowerPotFillGuide.class, FlowerPotBlock.class); - - registerGuide(PropertySpecificGuesserGuide.class, - RepeaterBlock.class, ComparatorBlock.class, RedstoneWireBlock.class, RedstoneTorchBlock.class, - BambooBlock.class, CactusBlock.class, SaplingBlock.class, ScaffoldingBlock.class, PointedDripstoneBlock.class, - HorizontalConnectingBlock.class, DoorBlock.class, TrapdoorBlock.class, FenceGateBlock.class, ChestBlock.class, - SnowBlock.class, SeaPickleBlock.class, CandleBlock.class, LeverBlock.class, EndPortalFrameBlock.class, - NoteBlock.class, CampfireBlock.class, PoweredRailBlock.class, LeavesBlock.class, TripwireHookBlock.class); - registerGuide(FallingBlockGuide.class, FallingBlock.class); - registerGuide(BlockIndifferentGuesserGuide.class, BambooBlock.class, BigDripleafStemBlock.class, BigDripleafBlock.class, - TwistingVinesPlantBlock.class, TripwireBlock.class); - - registerGuide(CampfireExtinguishGuide.class, CampfireBlock.class); - registerGuide(LightCandleGuide.class, AbstractCandleBlock.class); - registerGuide(EnderEyeGuide.class, EndPortalFrameBlock.class); - registerGuide(CycleStateGuide.class, - DoorBlock.class, FenceGateBlock.class, TrapdoorBlock.class, - LeverBlock.class, - RepeaterBlock.class, ComparatorBlock.class, NoteBlock.class); - registerGuide(BlockReplacementGuide.class, SnowBlock.class, SeaPickleBlock.class, CandleBlock.class, SlabBlock.class); - registerGuide(LogGuide.class); - registerGuide(LogStrippingGuide.class); - registerGuide(GuesserGuide.class); - } - - public ArrayList, Class[]>> getGuides() { - return guides; - } - - public Guide[] getInteractionGuides(SchematicBlockState state) { - ArrayList, Class[]>> guides = getGuides(); - - ArrayList applicableGuides = new ArrayList<>(); - for (Pair, Class[]> guidePair : guides) { - try { - if (guidePair.getRight().length == 0) { - applicableGuides.add(guidePair.getLeft().getConstructor(SchematicBlockState.class).newInstance(state)); - continue; - } - - for (Class clazz : guidePair.getRight()) { - if (clazz.isInstance(state.targetState.getBlock())) { - applicableGuides.add(guidePair.getLeft().getConstructor(SchematicBlockState.class).newInstance(state)); - } - } - } catch (Exception ignored) { - } - } - - return applicableGuides.toArray(Guide[]::new); - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/SkipGuide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/SkipGuide.java deleted file mode 100644 index 984bb480e..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/SkipGuide.java +++ /dev/null @@ -1,37 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides; - -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_18.actions.Action; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class SkipGuide extends Guide { - public SkipGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - return false; - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - return new ArrayList<>(); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(ItemStack.EMPTY); - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/CampfireExtinguishGuide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/CampfireExtinguishGuide.java deleted file mode 100644 index 49eabc261..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/CampfireExtinguishGuide.java +++ /dev/null @@ -1,36 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import net.minecraft.block.CampfireBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; - -public class CampfireExtinguishGuide extends InteractionGuide { - boolean shouldBeLit; - boolean isLit; - - public CampfireExtinguishGuide(SchematicBlockState state) { - super(state); - - shouldBeLit = getProperty(targetState, CampfireBlock.LIT).orElse(false); - isLit = getProperty(currentState, CampfireBlock.LIT).orElse(false); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return (currentState.getBlock() instanceof CampfireBlock) && !shouldBeLit && isLit; - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(SHOVEL_ITEMS).map(ItemStack::new).toList(); - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/CycleStateGuide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/CycleStateGuide.java deleted file mode 100644 index 68bb63109..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/CycleStateGuide.java +++ /dev/null @@ -1,45 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.LeverBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.state.property.Properties; -import net.minecraft.state.property.Property; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class CycleStateGuide extends InteractionGuide { - private static final Property[] propertiesToIgnore = new Property[]{ - Properties.POWERED, - Properties.LIT - }; - - public CycleStateGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return targetState.getBlock() == currentState.getBlock(); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(ItemStack.EMPTY); - } - - @Override - protected boolean statesEqual(BlockState state1, BlockState state2) { - if (state2.getBlock() instanceof LeverBlock) { - return super.statesEqual(state1, state2); - } - - return statesEqualIgnoreProperties(state1, state2, propertiesToIgnore); - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/EnderEyeGuide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/EnderEyeGuide.java deleted file mode 100644 index edb4e0e1e..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/EnderEyeGuide.java +++ /dev/null @@ -1,33 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.state.property.Properties; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class EnderEyeGuide extends InteractionGuide { - public EnderEyeGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - if (currentState.contains(Properties.EYE) && targetState.contains(Properties.EYE)) { - return !currentState.get(Properties.EYE) && targetState.get(Properties.EYE); - } - - return false; - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(new ItemStack(Items.ENDER_EYE)); - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/FlowerPotFillGuide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/FlowerPotFillGuide.java deleted file mode 100644 index b4cb1bb2a..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/FlowerPotFillGuide.java +++ /dev/null @@ -1,40 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import net.minecraft.block.Block; -import net.minecraft.block.FlowerPotBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class FlowerPotFillGuide extends InteractionGuide { - private final Block content; - - public FlowerPotFillGuide(SchematicBlockState state) { - super(state); - - Block targetBlock = state.targetState.getBlock(); - if (targetBlock instanceof FlowerPotBlock) { - this.content = ((FlowerPotBlock) targetBlock).getContent(); - } else { - this.content = null; - } - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (content == null) return false; - if (!(currentState.getBlock() instanceof FlowerPotBlock)) return false; - - return super.canExecute(player); - } - - @Override - protected @NotNull List getRequiredItems() { - if (content == null) return Collections.emptyList(); - else return Collections.singletonList(new ItemStack(content)); - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/InteractionGuide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/InteractionGuide.java deleted file mode 100644 index 257a9b656..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/InteractionGuide.java +++ /dev/null @@ -1,49 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_18.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_18.actions.Action; -import me.aleksilassila.litematica.printer.v1_18.actions.PrepareAction; -import me.aleksilassila.litematica.printer.v1_18.actions.ReleaseShiftAction; -import me.aleksilassila.litematica.printer.v1_18.guides.Guide; -import me.aleksilassila.litematica.printer.v1_18.implementation.actions.InteractActionImpl; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.List; - -/** - * A guide that clicks the current block to change its state. - */ -public abstract class InteractionGuide extends Guide { - public InteractionGuide(SchematicBlockState state) { - super(state); - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - List actions = new ArrayList<>(); - - BlockHitResult hitResult = new BlockHitResult(Vec3d.ofCenter(state.blockPos), Direction.UP, state.blockPos, false); - ItemStack requiredItem = getRequiredItem(player).orElse(ItemStack.EMPTY); - int requiredSlot = getRequiredItemStackSlot(player); - - if (requiredSlot == -1) return actions; - - PrinterPlacementContext ctx = new PrinterPlacementContext(player, hitResult, requiredItem, requiredSlot); - - actions.add(new ReleaseShiftAction()); - actions.add(new PrepareAction(ctx)); - actions.add(new InteractActionImpl(ctx)); - - return actions; - } - - @Override - abstract protected @NotNull List getRequiredItems(); -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/LightCandleGuide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/LightCandleGuide.java deleted file mode 100644 index b18898b67..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/LightCandleGuide.java +++ /dev/null @@ -1,36 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import net.minecraft.block.AbstractCandleBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.state.property.Properties; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class LightCandleGuide extends InteractionGuide { - boolean shouldBeLit; - boolean isLit; - - public LightCandleGuide(SchematicBlockState state) { - super(state); - - shouldBeLit = getProperty(targetState, Properties.LIT).orElse(false); - isLit = getProperty(currentState, Properties.LIT).orElse(false); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(new ItemStack(Items.FLINT_AND_STEEL)); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return (currentState.getBlock() instanceof AbstractCandleBlock) && shouldBeLit && !isLit; - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/LogStrippingGuide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/LogStrippingGuide.java deleted file mode 100644 index 12072377a..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/LogStrippingGuide.java +++ /dev/null @@ -1,47 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_18.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_18.mixin.AxeItemAccessor; -import net.minecraft.block.Block; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -public class LogStrippingGuide extends InteractionGuide { - static final Item[] AXE_ITEMS = new Item[]{ - Items.NETHERITE_AXE, - Items.DIAMOND_AXE, - Items.GOLDEN_AXE, - Items.IRON_AXE, - Items.STONE_AXE, - Items.WOODEN_AXE - }; - - public static final Map STRIPPED_BLOCKS = AxeItemAccessor.getStrippedBlocks(); - - public LogStrippingGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!LitematicaMixinMod.STRIP_LOGS.getBooleanValue()) return false; - - if (!super.canExecute(player)) return false; - - Block strippingResult = STRIPPED_BLOCKS.get(currentState.getBlock()); - return strippingResult == targetState.getBlock(); - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(AXE_ITEMS).map(ItemStack::new).toList(); - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/TillingGuide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/TillingGuide.java deleted file mode 100644 index 1f9de3aaf..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/interaction/TillingGuide.java +++ /dev/null @@ -1,39 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_18.guides.placement.FarmlandGuide; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; - -public class TillingGuide extends InteractionGuide { - public static final Item[] HOE_ITEMS = new Item[]{ - Items.NETHERITE_HOE, - Items.DIAMOND_HOE, - Items.GOLDEN_HOE, - Items.IRON_HOE, - Items.STONE_HOE, - Items.WOODEN_HOE - }; - - public TillingGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return Arrays.stream(FarmlandGuide.TILLABLE_BLOCKS).anyMatch(b -> b == currentState.getBlock()); - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(HOE_ITEMS).map(ItemStack::new).toList(); - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/BlockIndifferentGuesserGuide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/BlockIndifferentGuesserGuide.java deleted file mode 100644 index 9f4346508..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/BlockIndifferentGuesserGuide.java +++ /dev/null @@ -1,42 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.placement; - -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import net.minecraft.block.*; - -public class BlockIndifferentGuesserGuide extends GuesserGuide { - public BlockIndifferentGuesserGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected boolean statesEqual(BlockState resultState, BlockState targetState) { - Block targetBlock = targetState.getBlock(); - Block resultBlock = resultState.getBlock(); - - if (targetBlock instanceof BambooBlock) { - return resultBlock instanceof BambooBlock || resultBlock instanceof BambooSaplingBlock; - } - - if (targetBlock instanceof BigDripleafStemBlock) { - if (resultBlock instanceof BigDripleafBlock || resultBlock instanceof BigDripleafStemBlock) { - return resultState.get(HorizontalFacingBlock.FACING) == targetState.get(HorizontalFacingBlock.FACING); - } - } - - if (targetBlock instanceof TwistingVinesPlantBlock) { - if (resultBlock instanceof TwistingVinesBlock) { - return true; - } else if (resultBlock instanceof TwistingVinesPlantBlock) { - return statesEqualIgnoreProperties(resultState, targetState, TwistingVinesBlock.AGE); - } - } - - if (targetBlock instanceof TripwireBlock && resultBlock instanceof TripwireBlock) { - return statesEqualIgnoreProperties(resultState, targetState, - TripwireBlock.ATTACHED, TripwireBlock.DISARMED, TripwireBlock.POWERED, TripwireBlock.NORTH, - TripwireBlock.EAST, TripwireBlock.SOUTH, TripwireBlock.WEST); - } - - return super.statesEqual(resultState, targetState); - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/BlockReplacementGuide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/BlockReplacementGuide.java deleted file mode 100644 index 5008698e2..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/BlockReplacementGuide.java +++ /dev/null @@ -1,75 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.placement; - -import me.aleksilassila.litematica.printer.v1_18.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import net.minecraft.block.CandleBlock; -import net.minecraft.block.SeaPickleBlock; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.SnowBlock; -import net.minecraft.block.enums.SlabType; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.state.property.IntProperty; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.Nullable; - -import java.util.HashMap; -import java.util.Optional; - -public class BlockReplacementGuide extends PlacementGuide { - private static final HashMap increasingProperties = new HashMap<>(); - - static { - increasingProperties.put(SnowBlock.LAYERS, null); - increasingProperties.put(SeaPickleBlock.PICKLES, null); - increasingProperties.put(CandleBlock.CANDLES, null); - } - - private Integer currentLevel = null; - private Integer targetLevel = null; - private IntProperty increasingProperty = null; - - public BlockReplacementGuide(SchematicBlockState state) { - super(state); - - for (IntProperty property : increasingProperties.keySet()) { - if (targetState.contains(property) && currentState.contains(property)) { - currentLevel = currentState.get(property); - targetLevel = targetState.get(property); - increasingProperty = property; - break; - } - } - } - - @Override - protected boolean getUseShift(SchematicBlockState state) { - return false; - } - - @Override - public @Nullable PrinterPlacementContext getPlacementContext(ClientPlayerEntity player) { - Optional requiredItem = getRequiredItem(player); - int slot = getRequiredItemStackSlot(player); - if (requiredItem.isEmpty() || slot == -1) return null; - - BlockHitResult hitResult = new BlockHitResult(Vec3d.ofCenter(state.blockPos), Direction.UP, state.blockPos, false); - return new PrinterPlacementContext(player, hitResult, requiredItem.get(), slot); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (getProperty(targetState, SlabBlock.TYPE).orElse(null) == SlabType.DOUBLE && getProperty(currentState, SlabBlock.TYPE).orElse(SlabType.DOUBLE) != SlabType.DOUBLE) { - return super.canExecute(player); - } - - if (currentLevel == null || targetLevel == null || increasingProperty == null) return false; - if (!statesEqualIgnoreProperties(currentState, targetState, CandleBlock.LIT, increasingProperty)) return false; - if (currentLevel >= targetLevel) return false; - - return super.canExecute(player); - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/ChestGuide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/ChestGuide.java deleted file mode 100644 index af286ed4b..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/ChestGuide.java +++ /dev/null @@ -1,92 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.placement; - -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.ChestBlock; -import net.minecraft.block.enums.ChestType; -import net.minecraft.util.math.Direction; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -/** - * Whilst making this guide, I learned that chests are much like humans. - * Some prefer to stay single, and some want to connect with another of its kind. - * Also that reversing chest connection logic is an enormous pain in the ass. I spent way too long on this. - * Thanks for coming to my ted talk - */ -public class ChestGuide extends GeneralPlacementGuide { - public ChestGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected boolean getRequiresExplicitShift() { - return true; - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - protected Optional getLookDirection() { - return getProperty(targetState, ChestBlock.FACING) - .flatMap(facing -> Optional.of(facing.getOpposite())); - } - - @Override - protected List getPossibleSides() { - ChestType targetType = getProperty(targetState, ChestBlock.CHEST_TYPE).orElse(null); - Direction targetFacing = getProperty(targetState, ChestBlock.FACING).orElse(null); - - List sides = new ArrayList<>(); - - if (targetFacing == null || targetType == null) return sides; - - for (Direction direction : Direction.values()) { - if (targetType == ChestType.SINGLE && !willConnectToSide(state, direction)) { - sides.add(direction); - } else if (wantsToConnectToSide(state, direction) && willConnectToSide(state, direction)) { // :D - sides.add(direction); - } - } - - // Place single chests if cannot connect any existing chests - if (sides.isEmpty()) { - for (Direction direction : Direction.values()) { - if (!wantsToConnectToSide(state, direction) && !willConnectToSide(state, direction)) { - sides.add(direction); - } - } - } - - return sides; - } - - private boolean willConnectToSide(SchematicBlockState state, Direction neighborDirection) { - BlockState neighbor = state.offset(neighborDirection).currentState; - ChestType neighborType = getProperty(neighbor, ChestBlock.CHEST_TYPE).orElse(null); - Direction neighborFacing = getProperty(neighbor, ChestBlock.FACING).orElse(null); - Direction facing = getProperty(state.targetState, ChestBlock.FACING).orElse(null); - - if (neighborType == null || neighborFacing == null || facing == null) return false; - - if (facing.getAxis() == neighborDirection.getAxis() || neighborDirection.getAxis() == Direction.Axis.Y) - return false; - - return neighborType == ChestType.SINGLE && neighborFacing == facing && state.targetState.getBlock() == neighbor.getBlock(); - } - - private boolean wantsToConnectToSide(SchematicBlockState state, Direction direction) { - ChestType type = getProperty(state.targetState, ChestBlock.CHEST_TYPE).orElse(null); - Direction facing = getProperty(state.targetState, ChestBlock.FACING).orElse(null); - if (type == null || facing == null || type == ChestType.SINGLE) return false; - - Direction neighborDirection = type == ChestType.LEFT ? facing.rotateYClockwise() : facing.rotateYCounterclockwise(); - - return direction == neighborDirection; - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/FlowerPotGuide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/FlowerPotGuide.java deleted file mode 100644 index a3a5e8f02..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/FlowerPotGuide.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.placement; - -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class FlowerPotGuide extends GeneralPlacementGuide { - public FlowerPotGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(new ItemStack(Items.FLOWER_POT)); - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/GeneralPlacementGuide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/GeneralPlacementGuide.java deleted file mode 100644 index 269bc2440..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/GeneralPlacementGuide.java +++ /dev/null @@ -1,119 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.placement; - -import me.aleksilassila.litematica.printer.v1_18.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.enums.SlabType; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -/** - * An old school guide where there are defined specific conditions - * for player state depending on the block being placed. - */ -public class GeneralPlacementGuide extends PlacementGuide { - public GeneralPlacementGuide(SchematicBlockState state) { - super(state); - } - - protected List getPossibleSides() { - return Arrays.asList(Direction.values()); - } - - protected Optional getLookDirection() { - return Optional.empty(); - } - - protected boolean getRequiresSupport() { - return false; - } - - protected boolean getRequiresExplicitShift() { - return false; - } - - protected Vec3d getHitModifier(Direction validSide) { - return new Vec3d(0, 0, 0); - } - - private Optional getValidSide(SchematicBlockState state) { - boolean printInAir = false; // LitematicaMixinMod.PRINT_IN_AIR.getBooleanValue(); - - List sides = getPossibleSides(); - - if (sides.isEmpty()) { - return Optional.empty(); - } - - List validSides = new ArrayList<>(); - for (Direction side : sides) { - if (printInAir && !getRequiresSupport()) { - return Optional.of(side); - } else { - SchematicBlockState neighborState = state.offset(side); - - if (getProperty(neighborState.currentState, SlabBlock.TYPE).orElse(null) == SlabType.DOUBLE) { - validSides.add(side); - continue; - } - - if (canBeClicked(neighborState.world, neighborState.blockPos) && // Handle unclickable grass for example - !neighborState.currentState.getMaterial().isReplaceable()) - validSides.add(side); - } - } - - for (Direction validSide : validSides) { - if (!isInteractive(state.offset(validSide).currentState.getBlock())) { - return Optional.of(validSide); - } - } - - return validSides.isEmpty() ? Optional.empty() : Optional.of(validSides.get(0)); - } - - protected boolean getUseShift(SchematicBlockState state) { - if (getRequiresExplicitShift()) return true; - - Direction clickSide = getValidSide(state).orElse(null); - if (clickSide == null) return false; - return isInteractive(state.offset(clickSide).currentState.getBlock()); - } - - private Optional getHitVector(SchematicBlockState state) { - return getValidSide(state).map(side -> Vec3d.ofCenter(state.blockPos) - .add(Vec3d.of(side.getVector()).multiply(0.5)) - .add(getHitModifier(side))); - } - - @Nullable - public PrinterPlacementContext getPlacementContext(ClientPlayerEntity player) { - try { - Optional validSide = getValidSide(state); - Optional hitVec = getHitVector(state); - Optional requiredItem = getRequiredItem(player); - int requiredSlot = getRequiredItemStackSlot(player); - - if (validSide.isEmpty() || hitVec.isEmpty() || requiredItem.isEmpty() || requiredSlot == -1) return null; - - Optional lookDirection = getLookDirection(); - boolean requiresShift = getUseShift(state); - - BlockHitResult blockHitResult = new BlockHitResult(hitVec.get(), validSide.get().getOpposite(), state.blockPos.offset(validSide.get()), false); - - return new PrinterPlacementContext(player, blockHitResult, requiredItem.get(), requiredSlot, lookDirection.orElse(null), requiresShift); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/GuesserGuide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/GuesserGuide.java deleted file mode 100644 index 44850f470..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/GuesserGuide.java +++ /dev/null @@ -1,110 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.placement; - -import me.aleksilassila.litematica.printer.v1_18.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_18.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.ChestBlock; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.enums.ChestType; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.Nullable; - -/** - * This is the placement guide that most blocks will use. - * It will try to predict the correct player state for producing the right blockState - * by brute forcing the correct hit vector and look direction. - */ -public class GuesserGuide extends GeneralPlacementGuide { - private PrinterPlacementContext contextCache = null; - - protected static Direction[] directionsToTry = new Direction[]{ - Direction.NORTH, - Direction.SOUTH, - Direction.EAST, - Direction.WEST, - Direction.UP, - Direction.DOWN - }; - protected static Vec3d[] hitVecsToTry = new Vec3d[]{ - new Vec3d(-0.25, -0.25, -0.25), - new Vec3d(+0.25, -0.25, -0.25), - new Vec3d(-0.25, +0.25, -0.25), - new Vec3d(-0.25, -0.25, +0.25), - new Vec3d(+0.25, +0.25, -0.25), - new Vec3d(-0.25, +0.25, +0.25), - new Vec3d(+0.25, -0.25, +0.25), - new Vec3d(+0.25, +0.25, +0.25), - }; - - public GuesserGuide(SchematicBlockState state) { - super(state); - } - - @Nullable - @Override - public PrinterPlacementContext getPlacementContext(ClientPlayerEntity player) { - if (contextCache != null && !LitematicaMixinMod.DEBUG) return contextCache; - - ItemStack requiredItem = getRequiredItem(player).orElse(ItemStack.EMPTY); - int slot = getRequiredItemStackSlot(player); - - if (slot == -1) return null; - - for (Direction lookDirection : directionsToTry) { - for (Direction side : directionsToTry) { - BlockPos neighborPos = state.blockPos.offset(side); - BlockState neighborState = state.world.getBlockState(neighborPos); - boolean requiresShift = getRequiresExplicitShift() || isInteractive(neighborState.getBlock()); - - if (!canBeClicked(state.world, neighborPos) || // Handle unclickable grass for example - neighborState.getMaterial().isReplaceable()) - continue; - - Vec3d hitVec = Vec3d.ofCenter(state.blockPos) - .add(Vec3d.of(side.getVector()).multiply(0.5)); - - for (Vec3d hitVecToTry : hitVecsToTry) { - Vec3d multiplier = Vec3d.of(side.getVector()); - multiplier = new Vec3d(multiplier.x == 0 ? 1 : 0, multiplier.y == 0 ? 1 : 0, multiplier.z == 0 ? 1 : 0); - - BlockHitResult hitResult = new BlockHitResult(hitVec.add(hitVecToTry.multiply(multiplier)), side.getOpposite(), neighborPos, false); - PrinterPlacementContext context = new PrinterPlacementContext(player, hitResult, requiredItem, slot, lookDirection, requiresShift); - BlockState result = getRequiredItemAsBlock(player) - .orElse(targetState.getBlock()) - .getPlacementState(context); // FIXME torch shift clicks another torch and getPlacementState is the clicked block, which is true - - if (result != null && (statesEqual(result, targetState) || correctChestPlacement(targetState, result))) { - contextCache = context; - return context; - } - } - } - } - - return null; - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (targetState.getBlock() instanceof SlabBlock) return false; // Slabs are a special case - - return super.canExecute(player); - } - - private boolean correctChestPlacement(BlockState targetState, BlockState result) { - if (targetState.contains(ChestBlock.CHEST_TYPE) && result.contains(ChestBlock.CHEST_TYPE) && result.get(ChestBlock.FACING) == targetState.get(ChestBlock.FACING)) { - ChestType targetChestType = targetState.get(ChestBlock.CHEST_TYPE); - ChestType resultChestType = result.get(ChestBlock.CHEST_TYPE); - - return targetChestType != ChestType.SINGLE && resultChestType == ChestType.SINGLE; - } - - return false; - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/LogGuide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/LogGuide.java deleted file mode 100644 index b00aeaa7e..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/LogGuide.java +++ /dev/null @@ -1,54 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.placement; - -import me.aleksilassila.litematica.printer.v1_18.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_18.guides.interaction.LogStrippingGuide; -import net.minecraft.block.Block; -import net.minecraft.block.PillarBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.Direction; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -public class LogGuide extends GeneralPlacementGuide { - public LogGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - if (targetState.contains(PillarBlock.AXIS)) { - Direction.Axis axis = targetState.get(PillarBlock.AXIS); - return Arrays.stream(Direction.values()).filter(d -> d.getAxis() == axis).toList(); - } - - return new ArrayList<>(); - } - - @Override - protected @NotNull List getRequiredItems() { - for (Block log : LogStrippingGuide.STRIPPED_BLOCKS.keySet()) { - if (targetState.getBlock() == LogStrippingGuide.STRIPPED_BLOCKS.get(log)) { - return Collections.singletonList(new ItemStack(log)); - } - } - - return super.getRequiredItems(); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!LitematicaMixinMod.STRIP_LOGS.getBooleanValue()) return false; - - if (LogStrippingGuide.STRIPPED_BLOCKS.containsValue(targetState.getBlock())) { - return super.canExecute(player); - } - - return false; - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/PlacementGuide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/PlacementGuide.java deleted file mode 100644 index f5d8ff136..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/PlacementGuide.java +++ /dev/null @@ -1,138 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.placement; - -import me.aleksilassila.litematica.printer.v1_18.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_18.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_18.actions.Action; -import me.aleksilassila.litematica.printer.v1_18.actions.PrepareAction; -import me.aleksilassila.litematica.printer.v1_18.actions.ReleaseShiftAction; -import me.aleksilassila.litematica.printer.v1_18.guides.Guide; -import me.aleksilassila.litematica.printer.v1_18.implementation.actions.InteractActionImpl; -import net.minecraft.block.*; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.World; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -/** - * Guide that clicks its neighbors to create a placement in target position. - */ -abstract public class PlacementGuide extends Guide { - public PlacementGuide(SchematicBlockState state) { - super(state); - } - - protected ItemStack getBlockItem(BlockState state) { - return state.getBlock().getPickStack(this.state.world, this.state.blockPos, state); - } - - protected Optional getRequiredItemAsBlock(ClientPlayerEntity player) { - Optional requiredItem = getRequiredItem(player); - - if (requiredItem.isEmpty()) { - return Optional.empty(); - } else { - ItemStack itemStack = requiredItem.get(); - - if (itemStack.getItem() instanceof BlockItem) - return Optional.of(((BlockItem) itemStack.getItem()).getBlock()); - else return Optional.empty(); - } - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(getBlockItem(state.targetState)); - } - - abstract protected boolean getUseShift(SchematicBlockState state); - - @Nullable - abstract public PrinterPlacementContext getPlacementContext(ClientPlayerEntity player); - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - List requiredItems = getRequiredItems(); - if (requiredItems.isEmpty() || requiredItems.stream().allMatch(i -> i.isOf(Items.AIR))) - return false; - - ItemPlacementContext ctx = getPlacementContext(player); - if (ctx == null || !ctx.canPlace()) return false; -// if (!state.currentState.getMaterial().isReplaceable()) return false; - if (!LitematicaMixinMod.REPLACE_FLUIDS_SOURCE_BLOCKS.getBooleanValue() - && getProperty(state.currentState, FluidBlock.LEVEL).orElse(1) == 0) - return false; - - BlockState resultState = getRequiredItemAsBlock(player) - .orElse(targetState.getBlock()) - .getPlacementState(ctx); - - if (resultState != null) { - if (!resultState.canPlaceAt(state.world, state.blockPos)) return false; - return !(currentState.getBlock() instanceof FluidBlock) || canPlaceInWater(resultState); - } else { - return false; - } - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - List actions = new ArrayList<>(); - PrinterPlacementContext ctx = getPlacementContext(player); - - if (ctx == null) return actions; - actions.add(new PrepareAction(ctx)); - actions.add(new InteractActionImpl(ctx)); - if (ctx.shouldSneak) actions.add(new ReleaseShiftAction()); - - return actions; - } - - protected static boolean canBeClicked(World world, BlockPos pos) { - return getOutlineShape(world, pos) != VoxelShapes.empty() && !(world.getBlockState(pos).getBlock() instanceof AbstractSignBlock); // FIXME signs - } - - private static VoxelShape getOutlineShape(World world, BlockPos pos) { - return world.getBlockState(pos).getOutlineShape(world, pos); - } - - public boolean isInteractive(Block block) { - for (Class clazz : interactiveBlocks) { - if (clazz.isInstance(block)) { - return true; - } - } - - return false; - } - - private boolean canPlaceInWater(BlockState blockState) { - Block block = blockState.getBlock(); - if (block instanceof FluidFillable) { - return true; - } else if (!(block instanceof DoorBlock) && !(blockState.getBlock() instanceof AbstractSignBlock) && !blockState.isOf(Blocks.LADDER) && !blockState.isOf(Blocks.SUGAR_CANE) && !blockState.isOf(Blocks.BUBBLE_COLUMN)) { - Material material = blockState.getMaterial(); - if (material != Material.PORTAL && material != Material.STRUCTURE_VOID && material != Material.UNDERWATER_PLANT && material != Material.REPLACEABLE_UNDERWATER_PLANT) { - return material.blocksMovement(); - } else { - return true; - } - } - - return true; - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/PropertySpecificGuesserGuide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/PropertySpecificGuesserGuide.java deleted file mode 100644 index 2e1c50ae8..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/PropertySpecificGuesserGuide.java +++ /dev/null @@ -1,52 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.placement; - -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import net.minecraft.block.*; -import net.minecraft.state.property.Properties; -import net.minecraft.state.property.Property; - -public class PropertySpecificGuesserGuide extends GuesserGuide { - protected static Property[] ignoredProperties = new Property[]{ - RepeaterBlock.DELAY, - ComparatorBlock.MODE, - RedstoneWireBlock.POWER, - RedstoneWireBlock.WIRE_CONNECTION_EAST, - RedstoneWireBlock.WIRE_CONNECTION_NORTH, - RedstoneWireBlock.WIRE_CONNECTION_SOUTH, - RedstoneWireBlock.WIRE_CONNECTION_WEST, - Properties.POWERED, - Properties.OPEN, - PointedDripstoneBlock.THICKNESS, - ScaffoldingBlock.DISTANCE, - ScaffoldingBlock.BOTTOM, - CactusBlock.AGE, - BambooBlock.AGE, - BambooBlock.LEAVES, - BambooBlock.STAGE, - SaplingBlock.STAGE, - HorizontalConnectingBlock.EAST, - HorizontalConnectingBlock.NORTH, - HorizontalConnectingBlock.SOUTH, - HorizontalConnectingBlock.WEST, - SnowBlock.LAYERS, - SeaPickleBlock.PICKLES, - CandleBlock.CANDLES, - EndPortalFrameBlock.EYE, - Properties.LIT, - LeavesBlock.DISTANCE, - LeavesBlock.PERSISTENT, - Properties.ATTACHED, - Properties.NOTE, - Properties.INSTRUMENT, - - }; - - public PropertySpecificGuesserGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected boolean statesEqual(BlockState resultState, BlockState targetState) { - return statesEqualIgnoreProperties(resultState, targetState, ignoredProperties); - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/RailGuesserGuide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/RailGuesserGuide.java deleted file mode 100644 index 5cd95325c..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/RailGuesserGuide.java +++ /dev/null @@ -1,128 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.placement; - -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.enums.RailShape; -import net.minecraft.state.property.Properties; -import net.minecraft.util.math.Direction; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -public class RailGuesserGuide extends GuesserGuide { - static final RailShape[] STRAIGHT_RAIL_SHAPES = new RailShape[]{ - RailShape.NORTH_SOUTH, - RailShape.EAST_WEST - }; - - public RailGuesserGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - protected boolean statesEqual(BlockState resultState, BlockState targetState) { - if (!wouldConnectCorrectly()) return false; -// if (wouldBlockAnotherConnection()) return false; - /*TODO: Fully working rail guesser - * If has a neighbor that: - * - Has not been placed yet - * - OR Has been placed but can change shape - * - AND this placement should connect to only one rail, that is not the neighbor - * Then return false - * */ - - if (getRailShape(resultState).isPresent()) { - if (Arrays.stream(STRAIGHT_RAIL_SHAPES).anyMatch(shape -> shape == getRailShape(resultState).orElse(null))) { - return super.statesEqualIgnoreProperties(resultState, targetState, Properties.RAIL_SHAPE, Properties.STRAIGHT_RAIL_SHAPE, Properties.POWERED); - } - } - - return super.statesEqual(resultState, targetState); - } - - private boolean wouldConnectCorrectly() { - RailShape targetShape = getRailShape(state.targetState).orElse(null); - if (targetShape == null) return false; - - List allowedConnections = getRailDirections(targetShape); - - List possibleConnections = new ArrayList<>(); - for (Direction d : Direction.values()) { - if (d.getAxis().isVertical()) continue; - SchematicBlockState neighbor = state.offset(d); - - if (hasFreeConnections(neighbor)) { - possibleConnections.add(d); - } - } - - if (possibleConnections.size() > 2) return false; - - return allowedConnections.containsAll(possibleConnections); - } - -// private boolean wouldBlockAnotherConnection() { -// List possibleConnections = new ArrayList<>(); -// -// for (Direction d : Direction.values()) { -// if (d.getAxis().isVertical()) continue; -// SchematicBlockState neighbor = state.offset(d); -// -// if (couldConnectWrongly(neighbor)) { -// possibleConnections.add(d); -// } -// } -// -// return possibleConnections.size() > 1; -// } - - private boolean hasFreeConnections(SchematicBlockState state) { - List possibleConnections = getRailDirections(state); - if (possibleConnections.isEmpty()) return false; - - for (Direction d : possibleConnections) { - SchematicBlockState neighbor = state.offset(d); - if (neighbor.currentState.getBlock() != neighbor.currentState.getBlock()) { - return false; - } - } - - return possibleConnections.stream().anyMatch(possibleDirection -> { - SchematicBlockState neighbor = state.offset(possibleDirection); - return !getRailDirections(neighbor).contains(possibleDirection.getOpposite()); - }); - } - - private List getRailDirections(SchematicBlockState state) { - RailShape shape = getRailShape(state.currentState).orElse(null); - if (shape == null) return new ArrayList<>(); - - return getRailDirections(shape); - } - - private List getRailDirections(RailShape railShape) { - String name = railShape.getName(); - - if (railShape.isAscending()) { - Direction d = Direction.valueOf(name.replace("ascending_", "").toUpperCase()); - return Arrays.asList(d, d.getOpposite()); - } else { - Direction d1 = Direction.valueOf(name.split("_")[0].toUpperCase()); - Direction d2 = Direction.valueOf(name.split("_")[1].toUpperCase()); - return Arrays.asList(d1, d2); - } - } - - Optional getRailShape(BlockState state) { - Optional shape = getProperty(state, Properties.RAIL_SHAPE); - if (shape.isEmpty()) return getProperty(state, Properties.STRAIGHT_RAIL_SHAPE); - return shape; - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/RotatingBlockGuide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/RotatingBlockGuide.java deleted file mode 100644 index 0f9715276..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/RotatingBlockGuide.java +++ /dev/null @@ -1,58 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.placement; - -import me.aleksilassila.litematica.printer.v1_18.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_18.actions.Action; -import me.aleksilassila.litematica.printer.v1_18.actions.PrepareAction; -import net.minecraft.block.*; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.state.property.Properties; -import net.minecraft.util.math.Direction; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -public class RotatingBlockGuide extends GeneralPlacementGuide { - public RotatingBlockGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - Block block = state.targetState.getBlock(); - if (block instanceof WallSkullBlock || block instanceof WallSignBlock || block instanceof WallBannerBlock) { - Optional side = getProperty(state.targetState, Properties.HORIZONTAL_FACING).map(Direction::getOpposite); - return side.map(Collections::singletonList).orElseGet(Collections::emptyList); - } - - return Collections.singletonList(Direction.DOWN); - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - PrinterPlacementContext ctx = getPlacementContext(player); - - if (ctx == null) return new ArrayList<>(); - - int rotation = getProperty(state.targetState, Properties.ROTATION).orElse(0); - if (targetState.getBlock() instanceof BannerBlock || targetState.getBlock() instanceof SignBlock) { - rotation = (rotation + 8) % 16; - } - - int distTo0 = rotation > 8 ? 16 - rotation : rotation; - float yaw = Math.round(distTo0 / 8f * 180f * (rotation > 8 ? -1 : 1)); - - List actions = super.execute(player); - actions.set(0, new PrepareAction(ctx, yaw, 0)); - - return actions; - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/SlabGuide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/SlabGuide.java deleted file mode 100644 index dcdea76c2..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/SlabGuide.java +++ /dev/null @@ -1,48 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.placement; - -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.enums.SlabType; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; - -import java.util.Arrays; -import java.util.List; - -public class SlabGuide extends GeneralPlacementGuide { - public SlabGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - return Arrays.stream(Direction.values()) - .filter(d -> d != (getRequiredHalf(state).getOpposite()) && - getProperty(state.offset(d).currentState, SlabBlock.TYPE).orElse(SlabType.DOUBLE) == SlabType.DOUBLE) - .toList(); - } - - @Override - protected Vec3d getHitModifier(Direction validSide) { - Direction requiredHalf = getRequiredHalf(state); - if (validSide.getHorizontal() != -1) { - return new Vec3d(0, requiredHalf.getOffsetY() * 0.25, 0); - } else { - return new Vec3d(0, 0, 0); - } - } - - private Direction getRequiredHalf(SchematicBlockState state) { - BlockState targetState = state.targetState; - BlockState currentState = state.currentState; - - if (!currentState.contains(SlabBlock.TYPE)) { - return targetState.get(SlabBlock.TYPE) == SlabType.TOP ? Direction.UP : Direction.DOWN; - } else if (currentState.get(SlabBlock.TYPE) != targetState.get(SlabBlock.TYPE)) { - return currentState.get(SlabBlock.TYPE) == SlabType.TOP ? Direction.DOWN : Direction.UP; - } else { - return Direction.DOWN; - } - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/TorchGuide.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/TorchGuide.java deleted file mode 100644 index e1b42751d..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/guides/placement/TorchGuide.java +++ /dev/null @@ -1,31 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.guides.placement; - -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import net.minecraft.block.Block; -import net.minecraft.block.HorizontalFacingBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.math.Direction; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -public class TorchGuide extends GeneralPlacementGuide { - public TorchGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - Optional facing = getProperty(targetState, HorizontalFacingBlock.FACING); - - return facing - .map(direction -> Collections.singletonList(direction.getOpposite())) - .orElseGet(() -> Collections.singletonList(Direction.DOWN)); - } - - @Override - protected Optional getRequiredItemAsBlock(ClientPlayerEntity player) { - return Optional.of(state.targetState.getBlock()); - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/implementation/BlockHelperImpl.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/implementation/BlockHelperImpl.java deleted file mode 100644 index d5c738f56..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/implementation/BlockHelperImpl.java +++ /dev/null @@ -1,14 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.implementation; - -import me.aleksilassila.litematica.printer.v1_18.BlockHelper; -import net.minecraft.block.AbstractButtonBlock; - -import java.util.Arrays; - -public class BlockHelperImpl extends BlockHelper { - static { - interactiveBlocks.addAll(Arrays.asList( - AbstractButtonBlock.class - )); - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/implementation/PrinterPlacementContext.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/implementation/PrinterPlacementContext.java deleted file mode 100644 index 08546f646..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/implementation/PrinterPlacementContext.java +++ /dev/null @@ -1,59 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.implementation; - -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import org.jetbrains.annotations.Nullable; - -public class PrinterPlacementContext extends ItemPlacementContext { - public final @Nullable Direction lookDirection; - public final boolean shouldSneak; - public final BlockHitResult hitResult; - public final int requiredItemSlot; - - public PrinterPlacementContext(PlayerEntity player, BlockHitResult hitResult, ItemStack requiredItem, int requiredItemSlot) { - this(player, hitResult, requiredItem, requiredItemSlot, null, false); - } - - public PrinterPlacementContext(PlayerEntity player, BlockHitResult hitResult, ItemStack requiredItem, int requiredItemSlot, @Nullable Direction lookDirection, boolean requiresSneaking) { - super(player, Hand.MAIN_HAND, requiredItem, hitResult); - - this.lookDirection = lookDirection; - this.shouldSneak = requiresSneaking; - this.hitResult = hitResult; - this.requiredItemSlot = requiredItemSlot; - } - - @Override - public Direction getPlayerLookDirection() { - return lookDirection == null ? super.getPlayerLookDirection() : lookDirection; - } - - @Override - public Direction getVerticalPlayerLookDirection() { - if (lookDirection != null && lookDirection.getOpposite() == super.getVerticalPlayerLookDirection()) - return lookDirection; - return super.getVerticalPlayerLookDirection(); - } - - @Override - public Direction getPlayerFacing() { - if (lookDirection == null || !lookDirection.getAxis().isHorizontal()) return super.getPlayerFacing(); - - return lookDirection; - } - - @Override - public String toString() { - return "PrinterPlacementContext{" + - "lookDirection=" + lookDirection + - ", requiresSneaking=" + shouldSneak + - ", blockPos=" + hitResult.getBlockPos() + - ", side=" + hitResult.getSide() + -// ", hitVec=" + hitResult + - '}'; - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/implementation/actions/InteractActionImpl.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/implementation/actions/InteractActionImpl.java deleted file mode 100644 index b4564dc63..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/implementation/actions/InteractActionImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.implementation.actions; - -import me.aleksilassila.litematica.printer.v1_18.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_18.actions.InteractAction; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; - -public class InteractActionImpl extends InteractAction { - public InteractActionImpl(PrinterPlacementContext context) { - super(context); - } - - @Override - protected void interact(MinecraftClient client, ClientPlayerEntity player, Hand hand, BlockHitResult hitResult) { - client.interactionManager.interactBlock(player, client.world, hand, hitResult); - client.interactionManager.interactItem(player, client.world, hand); - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/implementation/mixin/MixinClientPlayerEntity.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/implementation/mixin/MixinClientPlayerEntity.java deleted file mode 100644 index 89ca9c74a..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/implementation/mixin/MixinClientPlayerEntity.java +++ /dev/null @@ -1,103 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.implementation.mixin; - -import com.mojang.authlib.GameProfile; -import fi.dy.masa.litematica.world.SchematicWorldHandler; -import fi.dy.masa.litematica.world.WorldSchematic; -import me.aleksilassila.litematica.printer.v1_18.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_18.Printer; -import me.aleksilassila.litematica.printer.v1_18.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_18.UpdateChecker; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.block.entity.SignBlockEntity; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.AbstractClientPlayerEntity; -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.network.MessageType; -import net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket; -import net.minecraft.text.LiteralText; -import org.spongepowered.asm.mixin.Mixin; -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; - -import java.util.Optional; - -@Mixin(ClientPlayerEntity.class) -public class MixinClientPlayerEntity extends AbstractClientPlayerEntity { - private static boolean didCheckForUpdates = false; - - public MixinClientPlayerEntity(ClientWorld world, GameProfile profile) { - super(world, profile); - } - - @Shadow - protected MinecraftClient client; - @Shadow - public ClientPlayNetworkHandler networkHandler; - - @Inject(at = @At("TAIL"), method = "tick") - public void tick(CallbackInfo ci) { - ClientPlayerEntity clientPlayer = (ClientPlayerEntity) (Object) this; - if (!didCheckForUpdates) { - didCheckForUpdates = true; - - checkForUpdates(); - } - - if (LitematicaMixinMod.printer == null || LitematicaMixinMod.printer.player != clientPlayer) { - System.out.println("Initializing printer, player: " + clientPlayer + ", client: " + client); - LitematicaMixinMod.printer = new Printer(client, clientPlayer); - } - - // Dirty optimization - boolean didFindPlacement = true; - for (int i = 0; i < 10; i++) { - if (didFindPlacement) { - didFindPlacement = LitematicaMixinMod.printer.onGameTick(); - } - LitematicaMixinMod.printer.actionHandler.onGameTick(); - } - } - - public void checkForUpdates() { - new Thread(() -> { - String version = UpdateChecker.version; - String newVersion = UpdateChecker.getPrinterVersion(); - - if (!version.equals(newVersion)) { - client.inGameHud.addChatMessage(MessageType.SYSTEM, - new LiteralText("New version of Litematica Printer available in https://github.com/aleksilassila/litematica-printer/releases"), - null); - } - }).start(); - } - - @Inject(method = "openEditSignScreen", at = @At("HEAD"), cancellable = true) - public void openEditSignScreen(SignBlockEntity sign, CallbackInfo ci) { - getTargetSignEntity(sign).ifPresent(signBlockEntity -> { - UpdateSignC2SPacket packet = new UpdateSignC2SPacket(sign.getPos(), - signBlockEntity.getTextOnRow(0, false).getString(), - signBlockEntity.getTextOnRow(1, false).getString(), - signBlockEntity.getTextOnRow(2, false).getString(), - signBlockEntity.getTextOnRow(3, false).getString()); - this.networkHandler.sendPacket(packet); - ci.cancel(); - }); - } - - private Optional getTargetSignEntity(SignBlockEntity sign) { - WorldSchematic worldSchematic = SchematicWorldHandler.getSchematicWorld(); - SchematicBlockState state = new SchematicBlockState(sign.getWorld(), worldSchematic, sign.getPos()); - - BlockEntity targetBlockEntity = worldSchematic.getBlockEntity(state.blockPos); - - if (targetBlockEntity instanceof SignBlockEntity targetSignEntity) { - return Optional.of(targetSignEntity); - } - - return Optional.empty(); - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/mixin/AxeItemAccessor.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/mixin/AxeItemAccessor.java deleted file mode 100644 index 8f9ed9b40..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/mixin/AxeItemAccessor.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.mixin; - -import net.minecraft.block.Block; -import net.minecraft.item.AxeItem; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.util.Map; - -/** - * This class apparently fixes an issue with Quilt. - */ -@Mixin(AxeItem.class) -public interface AxeItemAccessor { - @Accessor("STRIPPED_BLOCKS") - static Map getStrippedBlocks() { - throw new AssertionError("Untransformed @Accessor"); - } - -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/mixin/ConfigsMixin.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/mixin/ConfigsMixin.java deleted file mode 100644 index 1451f042f..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/mixin/ConfigsMixin.java +++ /dev/null @@ -1,35 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.mixin; - -import com.google.common.collect.ImmutableList; -import fi.dy.masa.litematica.config.Configs; -import fi.dy.masa.malilib.config.IConfigBase; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import me.aleksilassila.litematica.printer.v1_18.LitematicaMixinMod; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.List; - -@Mixin(value = Configs.class, remap = false) -public class ConfigsMixin { - @Redirect(method = "loadFromFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Configs$Generic;OPTIONS:Lcom/google/common/collect/ImmutableList;")) - private static ImmutableList moreOptions() { - return LitematicaMixinMod.getConfigList(); - } - - @Redirect(method = "saveToFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Configs$Generic;OPTIONS:Lcom/google/common/collect/ImmutableList;")) - private static ImmutableList moreeOptions() { - return LitematicaMixinMod.getConfigList(); - } - - @Redirect(method = "loadFromFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private static List moreHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } - - @Redirect(method = "saveToFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private static List moreeHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/mixin/GuiConfigsMixin.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/mixin/GuiConfigsMixin.java deleted file mode 100644 index cc7fe9e97..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/mixin/GuiConfigsMixin.java +++ /dev/null @@ -1,61 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.mixin; - -import com.google.common.collect.ImmutableList; -import fi.dy.masa.litematica.gui.GuiConfigs; -import fi.dy.masa.malilib.config.IConfigBase; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import me.aleksilassila.litematica.printer.v1_18.LitematicaMixinMod; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.List; - -@Mixin(value = GuiConfigs.class, remap = false) -public class GuiConfigsMixin { - - /*@Overwrite - public List getConfigs() - { - List configs; - ConfigGuiTab tab = DataManager.getConfigGuiTab(); - - if (tab == ConfigGuiTab.GENERIC) - { - configs = LitematicaMixinMod.betterConfigList; - } - else if (tab == ConfigGuiTab.INFO_OVERLAYS) - { - configs = Configs.InfoOverlays.OPTIONS; - } - else if (tab == ConfigGuiTab.VISUALS) - { - configs = Configs.Visuals.OPTIONS; - } - else if (tab == ConfigGuiTab.COLORS) - { - configs = Configs.Colors.OPTIONS; - } - else if (tab == ConfigGuiTab.HOTKEYS) - { - configs = LitematicaMixinMod.betterHotkeyList; - } - else - { - return Collections.emptyList(); - } - - return ConfigOptionWrapper.createFor(configs); - }*/ - - - @Redirect(method = "getConfigs", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Configs$Generic;OPTIONS:Lcom/google/common/collect/ImmutableList;")) - private ImmutableList moreOptions() { - return LitematicaMixinMod.getConfigList(); - } - - @Redirect(method = "getConfigs", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private List moreHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } -} diff --git a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/mixin/PlayerMoveC2SPacketMixin.java b/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/mixin/PlayerMoveC2SPacketMixin.java deleted file mode 100644 index e571ef44e..000000000 --- a/v1_18/src/main/java/me/aleksilassila/litematica/printer/v1_18/mixin/PlayerMoveC2SPacketMixin.java +++ /dev/null @@ -1,36 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_18.mixin; - -import me.aleksilassila.litematica.printer.v1_18.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_18.Printer; -import me.aleksilassila.litematica.printer.v1_18.actions.PrepareAction; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; - -@Mixin(PlayerMoveC2SPacket.class) -public class PlayerMoveC2SPacketMixin { - @ModifyVariable(method = "(DDDFFZZZ)V", at = @At("HEAD"), ordinal = 0) - private static float modifyLookYaw(float yaw) { - Printer printer = LitematicaMixinMod.printer; - if (printer == null) return yaw; - - PrepareAction action = printer.actionHandler.lookAction; - if (action != null && action.modifyYaw) { - if (LitematicaMixinMod.DEBUG) System.out.println("YAW: " + action.yaw); - return action.yaw; - } else return yaw; - } - - @ModifyVariable(method = "(DDDFFZZZ)V", at = @At("HEAD"), ordinal = 1) - private static float modifyLookPitch(float pitch) { - Printer printer = LitematicaMixinMod.printer; - if (printer == null) return pitch; - - PrepareAction action = printer.actionHandler.lookAction; - if (action != null && action.modifyPitch) { - if (LitematicaMixinMod.DEBUG) System.out.println("PITCH: " + action.pitch); - return action.pitch; - } else return pitch; - } -} diff --git a/v1_18/src/main/resources/fabric.mod.json b/v1_18/src/main/resources/fabric.mod.json deleted file mode 100644 index 69b73dda3..000000000 --- a/v1_18/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "schemaVersion": 1, - "id": "litematica_printer", - "version": "${version}", - "name": "Litematica Printer", - "description": "A fork of Litematica that adds the missing printer functionality", - "authors": [ - "aleksilassila" - ], - "contact": { - "homepage": "https://github.com/aleksilassila/litematica-printer", - "sources": "https://github.com/aleksilassila/litematica-printer" - }, - "license": "CC0-1.0", - "icon": "assets/modid/icon.png", - "environment": "*", - "entrypoints": { - "main": [ - "me.aleksilassila.litematica.printer.v1_18.LitematicaMixinMod" - ] - }, - "mixins": [ - "litematica-printer.mixins.json", - "litematica-printer-implementation.mixins.json" - ], - "depends": { - "fabricloader": ">=0.11.3", - "fabric": "*", - "minecraft": "1.18.x", - "java": ">=17" - }, - "custom": { - "modmenu": { - "parent": "carpet" - } - } -} diff --git a/v1_18/src/main/resources/litematica-printer.mixins.json b/v1_18/src/main/resources/litematica-printer.mixins.json deleted file mode 100644 index fd416ba80..000000000 --- a/v1_18/src/main/resources/litematica-printer.mixins.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "me.aleksilassila.litematica.printer.v1_18.mixin", - "compatibilityLevel": "JAVA_16", - "mixins": [ - ], - "client": [ - "ConfigsMixin", - "GuiConfigsMixin", - "InputHandlerMixin", - "PlayerMoveC2SPacketMixin", - "AxeItemAccessor" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/v1_18/src/main/resources/modid/icon.png b/v1_18/src/main/resources/modid/icon.png deleted file mode 100644 index 047b91f2347de5cf95f23284476fddbe21ba23fe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 453 zcmV;$0XqJPP)QAFYGys`80vegN0XDFh0OXKz&i8?Le#x7{1X)R+00000NkvXXu0mjf73i~T diff --git a/v1_19/build.gradle.kts b/v1_19/build.gradle.kts deleted file mode 100644 index 9c6f36262..000000000 --- a/v1_19/build.gradle.kts +++ /dev/null @@ -1,88 +0,0 @@ -plugins { - id("fabric-loom").version("1.0-SNAPSHOT") - id("maven-publish") -} - -java.sourceCompatibility = JavaVersion.VERSION_17 -java.targetCompatibility = JavaVersion.VERSION_17 - -val archives_base_name: String by project -val minecraft_version: String by project -val yarn_mappings: String by project -val loader_version: String by project -val fabric_version: String by project -val malilib_version: String by project -val litematica_projectid: String by project -val litematica_fileid: String by project - -val mod_version: String by project - -dependencies { -// implementation(project(":common")) - minecraft("com.mojang:minecraft:${minecraft_version}") - mappings("net.fabricmc:yarn:${yarn_mappings}:v2") - - modImplementation("net.fabricmc:fabric-loader:${loader_version}") - modImplementation("net.fabricmc.fabric-api:fabric-api:${fabric_version}") - modImplementation("fi.dy.masa.malilib:malilib-fabric-${malilib_version}") - modImplementation("curse.maven:litematica-${litematica_projectid}:${litematica_fileid}") -} - -repositories { - maven("https://masa.dy.fi/maven") - maven("https://www.cursemaven.com") -} - -// Process resources -tasks.withType { - inputs.property("version", mod_version) - - filesMatching("fabric.mod.json") { - expand(mapOf("version" to mod_version)) - } -} - -val sourceModule = "v1_19" -val targetModules = arrayOf("v1_17", "v1_18", "v1_19_3", "v1_19_4") - -fun copyFile(source: File) { - for (targetModule in targetModules) { - val destination = file(source.absolutePath.replace(sourceModule, targetModule)) - println("Copying ${source.absolutePath} to ${destination.absolutePath}") - destination.parentFile.mkdirs() - source.copyTo(destination, true) - destination.writeText(destination.readText().replace(sourceModule, targetModule)) - } -} - -fun deleteOldFiles(sourceBase: File) { - for (targetModule in targetModules) { - val targetBase = file(sourceBase.absolutePath.replace(sourceModule, targetModule)) - - for (file in targetBase.listFiles()) { - if (file.name.equals("implementation")) continue - println("Deleting recursively ${file.absolutePath}") - file.deleteRecursively() - } - } -} - -val syncImplementations = tasks.create("syncImplementations") { - doFirst { - val sourceStart = - this.project.projectDir.absolutePath + "/src/main/java/me/aleksilassila/litematica/printer/" + sourceModule - val sourceDir = file(sourceStart) - - deleteOldFiles(sourceDir) - - for (sourceFile in sourceDir.listFiles()) { - if (sourceFile.name.equals("implementation")) continue - - sourceFile.walk() - .filter { it.isFile } - .forEach { - copyFile(it) - } - } - } -} diff --git a/v1_19/gradle.properties b/v1_19/gradle.properties deleted file mode 100644 index 29ad7b029..000000000 --- a/v1_19/gradle.properties +++ /dev/null @@ -1,15 +0,0 @@ -# Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx1G - -# Fabric Properties - # check these on https://fabricmc.net/versions.html - minecraft_version=1.19.2 - yarn_mappings=1.19.2+build.28 - loader_version=0.14.10 - - malilib_version = 1.19.2:0.13.0 - litematica_fileid=3923065 - litematica_projectid=308892 - -# Dependencies - fabric_version=0.66.0+1.19.2 diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/Printer.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/Printer.java deleted file mode 100644 index 3d0c7ae1d..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/Printer.java +++ /dev/null @@ -1,110 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19; - -import fi.dy.masa.litematica.data.DataManager; -import fi.dy.masa.litematica.util.RayTraceUtils; -import fi.dy.masa.litematica.world.SchematicWorldHandler; -import fi.dy.masa.litematica.world.WorldSchematic; -import me.aleksilassila.litematica.printer.v1_19.actions.Action; -import me.aleksilassila.litematica.printer.v1_19.guides.Guide; -import me.aleksilassila.litematica.printer.v1_19.guides.Guides; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerAbilities; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.RaycastContext; -import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -public class Printer { - @NotNull - public final ClientPlayerEntity player; - - public final ActionHandler actionHandler; - - private final Guides interactionGuides = new Guides(); - - public Printer(@NotNull MinecraftClient client, @NotNull ClientPlayerEntity player) { - this.player = player; - - this.actionHandler = new ActionHandler(client, player); - } - - public boolean onGameTick() { - WorldSchematic worldSchematic = SchematicWorldHandler.getSchematicWorld(); - - if (!actionHandler.acceptsActions()) return false; - - if (worldSchematic == null) return false; - - if (!LitematicaMixinMod.PRINT_MODE.getBooleanValue() && !LitematicaMixinMod.PRINT.getKeybind().isPressed()) - return false; - - PlayerAbilities abilities = player.getAbilities(); - if (!abilities.allowModifyWorld) - return false; - - List positions = getReachablePositions(); - findBlock: - for (BlockPos position : positions) { - SchematicBlockState state = new SchematicBlockState(player.world, worldSchematic, position); - if (state.targetState.equals(state.currentState) || state.targetState.isAir()) continue; - - Guide[] guides = interactionGuides.getInteractionGuides(state); - - BlockHitResult result = RayTraceUtils.traceToSchematicWorld(player, 10, true, true); - boolean isCurrentlyLookingSchematic = result != null && result.getBlockPos().equals(position); - - for (Guide guide : guides) { - if (guide.canExecute(player)) { - System.out.println("Executing " + guide + " for " + state); - List actions = guide.execute(player); - actionHandler.addActions(actions.toArray(Action[]::new)); - return true; - } - if (guide.skipOtherGuides()) continue findBlock; - } - } - - return false; - } - - private List getReachablePositions() { - int maxReach = (int) Math.ceil(LitematicaMixinMod.PRINTING_RANGE.getDoubleValue()); - double maxReachSquared = MathHelper.square(LitematicaMixinMod.PRINTING_RANGE.getDoubleValue()); - - ArrayList positions = new ArrayList<>(); - - for (int y = -maxReach; y < maxReach + 1; y++) { - for (int x = -maxReach; x < maxReach + 1; x++) { - for (int z = -maxReach; z < maxReach + 1; z++) { - BlockPos blockPos = player.getBlockPos().north(x).west(z).up(y); - - if (!DataManager.getRenderLayerRange().isPositionWithinRange(blockPos)) continue; - if (this.player.getEyePos().squaredDistanceTo(Vec3d.ofCenter(blockPos)) > maxReachSquared) { - continue; - } - - positions.add(blockPos); - } - } - } - - return positions.stream() - .filter(p -> { - Vec3d vec = Vec3d.ofCenter(p); - return this.player.getPos().squaredDistanceTo(vec) > 1 && this.player.getEyePos().squaredDistanceTo(vec) > 1; - }) - .sorted((a, b) -> { - double aDistance = this.player.getPos().squaredDistanceTo(Vec3d.ofCenter(a)); - double bDistance = this.player.getPos().squaredDistanceTo(Vec3d.ofCenter(b)); - return Double.compare(aDistance, bDistance); - }).toList(); - } -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/SchematicBlockState.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/SchematicBlockState.java deleted file mode 100644 index f837edb20..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/SchematicBlockState.java +++ /dev/null @@ -1,42 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19; - -import fi.dy.masa.litematica.world.WorldSchematic; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.World; - -public class SchematicBlockState { - public final World world; - public final WorldSchematic schematic; - - public final BlockPos blockPos; - - public final BlockState targetState; - public final BlockState currentState; - - public SchematicBlockState(World world, WorldSchematic schematic, BlockPos blockPos) { - this.world = world; - this.schematic = schematic; - - this.blockPos = blockPos; - - this.targetState = schematic.getBlockState(blockPos); - this.currentState = world.getBlockState(blockPos); - } - - public SchematicBlockState offset(Direction direction) { - return new SchematicBlockState(world, schematic, blockPos.offset(direction)); - } - - @Override - public String toString() { - return "SchematicBlockState{" + - "world=" + world + - ", schematic=" + schematic + - ", blockPos=" + blockPos + - ", targetState=" + targetState + - ", currentState=" + currentState + - '}'; - } -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/UpdateChecker.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/UpdateChecker.java deleted file mode 100644 index 981ed2b89..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/UpdateChecker.java +++ /dev/null @@ -1,49 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import org.apache.commons.io.IOUtils; - -import java.io.BufferedReader; -import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.util.Scanner; - -public class UpdateChecker { - public static final String version = "v3.2"; - - // Try to get this to work at some point -// static { -// try (InputStream in = UpdateChecker.class.getResourceAsStream("/fabric.mod.json")) { -// String jsonString = IOUtils.toString(in, StandardCharsets.UTF_8); -// JsonObject json = JsonParser.parseString(jsonString).getAsJsonObject(); -// System.out.println("JSON object: " + json); -// System.out.println("Raw json: " + jsonString); -// System.out.println("File: " + new File(UpdateChecker.class.getResource("/fabric.mod.json").getFile())); -// String version = json.get("version").getAsString(); -// System.out.println("Reading fabric.mod.json"); -// System.out.println("Parsed version: " + version); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } - - @SuppressWarnings("deprecation") - public static String getPrinterVersion() { - try (InputStream inputStream = new URL("https://api.github.com/repos/aleksilassila/litematica-printer/tags").openStream(); Scanner scanner = new Scanner(inputStream)) { - if (scanner.hasNext()) { - JsonArray tags = new JsonParser().parse(scanner.next()).getAsJsonArray(); - return ((JsonObject) tags.get(0)).get("name").getAsString(); - } - } catch (Exception exception) { - System.out.println("Cannot look for updates: " + exception.getMessage()); - } - - return ""; - } -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/actions/Action.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/actions/Action.java deleted file mode 100644 index d2be59dcf..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/actions/Action.java +++ /dev/null @@ -1,8 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19.actions; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; - -public abstract class Action { - abstract public void send(MinecraftClient client, ClientPlayerEntity player); -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/Guide.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/Guide.java deleted file mode 100644 index a9247a461..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/Guide.java +++ /dev/null @@ -1,130 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19.guides; - -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19.actions.Action; -import me.aleksilassila.litematica.printer.v1_19.implementation.BlockHelperImpl; -import net.minecraft.block.BlockState; -import net.minecraft.block.CoralBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.state.property.Properties; -import net.minecraft.state.property.Property; -import org.jetbrains.annotations.NotNull; - -import java.util.List; -import java.util.Optional; - -abstract public class Guide extends BlockHelperImpl { - protected final SchematicBlockState state; - protected final BlockState currentState; - protected final BlockState targetState; - - public Guide(SchematicBlockState state) { - this.state = state; - - this.currentState = state.currentState; - this.targetState = state.targetState; - } - - protected boolean playerHasRightItem(ClientPlayerEntity player) { - return getRequiredItemStackSlot(player) != -1; - } - - protected int getSlotWithItem(ClientPlayerEntity player, ItemStack itemStack) { - PlayerInventory inventory = player.getInventory(); - - for (int i = 0; i < inventory.main.size(); ++i) { - if (itemStack.isEmpty() && inventory.main.get(i).isOf(itemStack.getItem())) return i; - if (!inventory.main.get(i).isEmpty() && inventory.main.get(i).isItemEqual(itemStack)) { - return i; - } - } - - return -1; - } - - protected int getRequiredItemStackSlot(ClientPlayerEntity player) { - if (player.getAbilities().creativeMode) { - return player.getInventory().selectedSlot; - } - - Optional requiredItem = getRequiredItem(player); - if (requiredItem.isEmpty()) return -1; - - return getSlotWithItem(player, requiredItem.get()); - } - - public boolean canExecute(ClientPlayerEntity player) { - if (!playerHasRightItem(player)) return false; - - BlockState targetState = state.targetState; - BlockState currentState = state.currentState; - - return !statesEqual(targetState, currentState); - } - - abstract public @NotNull List execute(ClientPlayerEntity player); - - abstract protected @NotNull List getRequiredItems(); - - /** - * Returns the first required item that player has access to, - * or empty if the items are inaccessible. - */ - protected Optional getRequiredItem(ClientPlayerEntity player) { - List requiredItems = getRequiredItems(); - - for (ItemStack requiredItem : requiredItems) { - if (player.getAbilities().creativeMode) return Optional.of(requiredItem); - - int slot = getSlotWithItem(player, requiredItem); - if (slot > -1) - return Optional.of(requiredItem); - } - - return Optional.empty(); - } - - protected boolean statesEqualIgnoreProperties(BlockState state1, BlockState state2, Property... propertiesToIgnore) { - if (state1.getBlock() != state2.getBlock()) return false; - - loop: - for (Property property : state1.getProperties()) { - if (property == Properties.WATERLOGGED && !(state1.getBlock() instanceof CoralBlock)) continue; - - for (Property ignoredProperty : propertiesToIgnore) { - if (property == ignoredProperty) continue loop; - } - - try { - if (state1.get(property) != state2.get(property)) { - return false; - } - } catch (Exception e) { - return false; - } - } - - return true; - } - - protected static > Optional getProperty(BlockState blockState, Property property) { - if (blockState.contains(property)) { - return Optional.of(blockState.get(property)); - } - return Optional.empty(); - } - - /** - * Returns true if - */ - protected boolean statesEqual(BlockState state1, BlockState state2) { - return statesEqualIgnoreProperties(state1, state2); - } - - public boolean skipOtherGuides() { - return false; - } -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/Guides.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/Guides.java deleted file mode 100644 index 7112328de..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/Guides.java +++ /dev/null @@ -1,81 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19.guides; - -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19.guides.interaction.*; -import me.aleksilassila.litematica.printer.v1_19.guides.placement.*; -import net.minecraft.block.*; -import net.minecraft.util.Pair; - -import java.util.ArrayList; - -public class Guides { - protected final static ArrayList, Class[]>> guides = new ArrayList<>(); - - @SafeVarargs - protected static void registerGuide(Class guideClass, Class... blocks) { - guides.add(new Pair<>(guideClass, blocks)); - } - - static { -// registerGuide(SkipGuide.class, AbstractSignBlock.class, SkullBlock.class, BannerBlock.class); - - registerGuide(RotatingBlockGuide.class, AbstractSkullBlock.class, AbstractSignBlock.class, AbstractBannerBlock.class); - registerGuide(SlabGuide.class, SlabBlock.class); - registerGuide(TorchGuide.class, TorchBlock.class); - registerGuide(FarmlandGuide.class, FarmlandBlock.class); - registerGuide(TillingGuide.class, FarmlandBlock.class); - registerGuide(RailGuesserGuide.class, AbstractRailBlock.class); - registerGuide(ChestGuide.class, ChestBlock.class); - registerGuide(FlowerPotGuide.class, FlowerPotBlock.class); - registerGuide(FlowerPotFillGuide.class, FlowerPotBlock.class); - - registerGuide(PropertySpecificGuesserGuide.class, - RepeaterBlock.class, ComparatorBlock.class, RedstoneWireBlock.class, RedstoneTorchBlock.class, - BambooBlock.class, CactusBlock.class, SaplingBlock.class, ScaffoldingBlock.class, PointedDripstoneBlock.class, - HorizontalConnectingBlock.class, DoorBlock.class, TrapdoorBlock.class, FenceGateBlock.class, ChestBlock.class, - SnowBlock.class, SeaPickleBlock.class, CandleBlock.class, LeverBlock.class, EndPortalFrameBlock.class, - NoteBlock.class, CampfireBlock.class, PoweredRailBlock.class, LeavesBlock.class, TripwireHookBlock.class); - registerGuide(FallingBlockGuide.class, FallingBlock.class); - registerGuide(BlockIndifferentGuesserGuide.class, BambooBlock.class, BigDripleafStemBlock.class, BigDripleafBlock.class, - TwistingVinesPlantBlock.class, TripwireBlock.class); - - registerGuide(CampfireExtinguishGuide.class, CampfireBlock.class); - registerGuide(LightCandleGuide.class, AbstractCandleBlock.class); - registerGuide(EnderEyeGuide.class, EndPortalFrameBlock.class); - registerGuide(CycleStateGuide.class, - DoorBlock.class, FenceGateBlock.class, TrapdoorBlock.class, - LeverBlock.class, - RepeaterBlock.class, ComparatorBlock.class, NoteBlock.class); - registerGuide(BlockReplacementGuide.class, SnowBlock.class, SeaPickleBlock.class, CandleBlock.class, SlabBlock.class); - registerGuide(LogGuide.class); - registerGuide(LogStrippingGuide.class); - registerGuide(GuesserGuide.class); - } - - public ArrayList, Class[]>> getGuides() { - return guides; - } - - public Guide[] getInteractionGuides(SchematicBlockState state) { - ArrayList, Class[]>> guides = getGuides(); - - ArrayList applicableGuides = new ArrayList<>(); - for (Pair, Class[]> guidePair : guides) { - try { - if (guidePair.getRight().length == 0) { - applicableGuides.add(guidePair.getLeft().getConstructor(SchematicBlockState.class).newInstance(state)); - continue; - } - - for (Class clazz : guidePair.getRight()) { - if (clazz.isInstance(state.targetState.getBlock())) { - applicableGuides.add(guidePair.getLeft().getConstructor(SchematicBlockState.class).newInstance(state)); - } - } - } catch (Exception ignored) { - } - } - - return applicableGuides.toArray(Guide[]::new); - } -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/CampfireExtinguishGuide.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/CampfireExtinguishGuide.java deleted file mode 100644 index 69809ca14..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/CampfireExtinguishGuide.java +++ /dev/null @@ -1,36 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; -import net.minecraft.block.CampfireBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; - -public class CampfireExtinguishGuide extends InteractionGuide { - boolean shouldBeLit; - boolean isLit; - - public CampfireExtinguishGuide(SchematicBlockState state) { - super(state); - - shouldBeLit = getProperty(targetState, CampfireBlock.LIT).orElse(false); - isLit = getProperty(currentState, CampfireBlock.LIT).orElse(false); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return (currentState.getBlock() instanceof CampfireBlock) && !shouldBeLit && isLit; - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(SHOVEL_ITEMS).map(ItemStack::new).toList(); - } -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/FlowerPotFillGuide.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/FlowerPotFillGuide.java deleted file mode 100644 index 1c888f9b9..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/FlowerPotFillGuide.java +++ /dev/null @@ -1,40 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; -import net.minecraft.block.Block; -import net.minecraft.block.FlowerPotBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class FlowerPotFillGuide extends InteractionGuide { - private final Block content; - - public FlowerPotFillGuide(SchematicBlockState state) { - super(state); - - Block targetBlock = state.targetState.getBlock(); - if (targetBlock instanceof FlowerPotBlock) { - this.content = ((FlowerPotBlock) targetBlock).getContent(); - } else { - this.content = null; - } - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (content == null) return false; - if (!(currentState.getBlock() instanceof FlowerPotBlock)) return false; - - return super.canExecute(player); - } - - @Override - protected @NotNull List getRequiredItems() { - if (content == null) return Collections.emptyList(); - else return Collections.singletonList(new ItemStack(content)); - } -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/InteractionGuide.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/InteractionGuide.java deleted file mode 100644 index b959c01bd..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/InteractionGuide.java +++ /dev/null @@ -1,49 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_19.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19.actions.Action; -import me.aleksilassila.litematica.printer.v1_19.actions.PrepareAction; -import me.aleksilassila.litematica.printer.v1_19.actions.ReleaseShiftAction; -import me.aleksilassila.litematica.printer.v1_19.guides.Guide; -import me.aleksilassila.litematica.printer.v1_19.implementation.actions.InteractActionImpl; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.List; - -/** - * A guide that clicks the current block to change its state. - */ -public abstract class InteractionGuide extends Guide { - public InteractionGuide(SchematicBlockState state) { - super(state); - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - List actions = new ArrayList<>(); - - BlockHitResult hitResult = new BlockHitResult(Vec3d.ofCenter(state.blockPos), Direction.UP, state.blockPos, false); - ItemStack requiredItem = getRequiredItem(player).orElse(ItemStack.EMPTY); - int requiredSlot = getRequiredItemStackSlot(player); - - if (requiredSlot == -1) return actions; - - PrinterPlacementContext ctx = new PrinterPlacementContext(player, hitResult, requiredItem, requiredSlot); - - actions.add(new ReleaseShiftAction()); - actions.add(new PrepareAction(ctx)); - actions.add(new InteractActionImpl(ctx)); - - return actions; - } - - @Override - abstract protected @NotNull List getRequiredItems(); -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/LightCandleGuide.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/LightCandleGuide.java deleted file mode 100644 index 21176810f..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/LightCandleGuide.java +++ /dev/null @@ -1,36 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; -import net.minecraft.block.AbstractCandleBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.state.property.Properties; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class LightCandleGuide extends InteractionGuide { - boolean shouldBeLit; - boolean isLit; - - public LightCandleGuide(SchematicBlockState state) { - super(state); - - shouldBeLit = getProperty(targetState, Properties.LIT).orElse(false); - isLit = getProperty(currentState, Properties.LIT).orElse(false); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(new ItemStack(Items.FLINT_AND_STEEL)); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return (currentState.getBlock() instanceof AbstractCandleBlock) && shouldBeLit && !isLit; - } -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/LogStrippingGuide.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/LogStrippingGuide.java deleted file mode 100644 index d247c76b5..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/interaction/LogStrippingGuide.java +++ /dev/null @@ -1,47 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_19.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19.mixin.AxeItemAccessor; -import net.minecraft.block.Block; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -public class LogStrippingGuide extends InteractionGuide { - static final Item[] AXE_ITEMS = new Item[]{ - Items.NETHERITE_AXE, - Items.DIAMOND_AXE, - Items.GOLDEN_AXE, - Items.IRON_AXE, - Items.STONE_AXE, - Items.WOODEN_AXE - }; - - public static final Map STRIPPED_BLOCKS = AxeItemAccessor.getStrippedBlocks(); - - public LogStrippingGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!LitematicaMixinMod.STRIP_LOGS.getBooleanValue()) return false; - - if (!super.canExecute(player)) return false; - - Block strippingResult = STRIPPED_BLOCKS.get(currentState.getBlock()); - return strippingResult == targetState.getBlock(); - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(AXE_ITEMS).map(ItemStack::new).toList(); - } -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/BlockIndifferentGuesserGuide.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/BlockIndifferentGuesserGuide.java deleted file mode 100644 index 32ce54251..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/BlockIndifferentGuesserGuide.java +++ /dev/null @@ -1,42 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; -import net.minecraft.block.*; - -public class BlockIndifferentGuesserGuide extends GuesserGuide { - public BlockIndifferentGuesserGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected boolean statesEqual(BlockState resultState, BlockState targetState) { - Block targetBlock = targetState.getBlock(); - Block resultBlock = resultState.getBlock(); - - if (targetBlock instanceof BambooBlock) { - return resultBlock instanceof BambooBlock || resultBlock instanceof BambooSaplingBlock; - } - - if (targetBlock instanceof BigDripleafStemBlock) { - if (resultBlock instanceof BigDripleafBlock || resultBlock instanceof BigDripleafStemBlock) { - return resultState.get(HorizontalFacingBlock.FACING) == targetState.get(HorizontalFacingBlock.FACING); - } - } - - if (targetBlock instanceof TwistingVinesPlantBlock) { - if (resultBlock instanceof TwistingVinesBlock) { - return true; - } else if (resultBlock instanceof TwistingVinesPlantBlock) { - return statesEqualIgnoreProperties(resultState, targetState, TwistingVinesBlock.AGE); - } - } - - if (targetBlock instanceof TripwireBlock && resultBlock instanceof TripwireBlock) { - return statesEqualIgnoreProperties(resultState, targetState, - TripwireBlock.ATTACHED, TripwireBlock.DISARMED, TripwireBlock.POWERED, TripwireBlock.NORTH, - TripwireBlock.EAST, TripwireBlock.SOUTH, TripwireBlock.WEST); - } - - return super.statesEqual(resultState, targetState); - } -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/BlockReplacementGuide.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/BlockReplacementGuide.java deleted file mode 100644 index a7385ae28..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/BlockReplacementGuide.java +++ /dev/null @@ -1,75 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; -import net.minecraft.block.CandleBlock; -import net.minecraft.block.SeaPickleBlock; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.SnowBlock; -import net.minecraft.block.enums.SlabType; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.state.property.IntProperty; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.Nullable; - -import java.util.HashMap; -import java.util.Optional; - -public class BlockReplacementGuide extends PlacementGuide { - private static final HashMap increasingProperties = new HashMap<>(); - - static { - increasingProperties.put(SnowBlock.LAYERS, null); - increasingProperties.put(SeaPickleBlock.PICKLES, null); - increasingProperties.put(CandleBlock.CANDLES, null); - } - - private Integer currentLevel = null; - private Integer targetLevel = null; - private IntProperty increasingProperty = null; - - public BlockReplacementGuide(SchematicBlockState state) { - super(state); - - for (IntProperty property : increasingProperties.keySet()) { - if (targetState.contains(property) && currentState.contains(property)) { - currentLevel = currentState.get(property); - targetLevel = targetState.get(property); - increasingProperty = property; - break; - } - } - } - - @Override - protected boolean getUseShift(SchematicBlockState state) { - return false; - } - - @Override - public @Nullable PrinterPlacementContext getPlacementContext(ClientPlayerEntity player) { - Optional requiredItem = getRequiredItem(player); - int slot = getRequiredItemStackSlot(player); - if (requiredItem.isEmpty() || slot == -1) return null; - - BlockHitResult hitResult = new BlockHitResult(Vec3d.ofCenter(state.blockPos), Direction.UP, state.blockPos, false); - return new PrinterPlacementContext(player, hitResult, requiredItem.get(), slot); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (getProperty(targetState, SlabBlock.TYPE).orElse(null) == SlabType.DOUBLE && getProperty(currentState, SlabBlock.TYPE).orElse(SlabType.DOUBLE) != SlabType.DOUBLE) { - return super.canExecute(player); - } - - if (currentLevel == null || targetLevel == null || increasingProperty == null) return false; - if (!statesEqualIgnoreProperties(currentState, targetState, CandleBlock.LIT, increasingProperty)) return false; - if (currentLevel >= targetLevel) return false; - - return super.canExecute(player); - } -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/FallingBlockGuide.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/FallingBlockGuide.java deleted file mode 100644 index 5da25b7d5..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/FallingBlockGuide.java +++ /dev/null @@ -1,37 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.FallingBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.math.Direction; - -public class FallingBlockGuide extends GuesserGuide { - - public FallingBlockGuide(SchematicBlockState state) { - super(state); - } - - boolean blockPlacement() { - if (targetState.getBlock() instanceof FallingBlock) { - BlockState below = state.world.getBlockState(state.blockPos.offset(Direction.DOWN)); - return FallingBlock.canFallThrough(below); - } - - return false; - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (blockPlacement()) return false; - - return super.canExecute(player); - } - - @Override - public boolean skipOtherGuides() { - if (blockPlacement()) return true; - - return super.skipOtherGuides(); - } -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/FarmlandGuide.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/FarmlandGuide.java deleted file mode 100644 index 2123875b1..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/FarmlandGuide.java +++ /dev/null @@ -1,29 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; - -public class FarmlandGuide extends GeneralPlacementGuide { - public static final Block[] TILLABLE_BLOCKS = new Block[]{ - Blocks.DIRT, - Blocks.GRASS_BLOCK, - Blocks.COARSE_DIRT, - Blocks.ROOTED_DIRT, - Blocks.DIRT_PATH, - }; - - public FarmlandGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(TILLABLE_BLOCKS).map(b -> getBlockItem(b.getDefaultState())).toList(); - } -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/GeneralPlacementGuide.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/GeneralPlacementGuide.java deleted file mode 100644 index 30a5eac0c..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/GeneralPlacementGuide.java +++ /dev/null @@ -1,119 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.enums.SlabType; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -/** - * An old school guide where there are defined specific conditions - * for player state depending on the block being placed. - */ -public class GeneralPlacementGuide extends PlacementGuide { - public GeneralPlacementGuide(SchematicBlockState state) { - super(state); - } - - protected List getPossibleSides() { - return Arrays.asList(Direction.values()); - } - - protected Optional getLookDirection() { - return Optional.empty(); - } - - protected boolean getRequiresSupport() { - return false; - } - - protected boolean getRequiresExplicitShift() { - return false; - } - - protected Vec3d getHitModifier(Direction validSide) { - return new Vec3d(0, 0, 0); - } - - private Optional getValidSide(SchematicBlockState state) { - boolean printInAir = false; // LitematicaMixinMod.PRINT_IN_AIR.getBooleanValue(); - - List sides = getPossibleSides(); - - if (sides.isEmpty()) { - return Optional.empty(); - } - - List validSides = new ArrayList<>(); - for (Direction side : sides) { - if (printInAir && !getRequiresSupport()) { - return Optional.of(side); - } else { - SchematicBlockState neighborState = state.offset(side); - - if (getProperty(neighborState.currentState, SlabBlock.TYPE).orElse(null) == SlabType.DOUBLE) { - validSides.add(side); - continue; - } - - if (canBeClicked(neighborState.world, neighborState.blockPos) && // Handle unclickable grass for example - !neighborState.currentState.getMaterial().isReplaceable()) - validSides.add(side); - } - } - - for (Direction validSide : validSides) { - if (!isInteractive(state.offset(validSide).currentState.getBlock())) { - return Optional.of(validSide); - } - } - - return validSides.isEmpty() ? Optional.empty() : Optional.of(validSides.get(0)); - } - - protected boolean getUseShift(SchematicBlockState state) { - if (getRequiresExplicitShift()) return true; - - Direction clickSide = getValidSide(state).orElse(null); - if (clickSide == null) return false; - return isInteractive(state.offset(clickSide).currentState.getBlock()); - } - - private Optional getHitVector(SchematicBlockState state) { - return getValidSide(state).map(side -> Vec3d.ofCenter(state.blockPos) - .add(Vec3d.of(side.getVector()).multiply(0.5)) - .add(getHitModifier(side))); - } - - @Nullable - public PrinterPlacementContext getPlacementContext(ClientPlayerEntity player) { - try { - Optional validSide = getValidSide(state); - Optional hitVec = getHitVector(state); - Optional requiredItem = getRequiredItem(player); - int requiredSlot = getRequiredItemStackSlot(player); - - if (validSide.isEmpty() || hitVec.isEmpty() || requiredItem.isEmpty() || requiredSlot == -1) return null; - - Optional lookDirection = getLookDirection(); - boolean requiresShift = getUseShift(state); - - BlockHitResult blockHitResult = new BlockHitResult(hitVec.get(), validSide.get().getOpposite(), state.blockPos.offset(validSide.get()), false); - - return new PrinterPlacementContext(player, blockHitResult, requiredItem.get(), requiredSlot, lookDirection.orElse(null), requiresShift); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/GuesserGuide.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/GuesserGuide.java deleted file mode 100644 index b61b5b0bd..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/GuesserGuide.java +++ /dev/null @@ -1,110 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_19.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.ChestBlock; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.enums.ChestType; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.Nullable; - -/** - * This is the placement guide that most blocks will use. - * It will try to predict the correct player state for producing the right blockState - * by brute forcing the correct hit vector and look direction. - */ -public class GuesserGuide extends GeneralPlacementGuide { - private PrinterPlacementContext contextCache = null; - - protected static Direction[] directionsToTry = new Direction[]{ - Direction.NORTH, - Direction.SOUTH, - Direction.EAST, - Direction.WEST, - Direction.UP, - Direction.DOWN - }; - protected static Vec3d[] hitVecsToTry = new Vec3d[]{ - new Vec3d(-0.25, -0.25, -0.25), - new Vec3d(+0.25, -0.25, -0.25), - new Vec3d(-0.25, +0.25, -0.25), - new Vec3d(-0.25, -0.25, +0.25), - new Vec3d(+0.25, +0.25, -0.25), - new Vec3d(-0.25, +0.25, +0.25), - new Vec3d(+0.25, -0.25, +0.25), - new Vec3d(+0.25, +0.25, +0.25), - }; - - public GuesserGuide(SchematicBlockState state) { - super(state); - } - - @Nullable - @Override - public PrinterPlacementContext getPlacementContext(ClientPlayerEntity player) { - if (contextCache != null && !LitematicaMixinMod.DEBUG) return contextCache; - - ItemStack requiredItem = getRequiredItem(player).orElse(ItemStack.EMPTY); - int slot = getRequiredItemStackSlot(player); - - if (slot == -1) return null; - - for (Direction lookDirection : directionsToTry) { - for (Direction side : directionsToTry) { - BlockPos neighborPos = state.blockPos.offset(side); - BlockState neighborState = state.world.getBlockState(neighborPos); - boolean requiresShift = getRequiresExplicitShift() || isInteractive(neighborState.getBlock()); - - if (!canBeClicked(state.world, neighborPos) || // Handle unclickable grass for example - neighborState.getMaterial().isReplaceable()) - continue; - - Vec3d hitVec = Vec3d.ofCenter(state.blockPos) - .add(Vec3d.of(side.getVector()).multiply(0.5)); - - for (Vec3d hitVecToTry : hitVecsToTry) { - Vec3d multiplier = Vec3d.of(side.getVector()); - multiplier = new Vec3d(multiplier.x == 0 ? 1 : 0, multiplier.y == 0 ? 1 : 0, multiplier.z == 0 ? 1 : 0); - - BlockHitResult hitResult = new BlockHitResult(hitVec.add(hitVecToTry.multiply(multiplier)), side.getOpposite(), neighborPos, false); - PrinterPlacementContext context = new PrinterPlacementContext(player, hitResult, requiredItem, slot, lookDirection, requiresShift); - BlockState result = getRequiredItemAsBlock(player) - .orElse(targetState.getBlock()) - .getPlacementState(context); // FIXME torch shift clicks another torch and getPlacementState is the clicked block, which is true - - if (result != null && (statesEqual(result, targetState) || correctChestPlacement(targetState, result))) { - contextCache = context; - return context; - } - } - } - } - - return null; - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (targetState.getBlock() instanceof SlabBlock) return false; // Slabs are a special case - - return super.canExecute(player); - } - - private boolean correctChestPlacement(BlockState targetState, BlockState result) { - if (targetState.contains(ChestBlock.CHEST_TYPE) && result.contains(ChestBlock.CHEST_TYPE) && result.get(ChestBlock.FACING) == targetState.get(ChestBlock.FACING)) { - ChestType targetChestType = targetState.get(ChestBlock.CHEST_TYPE); - ChestType resultChestType = result.get(ChestBlock.CHEST_TYPE); - - return targetChestType != ChestType.SINGLE && resultChestType == ChestType.SINGLE; - } - - return false; - } -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/PlacementGuide.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/PlacementGuide.java deleted file mode 100644 index ea9ce5fe5..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/PlacementGuide.java +++ /dev/null @@ -1,138 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_19.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19.actions.Action; -import me.aleksilassila.litematica.printer.v1_19.actions.PrepareAction; -import me.aleksilassila.litematica.printer.v1_19.actions.ReleaseShiftAction; -import me.aleksilassila.litematica.printer.v1_19.guides.Guide; -import me.aleksilassila.litematica.printer.v1_19.implementation.actions.InteractActionImpl; -import net.minecraft.block.*; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.World; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -/** - * Guide that clicks its neighbors to create a placement in target position. - */ -abstract public class PlacementGuide extends Guide { - public PlacementGuide(SchematicBlockState state) { - super(state); - } - - protected ItemStack getBlockItem(BlockState state) { - return state.getBlock().getPickStack(this.state.world, this.state.blockPos, state); - } - - protected Optional getRequiredItemAsBlock(ClientPlayerEntity player) { - Optional requiredItem = getRequiredItem(player); - - if (requiredItem.isEmpty()) { - return Optional.empty(); - } else { - ItemStack itemStack = requiredItem.get(); - - if (itemStack.getItem() instanceof BlockItem) - return Optional.of(((BlockItem) itemStack.getItem()).getBlock()); - else return Optional.empty(); - } - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(getBlockItem(state.targetState)); - } - - abstract protected boolean getUseShift(SchematicBlockState state); - - @Nullable - abstract public PrinterPlacementContext getPlacementContext(ClientPlayerEntity player); - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - List requiredItems = getRequiredItems(); - if (requiredItems.isEmpty() || requiredItems.stream().allMatch(i -> i.isOf(Items.AIR))) - return false; - - ItemPlacementContext ctx = getPlacementContext(player); - if (ctx == null || !ctx.canPlace()) return false; -// if (!state.currentState.getMaterial().isReplaceable()) return false; - if (!LitematicaMixinMod.REPLACE_FLUIDS_SOURCE_BLOCKS.getBooleanValue() - && getProperty(state.currentState, FluidBlock.LEVEL).orElse(1) == 0) - return false; - - BlockState resultState = getRequiredItemAsBlock(player) - .orElse(targetState.getBlock()) - .getPlacementState(ctx); - - if (resultState != null) { - if (!resultState.canPlaceAt(state.world, state.blockPos)) return false; - return !(currentState.getBlock() instanceof FluidBlock) || canPlaceInWater(resultState); - } else { - return false; - } - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - List actions = new ArrayList<>(); - PrinterPlacementContext ctx = getPlacementContext(player); - - if (ctx == null) return actions; - actions.add(new PrepareAction(ctx)); - actions.add(new InteractActionImpl(ctx)); - if (ctx.shouldSneak) actions.add(new ReleaseShiftAction()); - - return actions; - } - - protected static boolean canBeClicked(World world, BlockPos pos) { - return getOutlineShape(world, pos) != VoxelShapes.empty() && !(world.getBlockState(pos).getBlock() instanceof AbstractSignBlock); // FIXME signs - } - - private static VoxelShape getOutlineShape(World world, BlockPos pos) { - return world.getBlockState(pos).getOutlineShape(world, pos); - } - - public boolean isInteractive(Block block) { - for (Class clazz : interactiveBlocks) { - if (clazz.isInstance(block)) { - return true; - } - } - - return false; - } - - private boolean canPlaceInWater(BlockState blockState) { - Block block = blockState.getBlock(); - if (block instanceof FluidFillable) { - return true; - } else if (!(block instanceof DoorBlock) && !(blockState.getBlock() instanceof AbstractSignBlock) && !blockState.isOf(Blocks.LADDER) && !blockState.isOf(Blocks.SUGAR_CANE) && !blockState.isOf(Blocks.BUBBLE_COLUMN)) { - Material material = blockState.getMaterial(); - if (material != Material.PORTAL && material != Material.STRUCTURE_VOID && material != Material.UNDERWATER_PLANT && material != Material.REPLACEABLE_UNDERWATER_PLANT) { - return material.blocksMovement(); - } else { - return true; - } - } - - return true; - } -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/PropertySpecificGuesserGuide.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/PropertySpecificGuesserGuide.java deleted file mode 100644 index 5bee42353..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/PropertySpecificGuesserGuide.java +++ /dev/null @@ -1,52 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; -import net.minecraft.block.*; -import net.minecraft.state.property.Properties; -import net.minecraft.state.property.Property; - -public class PropertySpecificGuesserGuide extends GuesserGuide { - protected static Property[] ignoredProperties = new Property[]{ - RepeaterBlock.DELAY, - ComparatorBlock.MODE, - RedstoneWireBlock.POWER, - RedstoneWireBlock.WIRE_CONNECTION_EAST, - RedstoneWireBlock.WIRE_CONNECTION_NORTH, - RedstoneWireBlock.WIRE_CONNECTION_SOUTH, - RedstoneWireBlock.WIRE_CONNECTION_WEST, - Properties.POWERED, - Properties.OPEN, - PointedDripstoneBlock.THICKNESS, - ScaffoldingBlock.DISTANCE, - ScaffoldingBlock.BOTTOM, - CactusBlock.AGE, - BambooBlock.AGE, - BambooBlock.LEAVES, - BambooBlock.STAGE, - SaplingBlock.STAGE, - HorizontalConnectingBlock.EAST, - HorizontalConnectingBlock.NORTH, - HorizontalConnectingBlock.SOUTH, - HorizontalConnectingBlock.WEST, - SnowBlock.LAYERS, - SeaPickleBlock.PICKLES, - CandleBlock.CANDLES, - EndPortalFrameBlock.EYE, - Properties.LIT, - LeavesBlock.DISTANCE, - LeavesBlock.PERSISTENT, - Properties.ATTACHED, - Properties.NOTE, - Properties.INSTRUMENT, - - }; - - public PropertySpecificGuesserGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected boolean statesEqual(BlockState resultState, BlockState targetState) { - return statesEqualIgnoreProperties(resultState, targetState, ignoredProperties); - } -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/RailGuesserGuide.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/RailGuesserGuide.java deleted file mode 100644 index a48025dbf..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/guides/placement/RailGuesserGuide.java +++ /dev/null @@ -1,128 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.enums.RailShape; -import net.minecraft.state.property.Properties; -import net.minecraft.util.math.Direction; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -public class RailGuesserGuide extends GuesserGuide { - static final RailShape[] STRAIGHT_RAIL_SHAPES = new RailShape[]{ - RailShape.NORTH_SOUTH, - RailShape.EAST_WEST - }; - - public RailGuesserGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - protected boolean statesEqual(BlockState resultState, BlockState targetState) { - if (!wouldConnectCorrectly()) return false; -// if (wouldBlockAnotherConnection()) return false; - /*TODO: Fully working rail guesser - * If has a neighbor that: - * - Has not been placed yet - * - OR Has been placed but can change shape - * - AND this placement should connect to only one rail, that is not the neighbor - * Then return false - * */ - - if (getRailShape(resultState).isPresent()) { - if (Arrays.stream(STRAIGHT_RAIL_SHAPES).anyMatch(shape -> shape == getRailShape(resultState).orElse(null))) { - return super.statesEqualIgnoreProperties(resultState, targetState, Properties.RAIL_SHAPE, Properties.STRAIGHT_RAIL_SHAPE, Properties.POWERED); - } - } - - return super.statesEqual(resultState, targetState); - } - - private boolean wouldConnectCorrectly() { - RailShape targetShape = getRailShape(state.targetState).orElse(null); - if (targetShape == null) return false; - - List allowedConnections = getRailDirections(targetShape); - - List possibleConnections = new ArrayList<>(); - for (Direction d : Direction.values()) { - if (d.getAxis().isVertical()) continue; - SchematicBlockState neighbor = state.offset(d); - - if (hasFreeConnections(neighbor)) { - possibleConnections.add(d); - } - } - - if (possibleConnections.size() > 2) return false; - - return allowedConnections.containsAll(possibleConnections); - } - -// private boolean wouldBlockAnotherConnection() { -// List possibleConnections = new ArrayList<>(); -// -// for (Direction d : Direction.values()) { -// if (d.getAxis().isVertical()) continue; -// SchematicBlockState neighbor = state.offset(d); -// -// if (couldConnectWrongly(neighbor)) { -// possibleConnections.add(d); -// } -// } -// -// return possibleConnections.size() > 1; -// } - - private boolean hasFreeConnections(SchematicBlockState state) { - List possibleConnections = getRailDirections(state); - if (possibleConnections.isEmpty()) return false; - - for (Direction d : possibleConnections) { - SchematicBlockState neighbor = state.offset(d); - if (neighbor.currentState.getBlock() != neighbor.currentState.getBlock()) { - return false; - } - } - - return possibleConnections.stream().anyMatch(possibleDirection -> { - SchematicBlockState neighbor = state.offset(possibleDirection); - return !getRailDirections(neighbor).contains(possibleDirection.getOpposite()); - }); - } - - private List getRailDirections(SchematicBlockState state) { - RailShape shape = getRailShape(state.currentState).orElse(null); - if (shape == null) return new ArrayList<>(); - - return getRailDirections(shape); - } - - private List getRailDirections(RailShape railShape) { - String name = railShape.getName(); - - if (railShape.isAscending()) { - Direction d = Direction.valueOf(name.replace("ascending_", "").toUpperCase()); - return Arrays.asList(d, d.getOpposite()); - } else { - Direction d1 = Direction.valueOf(name.split("_")[0].toUpperCase()); - Direction d2 = Direction.valueOf(name.split("_")[1].toUpperCase()); - return Arrays.asList(d1, d2); - } - } - - Optional getRailShape(BlockState state) { - Optional shape = getProperty(state, Properties.RAIL_SHAPE); - if (shape.isEmpty()) return getProperty(state, Properties.STRAIGHT_RAIL_SHAPE); - return shape; - } -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/implementation/BlockHelperImpl.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/implementation/BlockHelperImpl.java deleted file mode 100644 index fe7cac1fb..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/implementation/BlockHelperImpl.java +++ /dev/null @@ -1,14 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19.implementation; - -import me.aleksilassila.litematica.printer.v1_19.BlockHelper; -import net.minecraft.block.AbstractButtonBlock; - -import java.util.Arrays; - -public class BlockHelperImpl extends BlockHelper { - static { - interactiveBlocks.addAll(Arrays.asList( - AbstractButtonBlock.class - )); - } -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/implementation/PrinterPlacementContext.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/implementation/PrinterPlacementContext.java deleted file mode 100644 index 20f426e4b..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/implementation/PrinterPlacementContext.java +++ /dev/null @@ -1,59 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19.implementation; - -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import org.jetbrains.annotations.Nullable; - -public class PrinterPlacementContext extends ItemPlacementContext { - public final @Nullable Direction lookDirection; - public final boolean shouldSneak; - public final BlockHitResult hitResult; - public final int requiredItemSlot; - - public PrinterPlacementContext(PlayerEntity player, BlockHitResult hitResult, ItemStack requiredItem, int requiredItemSlot) { - this(player, hitResult, requiredItem, requiredItemSlot, null, false); - } - - public PrinterPlacementContext(PlayerEntity player, BlockHitResult hitResult, ItemStack requiredItem, int requiredItemSlot, @Nullable Direction lookDirection, boolean requiresSneaking) { - super(player, Hand.MAIN_HAND, requiredItem, hitResult); - - this.lookDirection = lookDirection; - this.shouldSneak = requiresSneaking; - this.hitResult = hitResult; - this.requiredItemSlot = requiredItemSlot; - } - - @Override - public Direction getPlayerLookDirection() { - return lookDirection == null ? super.getPlayerLookDirection() : lookDirection; - } - - @Override - public Direction getVerticalPlayerLookDirection() { - if (lookDirection != null && lookDirection.getOpposite() == super.getVerticalPlayerLookDirection()) - return lookDirection; - return super.getVerticalPlayerLookDirection(); - } - - @Override - public Direction getPlayerFacing() { - if (lookDirection == null || !lookDirection.getAxis().isHorizontal()) return super.getPlayerFacing(); - - return lookDirection; - } - - @Override - public String toString() { - return "PrinterPlacementContext{" + - "lookDirection=" + lookDirection + - ", requiresSneaking=" + shouldSneak + - ", blockPos=" + hitResult.getBlockPos() + - ", side=" + hitResult.getSide() + -// ", hitVec=" + hitResult + - '}'; - } -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/implementation/mixin/MixinClientPlayerEntity.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/implementation/mixin/MixinClientPlayerEntity.java deleted file mode 100644 index 246d5670a..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/implementation/mixin/MixinClientPlayerEntity.java +++ /dev/null @@ -1,102 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19.implementation.mixin; - -import com.mojang.authlib.GameProfile; -import fi.dy.masa.litematica.world.SchematicWorldHandler; -import fi.dy.masa.litematica.world.WorldSchematic; -import me.aleksilassila.litematica.printer.v1_19.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_19.Printer; -import me.aleksilassila.litematica.printer.v1_19.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19.UpdateChecker; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.block.entity.SignBlockEntity; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.AbstractClientPlayerEntity; -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.network.encryption.PlayerPublicKey; -import net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket; -import net.minecraft.text.Text; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -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; - -import java.util.Optional; - -@Mixin(ClientPlayerEntity.class) -public class MixinClientPlayerEntity extends AbstractClientPlayerEntity { - private static boolean didCheckForUpdates = false; - - @Shadow - protected MinecraftClient client; - @Shadow - public ClientPlayNetworkHandler networkHandler; - - public MixinClientPlayerEntity(ClientWorld world, GameProfile profile, @Nullable PlayerPublicKey publicKey) { - super(world, profile, publicKey); - } - - @Inject(at = @At("TAIL"), method = "tick") - public void tick(CallbackInfo ci) { - ClientPlayerEntity clientPlayer = (ClientPlayerEntity) (Object) this; - if (!didCheckForUpdates) { - didCheckForUpdates = true; - - checkForUpdates(); - } - - if (LitematicaMixinMod.printer == null || LitematicaMixinMod.printer.player != clientPlayer) { - System.out.println("Initializing printer, player: " + clientPlayer + ", client: " + client); - LitematicaMixinMod.printer = new Printer(client, clientPlayer); - } - - // Dirty optimization - boolean didFindPlacement = true; - for (int i = 0; i < 10; i++) { - if (didFindPlacement) { - didFindPlacement = LitematicaMixinMod.printer.onGameTick(); - } - LitematicaMixinMod.printer.actionHandler.onGameTick(); - } - } - - public void checkForUpdates() { - new Thread(() -> { - String version = UpdateChecker.version; - String newVersion = UpdateChecker.getPrinterVersion(); - - if (!version.equals(newVersion)) { - client.inGameHud.getChatHud().addMessage(Text.literal("New version of Litematica Printer available in https://github.com/aleksilassila/litematica-printer/releases")); - } - }).start(); - } - - @Inject(method = "openEditSignScreen", at = @At("HEAD"), cancellable = true) - public void openEditSignScreen(SignBlockEntity sign, CallbackInfo ci) { - getTargetSignEntity(sign).ifPresent(signBlockEntity -> { - UpdateSignC2SPacket packet = new UpdateSignC2SPacket(sign.getPos(), - signBlockEntity.getTextOnRow(0, false).getString(), - signBlockEntity.getTextOnRow(1, false).getString(), - signBlockEntity.getTextOnRow(2, false).getString(), - signBlockEntity.getTextOnRow(3, false).getString()); - this.networkHandler.sendPacket(packet); - ci.cancel(); - }); - } - - private Optional getTargetSignEntity(SignBlockEntity sign) { - WorldSchematic worldSchematic = SchematicWorldHandler.getSchematicWorld(); - SchematicBlockState state = new SchematicBlockState(sign.getWorld(), worldSchematic, sign.getPos()); - - BlockEntity targetBlockEntity = worldSchematic.getBlockEntity(state.blockPos); - - if (targetBlockEntity instanceof SignBlockEntity targetSignEntity) { - return Optional.of(targetSignEntity); - } - - return Optional.empty(); - } -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/mixin/InputHandlerMixin.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/mixin/InputHandlerMixin.java deleted file mode 100644 index f2bc30d5c..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/mixin/InputHandlerMixin.java +++ /dev/null @@ -1,25 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19.mixin; - -import fi.dy.masa.litematica.event.InputHandler; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import me.aleksilassila.litematica.printer.v1_19.LitematicaMixinMod; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.List; - -@Mixin(value = InputHandler.class, remap = false) -public class InputHandlerMixin { - - @Redirect(method = "addHotkeys", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private List moreHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } - - @Redirect(method = "addKeysToMap", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private List moreeHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } - -} diff --git a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/mixin/PlayerMoveC2SPacketMixin.java b/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/mixin/PlayerMoveC2SPacketMixin.java deleted file mode 100644 index 1d84ad9ef..000000000 --- a/v1_19/src/main/java/me/aleksilassila/litematica/printer/v1_19/mixin/PlayerMoveC2SPacketMixin.java +++ /dev/null @@ -1,36 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19.mixin; - -import me.aleksilassila.litematica.printer.v1_19.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_19.Printer; -import me.aleksilassila.litematica.printer.v1_19.actions.PrepareAction; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; - -@Mixin(PlayerMoveC2SPacket.class) -public class PlayerMoveC2SPacketMixin { - @ModifyVariable(method = "(DDDFFZZZ)V", at = @At("HEAD"), ordinal = 0) - private static float modifyLookYaw(float yaw) { - Printer printer = LitematicaMixinMod.printer; - if (printer == null) return yaw; - - PrepareAction action = printer.actionHandler.lookAction; - if (action != null && action.modifyYaw) { - if (LitematicaMixinMod.DEBUG) System.out.println("YAW: " + action.yaw); - return action.yaw; - } else return yaw; - } - - @ModifyVariable(method = "(DDDFFZZZ)V", at = @At("HEAD"), ordinal = 1) - private static float modifyLookPitch(float pitch) { - Printer printer = LitematicaMixinMod.printer; - if (printer == null) return pitch; - - PrepareAction action = printer.actionHandler.lookAction; - if (action != null && action.modifyPitch) { - if (LitematicaMixinMod.DEBUG) System.out.println("PITCH: " + action.pitch); - return action.pitch; - } else return pitch; - } -} diff --git a/v1_19/src/main/resources/assets/modid/icon.png b/v1_19/src/main/resources/assets/modid/icon.png deleted file mode 100644 index 047b91f2347de5cf95f23284476fddbe21ba23fe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 453 zcmV;$0XqJPP)QAFYGys`80vegN0XDFh0OXKz&i8?Le#x7{1X)R+00000NkvXXu0mjf73i~T diff --git a/v1_19/src/main/resources/fabric.mod.json b/v1_19/src/main/resources/fabric.mod.json deleted file mode 100644 index 71cf6f96a..000000000 --- a/v1_19/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "schemaVersion": 1, - "id": "litematica_printer", - "version": "${version}", - "name": "Litematica Printer", - "description": "A fork of Litematica that adds the missing printer functionality", - "authors": [ - "aleksilassila" - ], - "contact": { - "homepage": "https://github.com/aleksilassila/litematica-printer", - "sources": "https://github.com/aleksilassila/litematica-printer" - }, - "license": "CC0-1.0", - "icon": "assets/modid/icon.png", - "environment": "*", - "entrypoints": { - "main": [ - "me.aleksilassila.litematica.printer.v1_19.LitematicaMixinMod" - ] - }, - "mixins": [ - "litematica-printer.mixins.json", - "litematica-printer-implementation.mixins.json" - ], - "depends": { - "fabricloader": ">=0.14.7", - "fabric": "*", - "minecraft": "1.19.x", - "java": ">=17" - }, - "custom": { - "modmenu": { - "parent": "carpet" - } - } -} - diff --git a/v1_19/src/main/resources/litematica-printer-implementation.mixins.json b/v1_19/src/main/resources/litematica-printer-implementation.mixins.json deleted file mode 100644 index 5705cb400..000000000 --- a/v1_19/src/main/resources/litematica-printer-implementation.mixins.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "me.aleksilassila.litematica.printer.v1_19.implementation.mixin", - "compatibilityLevel": "JAVA_16", - "mixins": [ - ], - "client": [ - "MixinClientPlayerEntity" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/v1_19_3/build.gradle.kts b/v1_19_3/build.gradle.kts deleted file mode 100644 index e224ded2b..000000000 --- a/v1_19_3/build.gradle.kts +++ /dev/null @@ -1,88 +0,0 @@ -plugins { - id("fabric-loom").version("1.0-SNAPSHOT") - id("maven-publish") -} - -java.sourceCompatibility = JavaVersion.VERSION_17 -java.targetCompatibility = JavaVersion.VERSION_17 - -val archives_base_name: String by project -val minecraft_version: String by project -val yarn_mappings: String by project -val loader_version: String by project -val fabric_version: String by project -val malilib_version: String by project -val litematica_projectid: String by project -val litematica_fileid: String by project - -val mod_version: String by project - -dependencies { -// implementation(project(":common")) - minecraft("com.mojang:minecraft:${minecraft_version}") - mappings("net.fabricmc:yarn:${yarn_mappings}:v2") - - modImplementation("net.fabricmc:fabric-loader:${loader_version}") - modImplementation("net.fabricmc.fabric-api:fabric-api:${fabric_version}") - modImplementation("fi.dy.masa.malilib:malilib-fabric-${malilib_version}") - modImplementation("curse.maven:litematica-${litematica_projectid}:${litematica_fileid}") -} - -repositories { - maven("https://masa.dy.fi/maven") - maven("https://www.cursemaven.com") -} - -// Process resources -tasks.withType { - inputs.property("version", mod_version) - - filesMatching("fabric.mod.json") { - expand(mapOf("version" to mod_version)) - } -} - -val sourceModule = "v1_19_3" -val targetModules = arrayOf("v1_17", "v1_18", "v1_19", "v1_19_4") - -fun copyFile(source: File) { - for (targetModule in targetModules) { - val destination = file(source.absolutePath.replace(sourceModule, targetModule)) - println("Copying ${source.absolutePath} to ${destination.absolutePath}") - destination.parentFile.mkdirs() - source.copyTo(destination, true) - destination.writeText(destination.readText().replace(sourceModule, targetModule)) - } -} - -fun deleteOldFiles(sourceBase: File) { - for (targetModule in targetModules) { - val targetBase = file(sourceBase.absolutePath.replace(sourceModule, targetModule)) - - for (file in targetBase.listFiles()) { - if (file.name.equals("implementation")) continue - println("Deleting recursively ${file.absolutePath}") - file.deleteRecursively() - } - } -} - -val syncImplementations = tasks.create("syncImplementations") { - doFirst { - val sourceStart = - this.project.projectDir.absolutePath + "/src/main/java/me/aleksilassila/litematica/printer/" + sourceModule - val sourceDir = file(sourceStart) - - deleteOldFiles(sourceDir) - - for (sourceFile in sourceDir.listFiles()) { - if (sourceFile.name.equals("implementation")) continue - - sourceFile.walk() - .filter { it.isFile } - .forEach { - copyFile(it) - } - } - } -} diff --git a/v1_19_3/gradle.properties b/v1_19_3/gradle.properties deleted file mode 100644 index d5d3c58de..000000000 --- a/v1_19_3/gradle.properties +++ /dev/null @@ -1,13 +0,0 @@ -# Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx1G -# https://masa.dy.fi/maven/fi/dy/masa/malilib/ -malilib_version=1.19.3:0.14.0 -# https://www.curseforge.com/minecraft/mc-mods/litematica/files -litematica_fileid=4162847 -litematica_projectid=308892 -# Fabric Properties: https://fabricmc.net/develop/ -minecraft_version=1.19.3 -yarn_mappings=1.19.3+build.3 -loader_version=0.14.11 -#Fabric api -fabric_version=0.69.1+1.19.3 diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/ActionHandler.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/ActionHandler.java deleted file mode 100644 index 482a5e02e..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/ActionHandler.java +++ /dev/null @@ -1,57 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3; - -import me.aleksilassila.litematica.printer.v1_19_3.actions.Action; -import me.aleksilassila.litematica.printer.v1_19_3.actions.PrepareAction; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; - -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; - -public class ActionHandler { - private final MinecraftClient client; - private final ClientPlayerEntity player; - - private final Queue actionQueue = new LinkedList<>(); - public PrepareAction lookAction = null; - - public ActionHandler(MinecraftClient client, ClientPlayerEntity player) { - this.client = client; - this.player = player; - } - - private int tick = 0; - - public void onGameTick() { - int tickRate = LitematicaMixinMod.PRINTING_INTERVAL.getIntegerValue(); - - tick = tick % tickRate == tickRate - 1 ? 0 : tick + 1; - if (tick % tickRate != 0) { - return; - } - - Action nextAction = actionQueue.poll(); - if (nextAction != null) { - if (LitematicaMixinMod.DEBUG) System.out.println("Sending action " + nextAction); - nextAction.send(client, player); - } else { - lookAction = null; - } - } - - public boolean acceptsActions() { - return actionQueue.isEmpty(); - } - - public void addActions(Action... actions) { - if (!acceptsActions()) return; - - for (Action action : actions) { - if (action instanceof PrepareAction) - lookAction = (PrepareAction) action; - } - - actionQueue.addAll(List.of(actions)); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/BlockHelper.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/BlockHelper.java deleted file mode 100644 index d1c09b41a..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/BlockHelper.java +++ /dev/null @@ -1,31 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3; - -import net.minecraft.block.*; -import net.minecraft.item.Item; -import net.minecraft.item.Items; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -abstract public class BlockHelper { - public static List> interactiveBlocks = new ArrayList<>(Arrays.asList( - AbstractChestBlock.class, AbstractFurnaceBlock.class, CraftingTableBlock.class, LeverBlock.class, - DoorBlock.class, TrapdoorBlock.class, BedBlock.class, RedstoneWireBlock.class, ScaffoldingBlock.class, - HopperBlock.class, EnchantingTableBlock.class, NoteBlock.class, JukeboxBlock.class, CakeBlock.class, - FenceGateBlock.class, BrewingStandBlock.class, DragonEggBlock.class, CommandBlock.class, - BeaconBlock.class, AnvilBlock.class, ComparatorBlock.class, RepeaterBlock.class, - DropperBlock.class, DispenserBlock.class, ShulkerBoxBlock.class, LecternBlock.class, - FlowerPotBlock.class, BarrelBlock.class, BellBlock.class, SmithingTableBlock.class, - LoomBlock.class, CartographyTableBlock.class, GrindstoneBlock.class, - StonecutterBlock.class, AbstractSignBlock.class, AbstractCandleBlock.class)); - - public static final Item[] SHOVEL_ITEMS = new Item[]{ - Items.NETHERITE_SHOVEL, - Items.DIAMOND_SHOVEL, - Items.GOLDEN_SHOVEL, - Items.IRON_SHOVEL, - Items.STONE_SHOVEL, - Items.WOODEN_SHOVEL - }; -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/LitematicaMixinMod.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/LitematicaMixinMod.java deleted file mode 100644 index 1460fe5a0..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/LitematicaMixinMod.java +++ /dev/null @@ -1,58 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3; - -import com.google.common.collect.ImmutableList; -import fi.dy.masa.litematica.config.Configs; -import fi.dy.masa.litematica.config.Hotkeys; -import fi.dy.masa.malilib.config.IConfigBase; -import fi.dy.masa.malilib.config.options.ConfigBoolean; -import fi.dy.masa.malilib.config.options.ConfigDouble; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import fi.dy.masa.malilib.config.options.ConfigInteger; -import fi.dy.masa.malilib.hotkeys.KeyCallbackToggleBooleanConfigWithMessage; -import fi.dy.masa.malilib.hotkeys.KeybindSettings; -import net.fabricmc.api.ModInitializer; - -import java.util.List; - -public class LitematicaMixinMod implements ModInitializer { - - public static Printer printer; - public static boolean DEBUG = false; - // Config settings - public static final ConfigInteger PRINTING_INTERVAL = new ConfigInteger("printingInterval", 12, 1, 40, "Printing interval. Lower values mean faster printing speed.\nIf the printer creates \"ghost blocks\" or blocks are facing the wrong way, raise this value."); - public static final ConfigDouble PRINTING_RANGE = new ConfigDouble("printingRange", 5, 2.5, 5, "Printing block place range\nLower values are recommended for servers."); - // public static final ConfigBoolean PRINT_WATER = new ConfigBoolean("printWater", false, "Whether the printer should place water\n source blocks or make blocks waterlogged."); -// public static final ConfigBoolean PRINT_IN_AIR = new ConfigBoolean("printInAir", true, "Whether or not the printer should place blocks without anything to build on.\nBe aware that some anti-cheat plugins might notice this."); - public static final ConfigBoolean PRINT_MODE = new ConfigBoolean("printingMode", false, "Autobuild / print loaded selection.\nBe aware that some servers and anticheat plugins do not allow printing."); - public static final ConfigBoolean REPLACE_FLUIDS_SOURCE_BLOCKS = new ConfigBoolean("replaceFluidSourceBlocks", true, "Whether or not fluid source blocks should be replaced by the printer."); - public static final ConfigBoolean STRIP_LOGS = new ConfigBoolean("stripLogs", true, "Whether or not the printer should use normal logs if stripped\nversions are not available and then strip them with an axe."); - - public static ImmutableList getConfigList() { - List list = new java.util.ArrayList<>(Configs.Generic.OPTIONS); - list.add(PRINT_MODE); - list.add(PRINTING_INTERVAL); - list.add(PRINTING_RANGE); -// list.add(PRINT_IN_AIR); - list.add(REPLACE_FLUIDS_SOURCE_BLOCKS); - list.add(STRIP_LOGS); - - return ImmutableList.copyOf(list); - } - - // Hotkeys - public static final ConfigHotkey PRINT = new ConfigHotkey("print", "V", KeybindSettings.PRESS_ALLOWEXTRA_EMPTY, "Prints while pressed"); - public static final ConfigHotkey TOGGLE_PRINTING_MODE = new ConfigHotkey("togglePrintingMode", "CAPS_LOCK", KeybindSettings.PRESS_ALLOWEXTRA_EMPTY, "Allows quickly toggling on/off Printing mode"); - - public static List getHotkeyList() { - List list = new java.util.ArrayList<>(Hotkeys.HOTKEY_LIST); - list.add(PRINT); - list.add(TOGGLE_PRINTING_MODE); - - return ImmutableList.copyOf(list); - } - - @Override - public void onInitialize() { - TOGGLE_PRINTING_MODE.getKeybind().setCallback(new KeyCallbackToggleBooleanConfigWithMessage(PRINT_MODE)); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/Printer.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/Printer.java deleted file mode 100644 index 71b343819..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/Printer.java +++ /dev/null @@ -1,110 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3; - -import fi.dy.masa.litematica.data.DataManager; -import fi.dy.masa.litematica.util.RayTraceUtils; -import fi.dy.masa.litematica.world.SchematicWorldHandler; -import fi.dy.masa.litematica.world.WorldSchematic; -import me.aleksilassila.litematica.printer.v1_19_3.actions.Action; -import me.aleksilassila.litematica.printer.v1_19_3.guides.Guide; -import me.aleksilassila.litematica.printer.v1_19_3.guides.Guides; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerAbilities; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.RaycastContext; -import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -public class Printer { - @NotNull - public final ClientPlayerEntity player; - - public final ActionHandler actionHandler; - - private final Guides interactionGuides = new Guides(); - - public Printer(@NotNull MinecraftClient client, @NotNull ClientPlayerEntity player) { - this.player = player; - - this.actionHandler = new ActionHandler(client, player); - } - - public boolean onGameTick() { - WorldSchematic worldSchematic = SchematicWorldHandler.getSchematicWorld(); - - if (!actionHandler.acceptsActions()) return false; - - if (worldSchematic == null) return false; - - if (!LitematicaMixinMod.PRINT_MODE.getBooleanValue() && !LitematicaMixinMod.PRINT.getKeybind().isPressed()) - return false; - - PlayerAbilities abilities = player.getAbilities(); - if (!abilities.allowModifyWorld) - return false; - - List positions = getReachablePositions(); - findBlock: - for (BlockPos position : positions) { - SchematicBlockState state = new SchematicBlockState(player.world, worldSchematic, position); - if (state.targetState.equals(state.currentState) || state.targetState.isAir()) continue; - - Guide[] guides = interactionGuides.getInteractionGuides(state); - - BlockHitResult result = RayTraceUtils.traceToSchematicWorld(player, 10, true, true); - boolean isCurrentlyLookingSchematic = result != null && result.getBlockPos().equals(position); - - for (Guide guide : guides) { - if (guide.canExecute(player)) { - System.out.println("Executing " + guide + " for " + state); - List actions = guide.execute(player); - actionHandler.addActions(actions.toArray(Action[]::new)); - return true; - } - if (guide.skipOtherGuides()) continue findBlock; - } - } - - return false; - } - - private List getReachablePositions() { - int maxReach = (int) Math.ceil(LitematicaMixinMod.PRINTING_RANGE.getDoubleValue()); - double maxReachSquared = MathHelper.square(LitematicaMixinMod.PRINTING_RANGE.getDoubleValue()); - - ArrayList positions = new ArrayList<>(); - - for (int y = -maxReach; y < maxReach + 1; y++) { - for (int x = -maxReach; x < maxReach + 1; x++) { - for (int z = -maxReach; z < maxReach + 1; z++) { - BlockPos blockPos = player.getBlockPos().north(x).west(z).up(y); - - if (!DataManager.getRenderLayerRange().isPositionWithinRange(blockPos)) continue; - if (this.player.getEyePos().squaredDistanceTo(Vec3d.ofCenter(blockPos)) > maxReachSquared) { - continue; - } - - positions.add(blockPos); - } - } - } - - return positions.stream() - .filter(p -> { - Vec3d vec = Vec3d.ofCenter(p); - return this.player.getPos().squaredDistanceTo(vec) > 1 && this.player.getEyePos().squaredDistanceTo(vec) > 1; - }) - .sorted((a, b) -> { - double aDistance = this.player.getPos().squaredDistanceTo(Vec3d.ofCenter(a)); - double bDistance = this.player.getPos().squaredDistanceTo(Vec3d.ofCenter(b)); - return Double.compare(aDistance, bDistance); - }).toList(); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/SchematicBlockState.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/SchematicBlockState.java deleted file mode 100644 index d8cd3549a..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/SchematicBlockState.java +++ /dev/null @@ -1,42 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3; - -import fi.dy.masa.litematica.world.WorldSchematic; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.World; - -public class SchematicBlockState { - public final World world; - public final WorldSchematic schematic; - - public final BlockPos blockPos; - - public final BlockState targetState; - public final BlockState currentState; - - public SchematicBlockState(World world, WorldSchematic schematic, BlockPos blockPos) { - this.world = world; - this.schematic = schematic; - - this.blockPos = blockPos; - - this.targetState = schematic.getBlockState(blockPos); - this.currentState = world.getBlockState(blockPos); - } - - public SchematicBlockState offset(Direction direction) { - return new SchematicBlockState(world, schematic, blockPos.offset(direction)); - } - - @Override - public String toString() { - return "SchematicBlockState{" + - "world=" + world + - ", schematic=" + schematic + - ", blockPos=" + blockPos + - ", targetState=" + targetState + - ", currentState=" + currentState + - '}'; - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/UpdateChecker.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/UpdateChecker.java deleted file mode 100644 index 76edbcb71..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/UpdateChecker.java +++ /dev/null @@ -1,49 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import org.apache.commons.io.IOUtils; - -import java.io.BufferedReader; -import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.util.Scanner; - -public class UpdateChecker { - public static final String version = "v3.2"; - - // Try to get this to work at some point -// static { -// try (InputStream in = UpdateChecker.class.getResourceAsStream("/fabric.mod.json")) { -// String jsonString = IOUtils.toString(in, StandardCharsets.UTF_8); -// JsonObject json = JsonParser.parseString(jsonString).getAsJsonObject(); -// System.out.println("JSON object: " + json); -// System.out.println("Raw json: " + jsonString); -// System.out.println("File: " + new File(UpdateChecker.class.getResource("/fabric.mod.json").getFile())); -// String version = json.get("version").getAsString(); -// System.out.println("Reading fabric.mod.json"); -// System.out.println("Parsed version: " + version); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } - - @SuppressWarnings("deprecation") - public static String getPrinterVersion() { - try (InputStream inputStream = new URL("https://api.github.com/repos/aleksilassila/litematica-printer/tags").openStream(); Scanner scanner = new Scanner(inputStream)) { - if (scanner.hasNext()) { - JsonArray tags = new JsonParser().parse(scanner.next()).getAsJsonArray(); - return ((JsonObject) tags.get(0)).get("name").getAsString(); - } - } catch (Exception exception) { - System.out.println("Cannot look for updates: " + exception.getMessage()); - } - - return ""; - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/actions/Action.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/actions/Action.java deleted file mode 100644 index f5e0635ec..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/actions/Action.java +++ /dev/null @@ -1,8 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.actions; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; - -public abstract class Action { - abstract public void send(MinecraftClient client, ClientPlayerEntity player); -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/actions/InteractAction.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/actions/InteractAction.java deleted file mode 100644 index 22b72d1c3..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/actions/InteractAction.java +++ /dev/null @@ -1,33 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.actions; - -import me.aleksilassila.litematica.printer.v1_19_3.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_19_3.implementation.PrinterPlacementContext; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; - -abstract public class InteractAction extends Action { - public final PrinterPlacementContext context; - - public InteractAction(PrinterPlacementContext context) { - this.context = context; - } - - protected abstract void interact(MinecraftClient client, ClientPlayerEntity player, Hand hand, BlockHitResult hitResult); - - @Override - public void send(MinecraftClient client, ClientPlayerEntity player) { - interact(client, player, Hand.MAIN_HAND, context.hitResult); - - if (LitematicaMixinMod.DEBUG) - System.out.println("InteractAction.send: Blockpos: " + context.getBlockPos() + " Side: " + context.getSide() + " HitPos: " + context.getHitPos()); - } - - @Override - public String toString() { - return "InteractAction{" + - "context=" + context + - '}'; - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/actions/PrepareAction.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/actions/PrepareAction.java deleted file mode 100644 index 75b09b528..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/actions/PrepareAction.java +++ /dev/null @@ -1,109 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.actions; - -import me.aleksilassila.litematica.printer.v1_19_3.implementation.PrinterPlacementContext; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; -import net.minecraft.util.Hand; -import net.minecraft.util.math.Direction; - -public class PrepareAction extends Action { -// public final Direction lookDirection; -// public final boolean requireSneaking; -// public final Item item; - -// public PrepareAction(Direction lookDirection, boolean requireSneaking, Item item) { -// this.lookDirection = lookDirection; -// this.requireSneaking = requireSneaking; -// this.item = item; -// } -// -// public PrepareAction(Direction lookDirection, boolean requireSneaking, BlockState requiredState) { -// this(lookDirection, requireSneaking, requiredState.getBlock().asItem()); -// } - - public final PrinterPlacementContext context; - - public boolean modifyYaw = true; - public boolean modifyPitch = true; - public float yaw = 0; - public float pitch = 0; - - public PrepareAction(PrinterPlacementContext context) { - this.context = context; - - Direction lookDirection = context.lookDirection; - - if (lookDirection != null && lookDirection.getAxis().isHorizontal()) { - this.yaw = lookDirection.asRotation(); - } else { - this.modifyYaw = false; - } - - if (lookDirection == Direction.UP) { - this.pitch = -90; - } else if (lookDirection == Direction.DOWN) { - this.pitch = 90; - } else if (lookDirection != null) { - this.pitch = 0; - } else { - this.modifyPitch = false; - } - } - - public PrepareAction(PrinterPlacementContext context, float yaw, float pitch) { - this.context = context; - - this.yaw = yaw; - this.pitch = pitch; - } - - @Override - public void send(MinecraftClient client, ClientPlayerEntity player) { - ItemStack itemStack = context.getStack(); - int slot = context.requiredItemSlot; - - if (itemStack != null) { - PlayerInventory inventory = player.getInventory(); - - // This thing is straight from MinecraftClient#doItemPick() - if (player.getAbilities().creativeMode) { - inventory.addPickBlock(itemStack); - client.interactionManager.clickCreativeStack(player.getStackInHand(Hand.MAIN_HAND), 36 + inventory.selectedSlot); - } else if (slot != -1) { - if (PlayerInventory.isValidHotbarIndex(slot)) { - inventory.selectedSlot = slot; - } else { - client.interactionManager.pickFromInventory(slot); - } - } - } - - if (modifyPitch || modifyYaw) { - float yaw = modifyYaw ? this.yaw : player.getYaw(); - float pitch = modifyPitch ? this.pitch : player.getPitch(); - - PlayerMoveC2SPacket packet = new PlayerMoveC2SPacket.Full(player.getX(), player.getY(), player.getZ(), yaw, pitch, player.isOnGround()); - - player.networkHandler.sendPacket(packet); - } - - if (context.shouldSneak) { - player.input.sneaking = true; - player.networkHandler.sendPacket(new ClientCommandC2SPacket(player, ClientCommandC2SPacket.Mode.PRESS_SHIFT_KEY)); - } else { - player.input.sneaking = false; - player.networkHandler.sendPacket(new ClientCommandC2SPacket(player, ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY)); - } - } - - @Override - public String toString() { - return "PrepareAction{" + - "context=" + context + - '}'; - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/actions/ReleaseShiftAction.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/actions/ReleaseShiftAction.java deleted file mode 100644 index cf8f94ff9..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/actions/ReleaseShiftAction.java +++ /dev/null @@ -1,13 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.actions; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; - -public class ReleaseShiftAction extends Action { - @Override - public void send(MinecraftClient client, ClientPlayerEntity player) { - player.input.sneaking = false; - player.networkHandler.sendPacket(new ClientCommandC2SPacket(player, ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY)); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/Guide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/Guide.java deleted file mode 100644 index cca5fa05f..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/Guide.java +++ /dev/null @@ -1,130 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides; - -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19_3.actions.Action; -import me.aleksilassila.litematica.printer.v1_19_3.implementation.BlockHelperImpl; -import net.minecraft.block.BlockState; -import net.minecraft.block.CoralBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.state.property.Properties; -import net.minecraft.state.property.Property; -import org.jetbrains.annotations.NotNull; - -import java.util.List; -import java.util.Optional; - -abstract public class Guide extends BlockHelperImpl { - protected final SchematicBlockState state; - protected final BlockState currentState; - protected final BlockState targetState; - - public Guide(SchematicBlockState state) { - this.state = state; - - this.currentState = state.currentState; - this.targetState = state.targetState; - } - - protected boolean playerHasRightItem(ClientPlayerEntity player) { - return getRequiredItemStackSlot(player) != -1; - } - - protected int getSlotWithItem(ClientPlayerEntity player, ItemStack itemStack) { - PlayerInventory inventory = player.getInventory(); - - for (int i = 0; i < inventory.main.size(); ++i) { - if (itemStack.isEmpty() && inventory.main.get(i).isOf(itemStack.getItem())) return i; - if (!inventory.main.get(i).isEmpty() && inventory.main.get(i).isItemEqual(itemStack)) { - return i; - } - } - - return -1; - } - - protected int getRequiredItemStackSlot(ClientPlayerEntity player) { - if (player.getAbilities().creativeMode) { - return player.getInventory().selectedSlot; - } - - Optional requiredItem = getRequiredItem(player); - if (requiredItem.isEmpty()) return -1; - - return getSlotWithItem(player, requiredItem.get()); - } - - public boolean canExecute(ClientPlayerEntity player) { - if (!playerHasRightItem(player)) return false; - - BlockState targetState = state.targetState; - BlockState currentState = state.currentState; - - return !statesEqual(targetState, currentState); - } - - abstract public @NotNull List execute(ClientPlayerEntity player); - - abstract protected @NotNull List getRequiredItems(); - - /** - * Returns the first required item that player has access to, - * or empty if the items are inaccessible. - */ - protected Optional getRequiredItem(ClientPlayerEntity player) { - List requiredItems = getRequiredItems(); - - for (ItemStack requiredItem : requiredItems) { - if (player.getAbilities().creativeMode) return Optional.of(requiredItem); - - int slot = getSlotWithItem(player, requiredItem); - if (slot > -1) - return Optional.of(requiredItem); - } - - return Optional.empty(); - } - - protected boolean statesEqualIgnoreProperties(BlockState state1, BlockState state2, Property... propertiesToIgnore) { - if (state1.getBlock() != state2.getBlock()) return false; - - loop: - for (Property property : state1.getProperties()) { - if (property == Properties.WATERLOGGED && !(state1.getBlock() instanceof CoralBlock)) continue; - - for (Property ignoredProperty : propertiesToIgnore) { - if (property == ignoredProperty) continue loop; - } - - try { - if (state1.get(property) != state2.get(property)) { - return false; - } - } catch (Exception e) { - return false; - } - } - - return true; - } - - protected static > Optional getProperty(BlockState blockState, Property property) { - if (blockState.contains(property)) { - return Optional.of(blockState.get(property)); - } - return Optional.empty(); - } - - /** - * Returns true if - */ - protected boolean statesEqual(BlockState state1, BlockState state2) { - return statesEqualIgnoreProperties(state1, state2); - } - - public boolean skipOtherGuides() { - return false; - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/Guides.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/Guides.java deleted file mode 100644 index 543170932..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/Guides.java +++ /dev/null @@ -1,81 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides; - -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19_3.guides.interaction.*; -import me.aleksilassila.litematica.printer.v1_19_3.guides.placement.*; -import net.minecraft.block.*; -import net.minecraft.util.Pair; - -import java.util.ArrayList; - -public class Guides { - protected final static ArrayList, Class[]>> guides = new ArrayList<>(); - - @SafeVarargs - protected static void registerGuide(Class guideClass, Class... blocks) { - guides.add(new Pair<>(guideClass, blocks)); - } - - static { -// registerGuide(SkipGuide.class, AbstractSignBlock.class, SkullBlock.class, BannerBlock.class); - - registerGuide(RotatingBlockGuide.class, AbstractSkullBlock.class, AbstractSignBlock.class, AbstractBannerBlock.class); - registerGuide(SlabGuide.class, SlabBlock.class); - registerGuide(TorchGuide.class, TorchBlock.class); - registerGuide(FarmlandGuide.class, FarmlandBlock.class); - registerGuide(TillingGuide.class, FarmlandBlock.class); - registerGuide(RailGuesserGuide.class, AbstractRailBlock.class); - registerGuide(ChestGuide.class, ChestBlock.class); - registerGuide(FlowerPotGuide.class, FlowerPotBlock.class); - registerGuide(FlowerPotFillGuide.class, FlowerPotBlock.class); - - registerGuide(PropertySpecificGuesserGuide.class, - RepeaterBlock.class, ComparatorBlock.class, RedstoneWireBlock.class, RedstoneTorchBlock.class, - BambooBlock.class, CactusBlock.class, SaplingBlock.class, ScaffoldingBlock.class, PointedDripstoneBlock.class, - HorizontalConnectingBlock.class, DoorBlock.class, TrapdoorBlock.class, FenceGateBlock.class, ChestBlock.class, - SnowBlock.class, SeaPickleBlock.class, CandleBlock.class, LeverBlock.class, EndPortalFrameBlock.class, - NoteBlock.class, CampfireBlock.class, PoweredRailBlock.class, LeavesBlock.class, TripwireHookBlock.class); - registerGuide(FallingBlockGuide.class, FallingBlock.class); - registerGuide(BlockIndifferentGuesserGuide.class, BambooBlock.class, BigDripleafStemBlock.class, BigDripleafBlock.class, - TwistingVinesPlantBlock.class, TripwireBlock.class); - - registerGuide(CampfireExtinguishGuide.class, CampfireBlock.class); - registerGuide(LightCandleGuide.class, AbstractCandleBlock.class); - registerGuide(EnderEyeGuide.class, EndPortalFrameBlock.class); - registerGuide(CycleStateGuide.class, - DoorBlock.class, FenceGateBlock.class, TrapdoorBlock.class, - LeverBlock.class, - RepeaterBlock.class, ComparatorBlock.class, NoteBlock.class); - registerGuide(BlockReplacementGuide.class, SnowBlock.class, SeaPickleBlock.class, CandleBlock.class, SlabBlock.class); - registerGuide(LogGuide.class); - registerGuide(LogStrippingGuide.class); - registerGuide(GuesserGuide.class); - } - - public ArrayList, Class[]>> getGuides() { - return guides; - } - - public Guide[] getInteractionGuides(SchematicBlockState state) { - ArrayList, Class[]>> guides = getGuides(); - - ArrayList applicableGuides = new ArrayList<>(); - for (Pair, Class[]> guidePair : guides) { - try { - if (guidePair.getRight().length == 0) { - applicableGuides.add(guidePair.getLeft().getConstructor(SchematicBlockState.class).newInstance(state)); - continue; - } - - for (Class clazz : guidePair.getRight()) { - if (clazz.isInstance(state.targetState.getBlock())) { - applicableGuides.add(guidePair.getLeft().getConstructor(SchematicBlockState.class).newInstance(state)); - } - } - } catch (Exception ignored) { - } - } - - return applicableGuides.toArray(Guide[]::new); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/SkipGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/SkipGuide.java deleted file mode 100644 index 9084efad8..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/SkipGuide.java +++ /dev/null @@ -1,37 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides; - -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19_3.actions.Action; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class SkipGuide extends Guide { - public SkipGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - return false; - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - return new ArrayList<>(); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(ItemStack.EMPTY); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/CampfireExtinguishGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/CampfireExtinguishGuide.java deleted file mode 100644 index 79d90c3b6..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/CampfireExtinguishGuide.java +++ /dev/null @@ -1,36 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import net.minecraft.block.CampfireBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; - -public class CampfireExtinguishGuide extends InteractionGuide { - boolean shouldBeLit; - boolean isLit; - - public CampfireExtinguishGuide(SchematicBlockState state) { - super(state); - - shouldBeLit = getProperty(targetState, CampfireBlock.LIT).orElse(false); - isLit = getProperty(currentState, CampfireBlock.LIT).orElse(false); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return (currentState.getBlock() instanceof CampfireBlock) && !shouldBeLit && isLit; - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(SHOVEL_ITEMS).map(ItemStack::new).toList(); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/CycleStateGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/CycleStateGuide.java deleted file mode 100644 index 8fadeabae..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/CycleStateGuide.java +++ /dev/null @@ -1,45 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.LeverBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.state.property.Properties; -import net.minecraft.state.property.Property; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class CycleStateGuide extends InteractionGuide { - private static final Property[] propertiesToIgnore = new Property[]{ - Properties.POWERED, - Properties.LIT - }; - - public CycleStateGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return targetState.getBlock() == currentState.getBlock(); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(ItemStack.EMPTY); - } - - @Override - protected boolean statesEqual(BlockState state1, BlockState state2) { - if (state2.getBlock() instanceof LeverBlock) { - return super.statesEqual(state1, state2); - } - - return statesEqualIgnoreProperties(state1, state2, propertiesToIgnore); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/EnderEyeGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/EnderEyeGuide.java deleted file mode 100644 index 72e81e6eb..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/EnderEyeGuide.java +++ /dev/null @@ -1,33 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.state.property.Properties; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class EnderEyeGuide extends InteractionGuide { - public EnderEyeGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - if (currentState.contains(Properties.EYE) && targetState.contains(Properties.EYE)) { - return !currentState.get(Properties.EYE) && targetState.get(Properties.EYE); - } - - return false; - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(new ItemStack(Items.ENDER_EYE)); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/FlowerPotFillGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/FlowerPotFillGuide.java deleted file mode 100644 index bed6a13ad..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/FlowerPotFillGuide.java +++ /dev/null @@ -1,40 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import net.minecraft.block.Block; -import net.minecraft.block.FlowerPotBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class FlowerPotFillGuide extends InteractionGuide { - private final Block content; - - public FlowerPotFillGuide(SchematicBlockState state) { - super(state); - - Block targetBlock = state.targetState.getBlock(); - if (targetBlock instanceof FlowerPotBlock) { - this.content = ((FlowerPotBlock) targetBlock).getContent(); - } else { - this.content = null; - } - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (content == null) return false; - if (!(currentState.getBlock() instanceof FlowerPotBlock)) return false; - - return super.canExecute(player); - } - - @Override - protected @NotNull List getRequiredItems() { - if (content == null) return Collections.emptyList(); - else return Collections.singletonList(new ItemStack(content)); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/InteractionGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/InteractionGuide.java deleted file mode 100644 index 764f2e080..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/InteractionGuide.java +++ /dev/null @@ -1,49 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_19_3.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19_3.actions.Action; -import me.aleksilassila.litematica.printer.v1_19_3.actions.PrepareAction; -import me.aleksilassila.litematica.printer.v1_19_3.actions.ReleaseShiftAction; -import me.aleksilassila.litematica.printer.v1_19_3.guides.Guide; -import me.aleksilassila.litematica.printer.v1_19_3.implementation.actions.InteractActionImpl; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.List; - -/** - * A guide that clicks the current block to change its state. - */ -public abstract class InteractionGuide extends Guide { - public InteractionGuide(SchematicBlockState state) { - super(state); - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - List actions = new ArrayList<>(); - - BlockHitResult hitResult = new BlockHitResult(Vec3d.ofCenter(state.blockPos), Direction.UP, state.blockPos, false); - ItemStack requiredItem = getRequiredItem(player).orElse(ItemStack.EMPTY); - int requiredSlot = getRequiredItemStackSlot(player); - - if (requiredSlot == -1) return actions; - - PrinterPlacementContext ctx = new PrinterPlacementContext(player, hitResult, requiredItem, requiredSlot); - - actions.add(new ReleaseShiftAction()); - actions.add(new PrepareAction(ctx)); - actions.add(new InteractActionImpl(ctx)); - - return actions; - } - - @Override - abstract protected @NotNull List getRequiredItems(); -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/LightCandleGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/LightCandleGuide.java deleted file mode 100644 index 4f9124853..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/LightCandleGuide.java +++ /dev/null @@ -1,36 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import net.minecraft.block.AbstractCandleBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.state.property.Properties; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class LightCandleGuide extends InteractionGuide { - boolean shouldBeLit; - boolean isLit; - - public LightCandleGuide(SchematicBlockState state) { - super(state); - - shouldBeLit = getProperty(targetState, Properties.LIT).orElse(false); - isLit = getProperty(currentState, Properties.LIT).orElse(false); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(new ItemStack(Items.FLINT_AND_STEEL)); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return (currentState.getBlock() instanceof AbstractCandleBlock) && shouldBeLit && !isLit; - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/LogStrippingGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/LogStrippingGuide.java deleted file mode 100644 index 9664e11f3..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/LogStrippingGuide.java +++ /dev/null @@ -1,47 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_19_3.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19_3.mixin.AxeItemAccessor; -import net.minecraft.block.Block; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -public class LogStrippingGuide extends InteractionGuide { - static final Item[] AXE_ITEMS = new Item[]{ - Items.NETHERITE_AXE, - Items.DIAMOND_AXE, - Items.GOLDEN_AXE, - Items.IRON_AXE, - Items.STONE_AXE, - Items.WOODEN_AXE - }; - - public static final Map STRIPPED_BLOCKS = AxeItemAccessor.getStrippedBlocks(); - - public LogStrippingGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!LitematicaMixinMod.STRIP_LOGS.getBooleanValue()) return false; - - if (!super.canExecute(player)) return false; - - Block strippingResult = STRIPPED_BLOCKS.get(currentState.getBlock()); - return strippingResult == targetState.getBlock(); - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(AXE_ITEMS).map(ItemStack::new).toList(); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/TillingGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/TillingGuide.java deleted file mode 100644 index 13f4b75d0..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/interaction/TillingGuide.java +++ /dev/null @@ -1,39 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19_3.guides.placement.FarmlandGuide; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; - -public class TillingGuide extends InteractionGuide { - public static final Item[] HOE_ITEMS = new Item[]{ - Items.NETHERITE_HOE, - Items.DIAMOND_HOE, - Items.GOLDEN_HOE, - Items.IRON_HOE, - Items.STONE_HOE, - Items.WOODEN_HOE - }; - - public TillingGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return Arrays.stream(FarmlandGuide.TILLABLE_BLOCKS).anyMatch(b -> b == currentState.getBlock()); - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(HOE_ITEMS).map(ItemStack::new).toList(); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/BlockIndifferentGuesserGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/BlockIndifferentGuesserGuide.java deleted file mode 100644 index dc0f65d8a..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/BlockIndifferentGuesserGuide.java +++ /dev/null @@ -1,42 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import net.minecraft.block.*; - -public class BlockIndifferentGuesserGuide extends GuesserGuide { - public BlockIndifferentGuesserGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected boolean statesEqual(BlockState resultState, BlockState targetState) { - Block targetBlock = targetState.getBlock(); - Block resultBlock = resultState.getBlock(); - - if (targetBlock instanceof BambooBlock) { - return resultBlock instanceof BambooBlock || resultBlock instanceof BambooSaplingBlock; - } - - if (targetBlock instanceof BigDripleafStemBlock) { - if (resultBlock instanceof BigDripleafBlock || resultBlock instanceof BigDripleafStemBlock) { - return resultState.get(HorizontalFacingBlock.FACING) == targetState.get(HorizontalFacingBlock.FACING); - } - } - - if (targetBlock instanceof TwistingVinesPlantBlock) { - if (resultBlock instanceof TwistingVinesBlock) { - return true; - } else if (resultBlock instanceof TwistingVinesPlantBlock) { - return statesEqualIgnoreProperties(resultState, targetState, TwistingVinesBlock.AGE); - } - } - - if (targetBlock instanceof TripwireBlock && resultBlock instanceof TripwireBlock) { - return statesEqualIgnoreProperties(resultState, targetState, - TripwireBlock.ATTACHED, TripwireBlock.DISARMED, TripwireBlock.POWERED, TripwireBlock.NORTH, - TripwireBlock.EAST, TripwireBlock.SOUTH, TripwireBlock.WEST); - } - - return super.statesEqual(resultState, targetState); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/BlockReplacementGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/BlockReplacementGuide.java deleted file mode 100644 index 2c13c63bc..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/BlockReplacementGuide.java +++ /dev/null @@ -1,75 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_3.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import net.minecraft.block.CandleBlock; -import net.minecraft.block.SeaPickleBlock; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.SnowBlock; -import net.minecraft.block.enums.SlabType; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.state.property.IntProperty; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.Nullable; - -import java.util.HashMap; -import java.util.Optional; - -public class BlockReplacementGuide extends PlacementGuide { - private static final HashMap increasingProperties = new HashMap<>(); - - static { - increasingProperties.put(SnowBlock.LAYERS, null); - increasingProperties.put(SeaPickleBlock.PICKLES, null); - increasingProperties.put(CandleBlock.CANDLES, null); - } - - private Integer currentLevel = null; - private Integer targetLevel = null; - private IntProperty increasingProperty = null; - - public BlockReplacementGuide(SchematicBlockState state) { - super(state); - - for (IntProperty property : increasingProperties.keySet()) { - if (targetState.contains(property) && currentState.contains(property)) { - currentLevel = currentState.get(property); - targetLevel = targetState.get(property); - increasingProperty = property; - break; - } - } - } - - @Override - protected boolean getUseShift(SchematicBlockState state) { - return false; - } - - @Override - public @Nullable PrinterPlacementContext getPlacementContext(ClientPlayerEntity player) { - Optional requiredItem = getRequiredItem(player); - int slot = getRequiredItemStackSlot(player); - if (requiredItem.isEmpty() || slot == -1) return null; - - BlockHitResult hitResult = new BlockHitResult(Vec3d.ofCenter(state.blockPos), Direction.UP, state.blockPos, false); - return new PrinterPlacementContext(player, hitResult, requiredItem.get(), slot); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (getProperty(targetState, SlabBlock.TYPE).orElse(null) == SlabType.DOUBLE && getProperty(currentState, SlabBlock.TYPE).orElse(SlabType.DOUBLE) != SlabType.DOUBLE) { - return super.canExecute(player); - } - - if (currentLevel == null || targetLevel == null || increasingProperty == null) return false; - if (!statesEqualIgnoreProperties(currentState, targetState, CandleBlock.LIT, increasingProperty)) return false; - if (currentLevel >= targetLevel) return false; - - return super.canExecute(player); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/ChestGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/ChestGuide.java deleted file mode 100644 index 8983fc0d3..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/ChestGuide.java +++ /dev/null @@ -1,92 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.ChestBlock; -import net.minecraft.block.enums.ChestType; -import net.minecraft.util.math.Direction; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -/** - * Whilst making this guide, I learned that chests are much like humans. - * Some prefer to stay single, and some want to connect with another of its kind. - * Also that reversing chest connection logic is an enormous pain in the ass. I spent way too long on this. - * Thanks for coming to my ted talk - */ -public class ChestGuide extends GeneralPlacementGuide { - public ChestGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected boolean getRequiresExplicitShift() { - return true; - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - protected Optional getLookDirection() { - return getProperty(targetState, ChestBlock.FACING) - .flatMap(facing -> Optional.of(facing.getOpposite())); - } - - @Override - protected List getPossibleSides() { - ChestType targetType = getProperty(targetState, ChestBlock.CHEST_TYPE).orElse(null); - Direction targetFacing = getProperty(targetState, ChestBlock.FACING).orElse(null); - - List sides = new ArrayList<>(); - - if (targetFacing == null || targetType == null) return sides; - - for (Direction direction : Direction.values()) { - if (targetType == ChestType.SINGLE && !willConnectToSide(state, direction)) { - sides.add(direction); - } else if (wantsToConnectToSide(state, direction) && willConnectToSide(state, direction)) { // :D - sides.add(direction); - } - } - - // Place single chests if cannot connect any existing chests - if (sides.isEmpty()) { - for (Direction direction : Direction.values()) { - if (!wantsToConnectToSide(state, direction) && !willConnectToSide(state, direction)) { - sides.add(direction); - } - } - } - - return sides; - } - - private boolean willConnectToSide(SchematicBlockState state, Direction neighborDirection) { - BlockState neighbor = state.offset(neighborDirection).currentState; - ChestType neighborType = getProperty(neighbor, ChestBlock.CHEST_TYPE).orElse(null); - Direction neighborFacing = getProperty(neighbor, ChestBlock.FACING).orElse(null); - Direction facing = getProperty(state.targetState, ChestBlock.FACING).orElse(null); - - if (neighborType == null || neighborFacing == null || facing == null) return false; - - if (facing.getAxis() == neighborDirection.getAxis() || neighborDirection.getAxis() == Direction.Axis.Y) - return false; - - return neighborType == ChestType.SINGLE && neighborFacing == facing && state.targetState.getBlock() == neighbor.getBlock(); - } - - private boolean wantsToConnectToSide(SchematicBlockState state, Direction direction) { - ChestType type = getProperty(state.targetState, ChestBlock.CHEST_TYPE).orElse(null); - Direction facing = getProperty(state.targetState, ChestBlock.FACING).orElse(null); - if (type == null || facing == null || type == ChestType.SINGLE) return false; - - Direction neighborDirection = type == ChestType.LEFT ? facing.rotateYClockwise() : facing.rotateYCounterclockwise(); - - return direction == neighborDirection; - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/FallingBlockGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/FallingBlockGuide.java deleted file mode 100644 index 6b6f228d3..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/FallingBlockGuide.java +++ /dev/null @@ -1,37 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.FallingBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.math.Direction; - -public class FallingBlockGuide extends GuesserGuide { - - public FallingBlockGuide(SchematicBlockState state) { - super(state); - } - - boolean blockPlacement() { - if (targetState.getBlock() instanceof FallingBlock) { - BlockState below = state.world.getBlockState(state.blockPos.offset(Direction.DOWN)); - return FallingBlock.canFallThrough(below); - } - - return false; - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (blockPlacement()) return false; - - return super.canExecute(player); - } - - @Override - public boolean skipOtherGuides() { - if (blockPlacement()) return true; - - return super.skipOtherGuides(); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/FarmlandGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/FarmlandGuide.java deleted file mode 100644 index 38b033f24..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/FarmlandGuide.java +++ /dev/null @@ -1,29 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; - -public class FarmlandGuide extends GeneralPlacementGuide { - public static final Block[] TILLABLE_BLOCKS = new Block[]{ - Blocks.DIRT, - Blocks.GRASS_BLOCK, - Blocks.COARSE_DIRT, - Blocks.ROOTED_DIRT, - Blocks.DIRT_PATH, - }; - - public FarmlandGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(TILLABLE_BLOCKS).map(b -> getBlockItem(b.getDefaultState())).toList(); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/FlowerPotGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/FlowerPotGuide.java deleted file mode 100644 index 3c4fc2449..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/FlowerPotGuide.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class FlowerPotGuide extends GeneralPlacementGuide { - public FlowerPotGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(new ItemStack(Items.FLOWER_POT)); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/GeneralPlacementGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/GeneralPlacementGuide.java deleted file mode 100644 index 3315253e0..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/GeneralPlacementGuide.java +++ /dev/null @@ -1,119 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_3.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.enums.SlabType; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -/** - * An old school guide where there are defined specific conditions - * for player state depending on the block being placed. - */ -public class GeneralPlacementGuide extends PlacementGuide { - public GeneralPlacementGuide(SchematicBlockState state) { - super(state); - } - - protected List getPossibleSides() { - return Arrays.asList(Direction.values()); - } - - protected Optional getLookDirection() { - return Optional.empty(); - } - - protected boolean getRequiresSupport() { - return false; - } - - protected boolean getRequiresExplicitShift() { - return false; - } - - protected Vec3d getHitModifier(Direction validSide) { - return new Vec3d(0, 0, 0); - } - - private Optional getValidSide(SchematicBlockState state) { - boolean printInAir = false; // LitematicaMixinMod.PRINT_IN_AIR.getBooleanValue(); - - List sides = getPossibleSides(); - - if (sides.isEmpty()) { - return Optional.empty(); - } - - List validSides = new ArrayList<>(); - for (Direction side : sides) { - if (printInAir && !getRequiresSupport()) { - return Optional.of(side); - } else { - SchematicBlockState neighborState = state.offset(side); - - if (getProperty(neighborState.currentState, SlabBlock.TYPE).orElse(null) == SlabType.DOUBLE) { - validSides.add(side); - continue; - } - - if (canBeClicked(neighborState.world, neighborState.blockPos) && // Handle unclickable grass for example - !neighborState.currentState.getMaterial().isReplaceable()) - validSides.add(side); - } - } - - for (Direction validSide : validSides) { - if (!isInteractive(state.offset(validSide).currentState.getBlock())) { - return Optional.of(validSide); - } - } - - return validSides.isEmpty() ? Optional.empty() : Optional.of(validSides.get(0)); - } - - protected boolean getUseShift(SchematicBlockState state) { - if (getRequiresExplicitShift()) return true; - - Direction clickSide = getValidSide(state).orElse(null); - if (clickSide == null) return false; - return isInteractive(state.offset(clickSide).currentState.getBlock()); - } - - private Optional getHitVector(SchematicBlockState state) { - return getValidSide(state).map(side -> Vec3d.ofCenter(state.blockPos) - .add(Vec3d.of(side.getVector()).multiply(0.5)) - .add(getHitModifier(side))); - } - - @Nullable - public PrinterPlacementContext getPlacementContext(ClientPlayerEntity player) { - try { - Optional validSide = getValidSide(state); - Optional hitVec = getHitVector(state); - Optional requiredItem = getRequiredItem(player); - int requiredSlot = getRequiredItemStackSlot(player); - - if (validSide.isEmpty() || hitVec.isEmpty() || requiredItem.isEmpty() || requiredSlot == -1) return null; - - Optional lookDirection = getLookDirection(); - boolean requiresShift = getUseShift(state); - - BlockHitResult blockHitResult = new BlockHitResult(hitVec.get(), validSide.get().getOpposite(), state.blockPos.offset(validSide.get()), false); - - return new PrinterPlacementContext(player, blockHitResult, requiredItem.get(), requiredSlot, lookDirection.orElse(null), requiresShift); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/GuesserGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/GuesserGuide.java deleted file mode 100644 index dd235cac0..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/GuesserGuide.java +++ /dev/null @@ -1,110 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_3.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_19_3.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.ChestBlock; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.enums.ChestType; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.Nullable; - -/** - * This is the placement guide that most blocks will use. - * It will try to predict the correct player state for producing the right blockState - * by brute forcing the correct hit vector and look direction. - */ -public class GuesserGuide extends GeneralPlacementGuide { - private PrinterPlacementContext contextCache = null; - - protected static Direction[] directionsToTry = new Direction[]{ - Direction.NORTH, - Direction.SOUTH, - Direction.EAST, - Direction.WEST, - Direction.UP, - Direction.DOWN - }; - protected static Vec3d[] hitVecsToTry = new Vec3d[]{ - new Vec3d(-0.25, -0.25, -0.25), - new Vec3d(+0.25, -0.25, -0.25), - new Vec3d(-0.25, +0.25, -0.25), - new Vec3d(-0.25, -0.25, +0.25), - new Vec3d(+0.25, +0.25, -0.25), - new Vec3d(-0.25, +0.25, +0.25), - new Vec3d(+0.25, -0.25, +0.25), - new Vec3d(+0.25, +0.25, +0.25), - }; - - public GuesserGuide(SchematicBlockState state) { - super(state); - } - - @Nullable - @Override - public PrinterPlacementContext getPlacementContext(ClientPlayerEntity player) { - if (contextCache != null && !LitematicaMixinMod.DEBUG) return contextCache; - - ItemStack requiredItem = getRequiredItem(player).orElse(ItemStack.EMPTY); - int slot = getRequiredItemStackSlot(player); - - if (slot == -1) return null; - - for (Direction lookDirection : directionsToTry) { - for (Direction side : directionsToTry) { - BlockPos neighborPos = state.blockPos.offset(side); - BlockState neighborState = state.world.getBlockState(neighborPos); - boolean requiresShift = getRequiresExplicitShift() || isInteractive(neighborState.getBlock()); - - if (!canBeClicked(state.world, neighborPos) || // Handle unclickable grass for example - neighborState.getMaterial().isReplaceable()) - continue; - - Vec3d hitVec = Vec3d.ofCenter(state.blockPos) - .add(Vec3d.of(side.getVector()).multiply(0.5)); - - for (Vec3d hitVecToTry : hitVecsToTry) { - Vec3d multiplier = Vec3d.of(side.getVector()); - multiplier = new Vec3d(multiplier.x == 0 ? 1 : 0, multiplier.y == 0 ? 1 : 0, multiplier.z == 0 ? 1 : 0); - - BlockHitResult hitResult = new BlockHitResult(hitVec.add(hitVecToTry.multiply(multiplier)), side.getOpposite(), neighborPos, false); - PrinterPlacementContext context = new PrinterPlacementContext(player, hitResult, requiredItem, slot, lookDirection, requiresShift); - BlockState result = getRequiredItemAsBlock(player) - .orElse(targetState.getBlock()) - .getPlacementState(context); // FIXME torch shift clicks another torch and getPlacementState is the clicked block, which is true - - if (result != null && (statesEqual(result, targetState) || correctChestPlacement(targetState, result))) { - contextCache = context; - return context; - } - } - } - } - - return null; - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (targetState.getBlock() instanceof SlabBlock) return false; // Slabs are a special case - - return super.canExecute(player); - } - - private boolean correctChestPlacement(BlockState targetState, BlockState result) { - if (targetState.contains(ChestBlock.CHEST_TYPE) && result.contains(ChestBlock.CHEST_TYPE) && result.get(ChestBlock.FACING) == targetState.get(ChestBlock.FACING)) { - ChestType targetChestType = targetState.get(ChestBlock.CHEST_TYPE); - ChestType resultChestType = result.get(ChestBlock.CHEST_TYPE); - - return targetChestType != ChestType.SINGLE && resultChestType == ChestType.SINGLE; - } - - return false; - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/LogGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/LogGuide.java deleted file mode 100644 index 10e5be8aa..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/LogGuide.java +++ /dev/null @@ -1,54 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_3.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19_3.guides.interaction.LogStrippingGuide; -import net.minecraft.block.Block; -import net.minecraft.block.PillarBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.Direction; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -public class LogGuide extends GeneralPlacementGuide { - public LogGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - if (targetState.contains(PillarBlock.AXIS)) { - Direction.Axis axis = targetState.get(PillarBlock.AXIS); - return Arrays.stream(Direction.values()).filter(d -> d.getAxis() == axis).toList(); - } - - return new ArrayList<>(); - } - - @Override - protected @NotNull List getRequiredItems() { - for (Block log : LogStrippingGuide.STRIPPED_BLOCKS.keySet()) { - if (targetState.getBlock() == LogStrippingGuide.STRIPPED_BLOCKS.get(log)) { - return Collections.singletonList(new ItemStack(log)); - } - } - - return super.getRequiredItems(); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!LitematicaMixinMod.STRIP_LOGS.getBooleanValue()) return false; - - if (LogStrippingGuide.STRIPPED_BLOCKS.containsValue(targetState.getBlock())) { - return super.canExecute(player); - } - - return false; - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/PlacementGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/PlacementGuide.java deleted file mode 100644 index a28e84e8a..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/PlacementGuide.java +++ /dev/null @@ -1,138 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_3.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_19_3.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19_3.actions.Action; -import me.aleksilassila.litematica.printer.v1_19_3.actions.PrepareAction; -import me.aleksilassila.litematica.printer.v1_19_3.actions.ReleaseShiftAction; -import me.aleksilassila.litematica.printer.v1_19_3.guides.Guide; -import me.aleksilassila.litematica.printer.v1_19_3.implementation.actions.InteractActionImpl; -import net.minecraft.block.*; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.World; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -/** - * Guide that clicks its neighbors to create a placement in target position. - */ -abstract public class PlacementGuide extends Guide { - public PlacementGuide(SchematicBlockState state) { - super(state); - } - - protected ItemStack getBlockItem(BlockState state) { - return state.getBlock().getPickStack(this.state.world, this.state.blockPos, state); - } - - protected Optional getRequiredItemAsBlock(ClientPlayerEntity player) { - Optional requiredItem = getRequiredItem(player); - - if (requiredItem.isEmpty()) { - return Optional.empty(); - } else { - ItemStack itemStack = requiredItem.get(); - - if (itemStack.getItem() instanceof BlockItem) - return Optional.of(((BlockItem) itemStack.getItem()).getBlock()); - else return Optional.empty(); - } - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(getBlockItem(state.targetState)); - } - - abstract protected boolean getUseShift(SchematicBlockState state); - - @Nullable - abstract public PrinterPlacementContext getPlacementContext(ClientPlayerEntity player); - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - List requiredItems = getRequiredItems(); - if (requiredItems.isEmpty() || requiredItems.stream().allMatch(i -> i.isOf(Items.AIR))) - return false; - - ItemPlacementContext ctx = getPlacementContext(player); - if (ctx == null || !ctx.canPlace()) return false; -// if (!state.currentState.getMaterial().isReplaceable()) return false; - if (!LitematicaMixinMod.REPLACE_FLUIDS_SOURCE_BLOCKS.getBooleanValue() - && getProperty(state.currentState, FluidBlock.LEVEL).orElse(1) == 0) - return false; - - BlockState resultState = getRequiredItemAsBlock(player) - .orElse(targetState.getBlock()) - .getPlacementState(ctx); - - if (resultState != null) { - if (!resultState.canPlaceAt(state.world, state.blockPos)) return false; - return !(currentState.getBlock() instanceof FluidBlock) || canPlaceInWater(resultState); - } else { - return false; - } - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - List actions = new ArrayList<>(); - PrinterPlacementContext ctx = getPlacementContext(player); - - if (ctx == null) return actions; - actions.add(new PrepareAction(ctx)); - actions.add(new InteractActionImpl(ctx)); - if (ctx.shouldSneak) actions.add(new ReleaseShiftAction()); - - return actions; - } - - protected static boolean canBeClicked(World world, BlockPos pos) { - return getOutlineShape(world, pos) != VoxelShapes.empty() && !(world.getBlockState(pos).getBlock() instanceof AbstractSignBlock); // FIXME signs - } - - private static VoxelShape getOutlineShape(World world, BlockPos pos) { - return world.getBlockState(pos).getOutlineShape(world, pos); - } - - public boolean isInteractive(Block block) { - for (Class clazz : interactiveBlocks) { - if (clazz.isInstance(block)) { - return true; - } - } - - return false; - } - - private boolean canPlaceInWater(BlockState blockState) { - Block block = blockState.getBlock(); - if (block instanceof FluidFillable) { - return true; - } else if (!(block instanceof DoorBlock) && !(blockState.getBlock() instanceof AbstractSignBlock) && !blockState.isOf(Blocks.LADDER) && !blockState.isOf(Blocks.SUGAR_CANE) && !blockState.isOf(Blocks.BUBBLE_COLUMN)) { - Material material = blockState.getMaterial(); - if (material != Material.PORTAL && material != Material.STRUCTURE_VOID && material != Material.UNDERWATER_PLANT && material != Material.REPLACEABLE_UNDERWATER_PLANT) { - return material.blocksMovement(); - } else { - return true; - } - } - - return true; - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/PropertySpecificGuesserGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/PropertySpecificGuesserGuide.java deleted file mode 100644 index 92cdbb810..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/PropertySpecificGuesserGuide.java +++ /dev/null @@ -1,52 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import net.minecraft.block.*; -import net.minecraft.state.property.Properties; -import net.minecraft.state.property.Property; - -public class PropertySpecificGuesserGuide extends GuesserGuide { - protected static Property[] ignoredProperties = new Property[]{ - RepeaterBlock.DELAY, - ComparatorBlock.MODE, - RedstoneWireBlock.POWER, - RedstoneWireBlock.WIRE_CONNECTION_EAST, - RedstoneWireBlock.WIRE_CONNECTION_NORTH, - RedstoneWireBlock.WIRE_CONNECTION_SOUTH, - RedstoneWireBlock.WIRE_CONNECTION_WEST, - Properties.POWERED, - Properties.OPEN, - PointedDripstoneBlock.THICKNESS, - ScaffoldingBlock.DISTANCE, - ScaffoldingBlock.BOTTOM, - CactusBlock.AGE, - BambooBlock.AGE, - BambooBlock.LEAVES, - BambooBlock.STAGE, - SaplingBlock.STAGE, - HorizontalConnectingBlock.EAST, - HorizontalConnectingBlock.NORTH, - HorizontalConnectingBlock.SOUTH, - HorizontalConnectingBlock.WEST, - SnowBlock.LAYERS, - SeaPickleBlock.PICKLES, - CandleBlock.CANDLES, - EndPortalFrameBlock.EYE, - Properties.LIT, - LeavesBlock.DISTANCE, - LeavesBlock.PERSISTENT, - Properties.ATTACHED, - Properties.NOTE, - Properties.INSTRUMENT, - - }; - - public PropertySpecificGuesserGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected boolean statesEqual(BlockState resultState, BlockState targetState) { - return statesEqualIgnoreProperties(resultState, targetState, ignoredProperties); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/RailGuesserGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/RailGuesserGuide.java deleted file mode 100644 index 54ace0c67..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/RailGuesserGuide.java +++ /dev/null @@ -1,128 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.enums.RailShape; -import net.minecraft.state.property.Properties; -import net.minecraft.util.math.Direction; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -public class RailGuesserGuide extends GuesserGuide { - static final RailShape[] STRAIGHT_RAIL_SHAPES = new RailShape[]{ - RailShape.NORTH_SOUTH, - RailShape.EAST_WEST - }; - - public RailGuesserGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - protected boolean statesEqual(BlockState resultState, BlockState targetState) { - if (!wouldConnectCorrectly()) return false; -// if (wouldBlockAnotherConnection()) return false; - /*TODO: Fully working rail guesser - * If has a neighbor that: - * - Has not been placed yet - * - OR Has been placed but can change shape - * - AND this placement should connect to only one rail, that is not the neighbor - * Then return false - * */ - - if (getRailShape(resultState).isPresent()) { - if (Arrays.stream(STRAIGHT_RAIL_SHAPES).anyMatch(shape -> shape == getRailShape(resultState).orElse(null))) { - return super.statesEqualIgnoreProperties(resultState, targetState, Properties.RAIL_SHAPE, Properties.STRAIGHT_RAIL_SHAPE, Properties.POWERED); - } - } - - return super.statesEqual(resultState, targetState); - } - - private boolean wouldConnectCorrectly() { - RailShape targetShape = getRailShape(state.targetState).orElse(null); - if (targetShape == null) return false; - - List allowedConnections = getRailDirections(targetShape); - - List possibleConnections = new ArrayList<>(); - for (Direction d : Direction.values()) { - if (d.getAxis().isVertical()) continue; - SchematicBlockState neighbor = state.offset(d); - - if (hasFreeConnections(neighbor)) { - possibleConnections.add(d); - } - } - - if (possibleConnections.size() > 2) return false; - - return allowedConnections.containsAll(possibleConnections); - } - -// private boolean wouldBlockAnotherConnection() { -// List possibleConnections = new ArrayList<>(); -// -// for (Direction d : Direction.values()) { -// if (d.getAxis().isVertical()) continue; -// SchematicBlockState neighbor = state.offset(d); -// -// if (couldConnectWrongly(neighbor)) { -// possibleConnections.add(d); -// } -// } -// -// return possibleConnections.size() > 1; -// } - - private boolean hasFreeConnections(SchematicBlockState state) { - List possibleConnections = getRailDirections(state); - if (possibleConnections.isEmpty()) return false; - - for (Direction d : possibleConnections) { - SchematicBlockState neighbor = state.offset(d); - if (neighbor.currentState.getBlock() != neighbor.currentState.getBlock()) { - return false; - } - } - - return possibleConnections.stream().anyMatch(possibleDirection -> { - SchematicBlockState neighbor = state.offset(possibleDirection); - return !getRailDirections(neighbor).contains(possibleDirection.getOpposite()); - }); - } - - private List getRailDirections(SchematicBlockState state) { - RailShape shape = getRailShape(state.currentState).orElse(null); - if (shape == null) return new ArrayList<>(); - - return getRailDirections(shape); - } - - private List getRailDirections(RailShape railShape) { - String name = railShape.getName(); - - if (railShape.isAscending()) { - Direction d = Direction.valueOf(name.replace("ascending_", "").toUpperCase()); - return Arrays.asList(d, d.getOpposite()); - } else { - Direction d1 = Direction.valueOf(name.split("_")[0].toUpperCase()); - Direction d2 = Direction.valueOf(name.split("_")[1].toUpperCase()); - return Arrays.asList(d1, d2); - } - } - - Optional getRailShape(BlockState state) { - Optional shape = getProperty(state, Properties.RAIL_SHAPE); - if (shape.isEmpty()) return getProperty(state, Properties.STRAIGHT_RAIL_SHAPE); - return shape; - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/RotatingBlockGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/RotatingBlockGuide.java deleted file mode 100644 index b85ede7e1..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/RotatingBlockGuide.java +++ /dev/null @@ -1,58 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_3.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19_3.actions.Action; -import me.aleksilassila.litematica.printer.v1_19_3.actions.PrepareAction; -import net.minecraft.block.*; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.state.property.Properties; -import net.minecraft.util.math.Direction; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -public class RotatingBlockGuide extends GeneralPlacementGuide { - public RotatingBlockGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - Block block = state.targetState.getBlock(); - if (block instanceof WallSkullBlock || block instanceof WallSignBlock || block instanceof WallBannerBlock) { - Optional side = getProperty(state.targetState, Properties.HORIZONTAL_FACING).map(Direction::getOpposite); - return side.map(Collections::singletonList).orElseGet(Collections::emptyList); - } - - return Collections.singletonList(Direction.DOWN); - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - PrinterPlacementContext ctx = getPlacementContext(player); - - if (ctx == null) return new ArrayList<>(); - - int rotation = getProperty(state.targetState, Properties.ROTATION).orElse(0); - if (targetState.getBlock() instanceof BannerBlock || targetState.getBlock() instanceof SignBlock) { - rotation = (rotation + 8) % 16; - } - - int distTo0 = rotation > 8 ? 16 - rotation : rotation; - float yaw = Math.round(distTo0 / 8f * 180f * (rotation > 8 ? -1 : 1)); - - List actions = super.execute(player); - actions.set(0, new PrepareAction(ctx, yaw, 0)); - - return actions; - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/SlabGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/SlabGuide.java deleted file mode 100644 index e3a06a075..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/SlabGuide.java +++ /dev/null @@ -1,48 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.enums.SlabType; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; - -import java.util.Arrays; -import java.util.List; - -public class SlabGuide extends GeneralPlacementGuide { - public SlabGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - return Arrays.stream(Direction.values()) - .filter(d -> d != (getRequiredHalf(state).getOpposite()) && - getProperty(state.offset(d).currentState, SlabBlock.TYPE).orElse(SlabType.DOUBLE) == SlabType.DOUBLE) - .toList(); - } - - @Override - protected Vec3d getHitModifier(Direction validSide) { - Direction requiredHalf = getRequiredHalf(state); - if (validSide.getHorizontal() != -1) { - return new Vec3d(0, requiredHalf.getOffsetY() * 0.25, 0); - } else { - return new Vec3d(0, 0, 0); - } - } - - private Direction getRequiredHalf(SchematicBlockState state) { - BlockState targetState = state.targetState; - BlockState currentState = state.currentState; - - if (!currentState.contains(SlabBlock.TYPE)) { - return targetState.get(SlabBlock.TYPE) == SlabType.TOP ? Direction.UP : Direction.DOWN; - } else if (currentState.get(SlabBlock.TYPE) != targetState.get(SlabBlock.TYPE)) { - return currentState.get(SlabBlock.TYPE) == SlabType.TOP ? Direction.DOWN : Direction.UP; - } else { - return Direction.DOWN; - } - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/TorchGuide.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/TorchGuide.java deleted file mode 100644 index fadc8cb44..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/guides/placement/TorchGuide.java +++ /dev/null @@ -1,31 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import net.minecraft.block.Block; -import net.minecraft.block.HorizontalFacingBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.math.Direction; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -public class TorchGuide extends GeneralPlacementGuide { - public TorchGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - Optional facing = getProperty(targetState, HorizontalFacingBlock.FACING); - - return facing - .map(direction -> Collections.singletonList(direction.getOpposite())) - .orElseGet(() -> Collections.singletonList(Direction.DOWN)); - } - - @Override - protected Optional getRequiredItemAsBlock(ClientPlayerEntity player) { - return Optional.of(state.targetState.getBlock()); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/implementation/BlockHelperImpl.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/implementation/BlockHelperImpl.java deleted file mode 100644 index a1c0ee1a0..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/implementation/BlockHelperImpl.java +++ /dev/null @@ -1,14 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.implementation; - -import me.aleksilassila.litematica.printer.v1_19_3.BlockHelper; -import net.minecraft.block.ButtonBlock; - -import java.util.Arrays; - -public class BlockHelperImpl extends BlockHelper { - static { - interactiveBlocks.addAll(Arrays.asList( - ButtonBlock.class - )); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/implementation/PrinterPlacementContext.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/implementation/PrinterPlacementContext.java deleted file mode 100644 index c66a12c10..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/implementation/PrinterPlacementContext.java +++ /dev/null @@ -1,59 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.implementation; - -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import org.jetbrains.annotations.Nullable; - -public class PrinterPlacementContext extends ItemPlacementContext { - public final @Nullable Direction lookDirection; - public final boolean shouldSneak; - public final BlockHitResult hitResult; - public final int requiredItemSlot; - - public PrinterPlacementContext(PlayerEntity player, BlockHitResult hitResult, ItemStack requiredItem, int requiredItemSlot) { - this(player, hitResult, requiredItem, requiredItemSlot, null, false); - } - - public PrinterPlacementContext(PlayerEntity player, BlockHitResult hitResult, ItemStack requiredItem, int requiredItemSlot, @Nullable Direction lookDirection, boolean requiresSneaking) { - super(player, Hand.MAIN_HAND, requiredItem, hitResult); - - this.lookDirection = lookDirection; - this.shouldSneak = requiresSneaking; - this.hitResult = hitResult; - this.requiredItemSlot = requiredItemSlot; - } - - @Override - public Direction getPlayerLookDirection() { - return lookDirection == null ? super.getPlayerLookDirection() : lookDirection; - } - - @Override - public Direction getVerticalPlayerLookDirection() { - if (lookDirection != null && lookDirection.getOpposite() == super.getVerticalPlayerLookDirection()) - return lookDirection; - return super.getVerticalPlayerLookDirection(); - } - - @Override - public Direction getPlayerFacing() { - if (lookDirection == null || !lookDirection.getAxis().isHorizontal()) return super.getPlayerFacing(); - - return lookDirection; - } - - @Override - public String toString() { - return "PrinterPlacementContext{" + - "lookDirection=" + lookDirection + - ", requiresSneaking=" + shouldSneak + - ", blockPos=" + hitResult.getBlockPos() + - ", side=" + hitResult.getSide() + -// ", hitVec=" + hitResult + - '}'; - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/implementation/actions/InteractActionImpl.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/implementation/actions/InteractActionImpl.java deleted file mode 100644 index 90b10691f..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/implementation/actions/InteractActionImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.implementation.actions; - -import me.aleksilassila.litematica.printer.v1_19_3.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_19_3.actions.InteractAction; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; - -public class InteractActionImpl extends InteractAction { - public InteractActionImpl(PrinterPlacementContext context) { - super(context); - } - - @Override - protected void interact(MinecraftClient client, ClientPlayerEntity player, Hand hand, BlockHitResult hitResult) { - client.interactionManager.interactBlock(player, hand, hitResult); - client.interactionManager.interactItem(player, hand); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/implementation/mixin/MixinClientPlayerEntity.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/implementation/mixin/MixinClientPlayerEntity.java deleted file mode 100644 index 0b84b78c5..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/implementation/mixin/MixinClientPlayerEntity.java +++ /dev/null @@ -1,103 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.implementation.mixin; - -import com.mojang.authlib.GameProfile; -import fi.dy.masa.litematica.world.SchematicWorldHandler; -import fi.dy.masa.litematica.world.WorldSchematic; -import me.aleksilassila.litematica.printer.v1_19_3.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_19_3.Printer; -import me.aleksilassila.litematica.printer.v1_19_3.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19_3.UpdateChecker; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.block.entity.SignBlockEntity; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.AbstractClientPlayerEntity; -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.network.encryption.PlayerPublicKey; -import net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket; -import net.minecraft.text.Text; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -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; - -import java.util.Optional; - -@Mixin(ClientPlayerEntity.class) -public class MixinClientPlayerEntity extends AbstractClientPlayerEntity { - - private static boolean didCheckForUpdates = false; - - @Shadow - protected MinecraftClient client; - @Shadow - public ClientPlayNetworkHandler networkHandler; - - public MixinClientPlayerEntity(ClientWorld world, GameProfile profile) { - super(world, profile); - } - - @Inject(at = @At("TAIL"), method = "tick") - public void tick(CallbackInfo ci) { - ClientPlayerEntity clientPlayer = (ClientPlayerEntity) (Object) this; - if (!didCheckForUpdates) { - didCheckForUpdates = true; - - checkForUpdates(); - } - - if (LitematicaMixinMod.printer == null || LitematicaMixinMod.printer.player != clientPlayer) { - System.out.println("Initializing printer, player: " + clientPlayer + ", client: " + client); - LitematicaMixinMod.printer = new Printer(client, clientPlayer); - } - - // Dirty optimization - boolean didFindPlacement = true; - for (int i = 0; i < 10; i++) { - if (didFindPlacement) { - didFindPlacement = LitematicaMixinMod.printer.onGameTick(); - } - LitematicaMixinMod.printer.actionHandler.onGameTick(); - } - } - - public void checkForUpdates() { - new Thread(() -> { - String version = UpdateChecker.version; - String newVersion = UpdateChecker.getPrinterVersion(); - - if (!version.equals(newVersion)) { - client.inGameHud.getChatHud().addMessage(Text.literal("New version of Litematica Printer available in https://github.com/aleksilassila/litematica-printer/releases")); - } - }).start(); - } - - @Inject(method = "openEditSignScreen", at = @At("HEAD"), cancellable = true) - public void openEditSignScreen(SignBlockEntity sign, CallbackInfo ci) { - getTargetSignEntity(sign).ifPresent(signBlockEntity -> { - UpdateSignC2SPacket packet = new UpdateSignC2SPacket(sign.getPos(), - signBlockEntity.getTextOnRow(0, false).getString(), - signBlockEntity.getTextOnRow(1, false).getString(), - signBlockEntity.getTextOnRow(2, false).getString(), - signBlockEntity.getTextOnRow(3, false).getString()); - this.networkHandler.sendPacket(packet); - ci.cancel(); - }); - } - - private Optional getTargetSignEntity(SignBlockEntity sign) { - WorldSchematic worldSchematic = SchematicWorldHandler.getSchematicWorld(); - SchematicBlockState state = new SchematicBlockState(sign.getWorld(), worldSchematic, sign.getPos()); - - BlockEntity targetBlockEntity = worldSchematic.getBlockEntity(state.blockPos); - - if (targetBlockEntity instanceof SignBlockEntity targetSignEntity) { - return Optional.of(targetSignEntity); - } - - return Optional.empty(); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/mixin/AxeItemAccessor.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/mixin/AxeItemAccessor.java deleted file mode 100644 index b6afd51b9..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/mixin/AxeItemAccessor.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.mixin; - -import net.minecraft.block.Block; -import net.minecraft.item.AxeItem; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.util.Map; - -/** - * This class apparently fixes an issue with Quilt. - */ -@Mixin(AxeItem.class) -public interface AxeItemAccessor { - @Accessor("STRIPPED_BLOCKS") - static Map getStrippedBlocks() { - throw new AssertionError("Untransformed @Accessor"); - } - -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/mixin/ConfigsMixin.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/mixin/ConfigsMixin.java deleted file mode 100644 index 87fe9dc9b..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/mixin/ConfigsMixin.java +++ /dev/null @@ -1,35 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.mixin; - -import com.google.common.collect.ImmutableList; -import fi.dy.masa.litematica.config.Configs; -import fi.dy.masa.malilib.config.IConfigBase; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import me.aleksilassila.litematica.printer.v1_19_3.LitematicaMixinMod; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.List; - -@Mixin(value = Configs.class, remap = false) -public class ConfigsMixin { - @Redirect(method = "loadFromFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Configs$Generic;OPTIONS:Lcom/google/common/collect/ImmutableList;")) - private static ImmutableList moreOptions() { - return LitematicaMixinMod.getConfigList(); - } - - @Redirect(method = "saveToFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Configs$Generic;OPTIONS:Lcom/google/common/collect/ImmutableList;")) - private static ImmutableList moreeOptions() { - return LitematicaMixinMod.getConfigList(); - } - - @Redirect(method = "loadFromFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private static List moreHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } - - @Redirect(method = "saveToFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private static List moreeHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/mixin/GuiConfigsMixin.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/mixin/GuiConfigsMixin.java deleted file mode 100644 index 0c514deaa..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/mixin/GuiConfigsMixin.java +++ /dev/null @@ -1,61 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.mixin; - -import com.google.common.collect.ImmutableList; -import fi.dy.masa.litematica.gui.GuiConfigs; -import fi.dy.masa.malilib.config.IConfigBase; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import me.aleksilassila.litematica.printer.v1_19_3.LitematicaMixinMod; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.List; - -@Mixin(value = GuiConfigs.class, remap = false) -public class GuiConfigsMixin { - - /*@Overwrite - public List getConfigs() - { - List configs; - ConfigGuiTab tab = DataManager.getConfigGuiTab(); - - if (tab == ConfigGuiTab.GENERIC) - { - configs = LitematicaMixinMod.betterConfigList; - } - else if (tab == ConfigGuiTab.INFO_OVERLAYS) - { - configs = Configs.InfoOverlays.OPTIONS; - } - else if (tab == ConfigGuiTab.VISUALS) - { - configs = Configs.Visuals.OPTIONS; - } - else if (tab == ConfigGuiTab.COLORS) - { - configs = Configs.Colors.OPTIONS; - } - else if (tab == ConfigGuiTab.HOTKEYS) - { - configs = LitematicaMixinMod.betterHotkeyList; - } - else - { - return Collections.emptyList(); - } - - return ConfigOptionWrapper.createFor(configs); - }*/ - - - @Redirect(method = "getConfigs", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Configs$Generic;OPTIONS:Lcom/google/common/collect/ImmutableList;")) - private ImmutableList moreOptions() { - return LitematicaMixinMod.getConfigList(); - } - - @Redirect(method = "getConfigs", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private List moreHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/mixin/InputHandlerMixin.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/mixin/InputHandlerMixin.java deleted file mode 100644 index 960d34999..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/mixin/InputHandlerMixin.java +++ /dev/null @@ -1,25 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.mixin; - -import fi.dy.masa.litematica.event.InputHandler; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import me.aleksilassila.litematica.printer.v1_19_3.LitematicaMixinMod; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.List; - -@Mixin(value = InputHandler.class, remap = false) -public class InputHandlerMixin { - - @Redirect(method = "addHotkeys", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private List moreHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } - - @Redirect(method = "addKeysToMap", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private List moreeHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } - -} diff --git a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/mixin/PlayerMoveC2SPacketMixin.java b/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/mixin/PlayerMoveC2SPacketMixin.java deleted file mode 100644 index d2a10acb2..000000000 --- a/v1_19_3/src/main/java/me/aleksilassila/litematica/printer/v1_19_3/mixin/PlayerMoveC2SPacketMixin.java +++ /dev/null @@ -1,36 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_3.mixin; - -import me.aleksilassila.litematica.printer.v1_19_3.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_19_3.Printer; -import me.aleksilassila.litematica.printer.v1_19_3.actions.PrepareAction; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; - -@Mixin(PlayerMoveC2SPacket.class) -public class PlayerMoveC2SPacketMixin { - @ModifyVariable(method = "(DDDFFZZZ)V", at = @At("HEAD"), ordinal = 0) - private static float modifyLookYaw(float yaw) { - Printer printer = LitematicaMixinMod.printer; - if (printer == null) return yaw; - - PrepareAction action = printer.actionHandler.lookAction; - if (action != null && action.modifyYaw) { - if (LitematicaMixinMod.DEBUG) System.out.println("YAW: " + action.yaw); - return action.yaw; - } else return yaw; - } - - @ModifyVariable(method = "(DDDFFZZZ)V", at = @At("HEAD"), ordinal = 1) - private static float modifyLookPitch(float pitch) { - Printer printer = LitematicaMixinMod.printer; - if (printer == null) return pitch; - - PrepareAction action = printer.actionHandler.lookAction; - if (action != null && action.modifyPitch) { - if (LitematicaMixinMod.DEBUG) System.out.println("PITCH: " + action.pitch); - return action.pitch; - } else return pitch; - } -} diff --git a/v1_19_3/src/main/resources/assets/modid/icon.png b/v1_19_3/src/main/resources/assets/modid/icon.png deleted file mode 100644 index 047b91f2347de5cf95f23284476fddbe21ba23fe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 453 zcmV;$0XqJPP)QAFYGys`80vegN0XDFh0OXKz&i8?Le#x7{1X)R+00000NkvXXu0mjf73i~T diff --git a/v1_19_3/src/main/resources/fabric.mod.json b/v1_19_3/src/main/resources/fabric.mod.json deleted file mode 100644 index b1a4cd8b6..000000000 --- a/v1_19_3/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "schemaVersion": 1, - "id": "litematica_printer", - "version": "${version}", - "name": "Litematica Printer", - "description": "A fork of Litematica that adds the missing printer functionality", - "authors": [ - "aleksilassila" - ], - "contact": { - "homepage": "https://github.com/aleksilassila/litematica-printer", - "sources": "https://github.com/aleksilassila/litematica-printer" - }, - "license": "CC0-1.0", - "icon": "assets/modid/icon.png", - "environment": "*", - "entrypoints": { - "main": [ - "me.aleksilassila.litematica.printer.v1_19_3.LitematicaMixinMod" - ] - }, - "mixins": [ - "litematica-printer.mixins.json", - "litematica-printer-implementation.mixins.json" - ], - "depends": { - "fabricloader": ">=0.14.7", - "fabric": "*", - "minecraft": "1.19.x", - "java": ">=17" - }, - "custom": { - "modmenu": { - "parent": "carpet" - } - } -} - diff --git a/v1_19_3/src/main/resources/litematica-printer-implementation.mixins.json b/v1_19_3/src/main/resources/litematica-printer-implementation.mixins.json deleted file mode 100644 index 052413e9c..000000000 --- a/v1_19_3/src/main/resources/litematica-printer-implementation.mixins.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "me.aleksilassila.litematica.printer.v1_19_3.implementation.mixin", - "compatibilityLevel": "JAVA_16", - "mixins": [ - ], - "client": [ - "MixinClientPlayerEntity" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/v1_19_3/src/main/resources/litematica-printer.mixins.json b/v1_19_3/src/main/resources/litematica-printer.mixins.json deleted file mode 100644 index f4a7cc852..000000000 --- a/v1_19_3/src/main/resources/litematica-printer.mixins.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "me.aleksilassila.litematica.printer.v1_19_3.mixin", - "compatibilityLevel": "JAVA_16", - "mixins": [ - ], - "client": [ - "ConfigsMixin", - "GuiConfigsMixin", - "InputHandlerMixin", - "PlayerMoveC2SPacketMixin", - "AxeItemAccessor" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/v1_19_4/build.gradle.kts b/v1_19_4/build.gradle.kts deleted file mode 100644 index c3b72eeb4..000000000 --- a/v1_19_4/build.gradle.kts +++ /dev/null @@ -1,88 +0,0 @@ -plugins { - id("fabric-loom").version("1.0-SNAPSHOT") - id("maven-publish") -} - -java.sourceCompatibility = JavaVersion.VERSION_17 -java.targetCompatibility = JavaVersion.VERSION_17 - -val archives_base_name: String by project -val minecraft_version: String by project -val yarn_mappings: String by project -val loader_version: String by project -val fabric_version: String by project -val malilib_version: String by project -val litematica_projectid: String by project -val litematica_fileid: String by project - -val mod_version: String by project - -dependencies { -// implementation(project(":common")) - minecraft("com.mojang:minecraft:${minecraft_version}") - mappings("net.fabricmc:yarn:${yarn_mappings}:v2") - - modImplementation("net.fabricmc:fabric-loader:${loader_version}") - modImplementation("net.fabricmc.fabric-api:fabric-api:${fabric_version}") - modImplementation("fi.dy.masa.malilib:malilib-fabric-${malilib_version}") - modImplementation("curse.maven:litematica-${litematica_projectid}:${litematica_fileid}") -} - -repositories { - maven("https://masa.dy.fi/maven") - maven("https://www.cursemaven.com") -} - -// Process resources -tasks.withType { - inputs.property("version", mod_version) - - filesMatching("fabric.mod.json") { - expand(mapOf("version" to mod_version)) - } -} - -val sourceModule = "v1_19_4" -val targetModules = arrayOf("v1_19", "v1_18", "v1_17") - -fun copyFile(source: File) { - for (targetModule in targetModules) { - val destination = file(source.absolutePath.replace(sourceModule, targetModule)) - println("Copying ${source.absolutePath} to ${destination.absolutePath}") - destination.parentFile.mkdirs() - source.copyTo(destination, true) - destination.writeText(destination.readText().replace(sourceModule, targetModule)) - } -} - -fun deleteOldFiles(sourceBase: File) { - for (targetModule in targetModules) { - val targetBase = file(sourceBase.absolutePath.replace(sourceModule, targetModule)) - - for (file in targetBase.listFiles()) { - if (file.name.equals("implementation")) continue - println("Deleting recursively ${file.absolutePath}") - file.deleteRecursively() - } - } -} - -val syncImplementations = tasks.create("syncImplementations") { - doFirst { - val sourceStart = - this.project.projectDir.absolutePath + "/src/main/java/me/aleksilassila/litematica/printer/" + sourceModule - val sourceDir = file(sourceStart) - - deleteOldFiles(sourceDir) - - for (sourceFile in sourceDir.listFiles()) { - if (sourceFile.name.equals("implementation")) continue - - sourceFile.walk() - .filter { it.isFile } - .forEach { - copyFile(it) - } - } - } -} diff --git a/v1_19_4/gradle.properties b/v1_19_4/gradle.properties deleted file mode 100644 index 3e8de05fd..000000000 --- a/v1_19_4/gradle.properties +++ /dev/null @@ -1,13 +0,0 @@ -# Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx1G -# https://masa.dy.fi/maven/fi/dy/masa/malilib/ -malilib_version=1.19.4:0.15.3 -# https://www.curseforge.com/minecraft/mc-mods/litematica/files -litematica_fileid=4447936 -litematica_projectid=308892 -# Fabric Properties: https://fabricmc.net/develop/ -minecraft_version=1.19.4 -yarn_mappings=1.19.4+build.2 -loader_version=0.14.19 -#Fabric api -fabric_version=0.78.0+1.19.4 diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/ActionHandler.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/ActionHandler.java deleted file mode 100644 index 4c5476000..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/ActionHandler.java +++ /dev/null @@ -1,57 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4; - -import me.aleksilassila.litematica.printer.v1_19_4.actions.Action; -import me.aleksilassila.litematica.printer.v1_19_4.actions.PrepareAction; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; - -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; - -public class ActionHandler { - private final MinecraftClient client; - private final ClientPlayerEntity player; - - private final Queue actionQueue = new LinkedList<>(); - public PrepareAction lookAction = null; - - public ActionHandler(MinecraftClient client, ClientPlayerEntity player) { - this.client = client; - this.player = player; - } - - private int tick = 0; - - public void onGameTick() { - int tickRate = LitematicaMixinMod.PRINTING_INTERVAL.getIntegerValue(); - - tick = tick % tickRate == tickRate - 1 ? 0 : tick + 1; - if (tick % tickRate != 0) { - return; - } - - Action nextAction = actionQueue.poll(); - if (nextAction != null) { - if (LitematicaMixinMod.DEBUG) System.out.println("Sending action " + nextAction); - nextAction.send(client, player); - } else { - lookAction = null; - } - } - - public boolean acceptsActions() { - return actionQueue.isEmpty(); - } - - public void addActions(Action... actions) { - if (!acceptsActions()) return; - - for (Action action : actions) { - if (action instanceof PrepareAction) - lookAction = (PrepareAction) action; - } - - actionQueue.addAll(List.of(actions)); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/BlockHelper.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/BlockHelper.java deleted file mode 100644 index 572a30f6e..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/BlockHelper.java +++ /dev/null @@ -1,31 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4; - -import net.minecraft.block.*; -import net.minecraft.item.Item; -import net.minecraft.item.Items; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -abstract public class BlockHelper { - public static List> interactiveBlocks = new ArrayList<>(Arrays.asList( - AbstractChestBlock.class, AbstractFurnaceBlock.class, CraftingTableBlock.class, LeverBlock.class, - DoorBlock.class, TrapdoorBlock.class, BedBlock.class, RedstoneWireBlock.class, ScaffoldingBlock.class, - HopperBlock.class, EnchantingTableBlock.class, NoteBlock.class, JukeboxBlock.class, CakeBlock.class, - FenceGateBlock.class, BrewingStandBlock.class, DragonEggBlock.class, CommandBlock.class, - BeaconBlock.class, AnvilBlock.class, ComparatorBlock.class, RepeaterBlock.class, - DropperBlock.class, DispenserBlock.class, ShulkerBoxBlock.class, LecternBlock.class, - FlowerPotBlock.class, BarrelBlock.class, BellBlock.class, SmithingTableBlock.class, - LoomBlock.class, CartographyTableBlock.class, GrindstoneBlock.class, - StonecutterBlock.class, AbstractSignBlock.class, AbstractCandleBlock.class)); - - public static final Item[] SHOVEL_ITEMS = new Item[]{ - Items.NETHERITE_SHOVEL, - Items.DIAMOND_SHOVEL, - Items.GOLDEN_SHOVEL, - Items.IRON_SHOVEL, - Items.STONE_SHOVEL, - Items.WOODEN_SHOVEL - }; -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/LitematicaMixinMod.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/LitematicaMixinMod.java deleted file mode 100644 index 67ceba771..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/LitematicaMixinMod.java +++ /dev/null @@ -1,58 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4; - -import com.google.common.collect.ImmutableList; -import fi.dy.masa.litematica.config.Configs; -import fi.dy.masa.litematica.config.Hotkeys; -import fi.dy.masa.malilib.config.IConfigBase; -import fi.dy.masa.malilib.config.options.ConfigBoolean; -import fi.dy.masa.malilib.config.options.ConfigDouble; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import fi.dy.masa.malilib.config.options.ConfigInteger; -import fi.dy.masa.malilib.hotkeys.KeyCallbackToggleBooleanConfigWithMessage; -import fi.dy.masa.malilib.hotkeys.KeybindSettings; -import net.fabricmc.api.ModInitializer; - -import java.util.List; - -public class LitematicaMixinMod implements ModInitializer { - - public static Printer printer; - public static boolean DEBUG = false; - // Config settings - public static final ConfigInteger PRINTING_INTERVAL = new ConfigInteger("printingInterval", 12, 1, 40, "Printing interval. Lower values mean faster printing speed.\nIf the printer creates \"ghost blocks\" or blocks are facing the wrong way, raise this value."); - public static final ConfigDouble PRINTING_RANGE = new ConfigDouble("printingRange", 5, 2.5, 5, "Printing block place range\nLower values are recommended for servers."); - // public static final ConfigBoolean PRINT_WATER = new ConfigBoolean("printWater", false, "Whether the printer should place water\n source blocks or make blocks waterlogged."); -// public static final ConfigBoolean PRINT_IN_AIR = new ConfigBoolean("printInAir", true, "Whether or not the printer should place blocks without anything to build on.\nBe aware that some anti-cheat plugins might notice this."); - public static final ConfigBoolean PRINT_MODE = new ConfigBoolean("printingMode", false, "Autobuild / print loaded selection.\nBe aware that some servers and anticheat plugins do not allow printing."); - public static final ConfigBoolean REPLACE_FLUIDS_SOURCE_BLOCKS = new ConfigBoolean("replaceFluidSourceBlocks", true, "Whether or not fluid source blocks should be replaced by the printer."); - public static final ConfigBoolean STRIP_LOGS = new ConfigBoolean("stripLogs", true, "Whether or not the printer should use normal logs if stripped\nversions are not available and then strip them with an axe."); - - public static ImmutableList getConfigList() { - List list = new java.util.ArrayList<>(Configs.Generic.OPTIONS); - list.add(PRINT_MODE); - list.add(PRINTING_INTERVAL); - list.add(PRINTING_RANGE); -// list.add(PRINT_IN_AIR); - list.add(REPLACE_FLUIDS_SOURCE_BLOCKS); - list.add(STRIP_LOGS); - - return ImmutableList.copyOf(list); - } - - // Hotkeys - public static final ConfigHotkey PRINT = new ConfigHotkey("print", "V", KeybindSettings.PRESS_ALLOWEXTRA_EMPTY, "Prints while pressed"); - public static final ConfigHotkey TOGGLE_PRINTING_MODE = new ConfigHotkey("togglePrintingMode", "CAPS_LOCK", KeybindSettings.PRESS_ALLOWEXTRA_EMPTY, "Allows quickly toggling on/off Printing mode"); - - public static List getHotkeyList() { - List list = new java.util.ArrayList<>(Hotkeys.HOTKEY_LIST); - list.add(PRINT); - list.add(TOGGLE_PRINTING_MODE); - - return ImmutableList.copyOf(list); - } - - @Override - public void onInitialize() { - TOGGLE_PRINTING_MODE.getKeybind().setCallback(new KeyCallbackToggleBooleanConfigWithMessage(PRINT_MODE)); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/Printer.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/Printer.java deleted file mode 100644 index 23839067f..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/Printer.java +++ /dev/null @@ -1,110 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4; - -import fi.dy.masa.litematica.data.DataManager; -import fi.dy.masa.litematica.util.RayTraceUtils; -import fi.dy.masa.litematica.world.SchematicWorldHandler; -import fi.dy.masa.litematica.world.WorldSchematic; -import me.aleksilassila.litematica.printer.v1_19_4.actions.Action; -import me.aleksilassila.litematica.printer.v1_19_4.guides.Guide; -import me.aleksilassila.litematica.printer.v1_19_4.guides.Guides; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerAbilities; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.RaycastContext; -import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -public class Printer { - @NotNull - public final ClientPlayerEntity player; - - public final ActionHandler actionHandler; - - private final Guides interactionGuides = new Guides(); - - public Printer(@NotNull MinecraftClient client, @NotNull ClientPlayerEntity player) { - this.player = player; - - this.actionHandler = new ActionHandler(client, player); - } - - public boolean onGameTick() { - WorldSchematic worldSchematic = SchematicWorldHandler.getSchematicWorld(); - - if (!actionHandler.acceptsActions()) return false; - - if (worldSchematic == null) return false; - - if (!LitematicaMixinMod.PRINT_MODE.getBooleanValue() && !LitematicaMixinMod.PRINT.getKeybind().isPressed()) - return false; - - PlayerAbilities abilities = player.getAbilities(); - if (!abilities.allowModifyWorld) - return false; - - List positions = getReachablePositions(); - findBlock: - for (BlockPos position : positions) { - SchematicBlockState state = new SchematicBlockState(player.world, worldSchematic, position); - if (state.targetState.equals(state.currentState) || state.targetState.isAir()) continue; - - Guide[] guides = interactionGuides.getInteractionGuides(state); - - BlockHitResult result = RayTraceUtils.traceToSchematicWorld(player, 10, true, true); - boolean isCurrentlyLookingSchematic = result != null && result.getBlockPos().equals(position); - - for (Guide guide : guides) { - if (guide.canExecute(player)) { - System.out.println("Executing " + guide + " for " + state); - List actions = guide.execute(player); - actionHandler.addActions(actions.toArray(Action[]::new)); - return true; - } - if (guide.skipOtherGuides()) continue findBlock; - } - } - - return false; - } - - private List getReachablePositions() { - int maxReach = (int) Math.ceil(LitematicaMixinMod.PRINTING_RANGE.getDoubleValue()); - double maxReachSquared = MathHelper.square(LitematicaMixinMod.PRINTING_RANGE.getDoubleValue()); - - ArrayList positions = new ArrayList<>(); - - for (int y = -maxReach; y < maxReach + 1; y++) { - for (int x = -maxReach; x < maxReach + 1; x++) { - for (int z = -maxReach; z < maxReach + 1; z++) { - BlockPos blockPos = player.getBlockPos().north(x).west(z).up(y); - - if (!DataManager.getRenderLayerRange().isPositionWithinRange(blockPos)) continue; - if (this.player.getEyePos().squaredDistanceTo(Vec3d.ofCenter(blockPos)) > maxReachSquared) { - continue; - } - - positions.add(blockPos); - } - } - } - - return positions.stream() - .filter(p -> { - Vec3d vec = Vec3d.ofCenter(p); - return this.player.getPos().squaredDistanceTo(vec) > 1 && this.player.getEyePos().squaredDistanceTo(vec) > 1; - }) - .sorted((a, b) -> { - double aDistance = this.player.getPos().squaredDistanceTo(Vec3d.ofCenter(a)); - double bDistance = this.player.getPos().squaredDistanceTo(Vec3d.ofCenter(b)); - return Double.compare(aDistance, bDistance); - }).toList(); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/SchematicBlockState.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/SchematicBlockState.java deleted file mode 100644 index fa6571634..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/SchematicBlockState.java +++ /dev/null @@ -1,42 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4; - -import fi.dy.masa.litematica.world.WorldSchematic; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.World; - -public class SchematicBlockState { - public final World world; - public final WorldSchematic schematic; - - public final BlockPos blockPos; - - public final BlockState targetState; - public final BlockState currentState; - - public SchematicBlockState(World world, WorldSchematic schematic, BlockPos blockPos) { - this.world = world; - this.schematic = schematic; - - this.blockPos = blockPos; - - this.targetState = schematic.getBlockState(blockPos); - this.currentState = world.getBlockState(blockPos); - } - - public SchematicBlockState offset(Direction direction) { - return new SchematicBlockState(world, schematic, blockPos.offset(direction)); - } - - @Override - public String toString() { - return "SchematicBlockState{" + - "world=" + world + - ", schematic=" + schematic + - ", blockPos=" + blockPos + - ", targetState=" + targetState + - ", currentState=" + currentState + - '}'; - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/UpdateChecker.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/UpdateChecker.java deleted file mode 100644 index f9c51d510..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/UpdateChecker.java +++ /dev/null @@ -1,49 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import org.apache.commons.io.IOUtils; - -import java.io.BufferedReader; -import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.util.Scanner; - -public class UpdateChecker { - public static final String version = "v3.2"; - - // Try to get this to work at some point -// static { -// try (InputStream in = UpdateChecker.class.getResourceAsStream("/fabric.mod.json")) { -// String jsonString = IOUtils.toString(in, StandardCharsets.UTF_8); -// JsonObject json = JsonParser.parseString(jsonString).getAsJsonObject(); -// System.out.println("JSON object: " + json); -// System.out.println("Raw json: " + jsonString); -// System.out.println("File: " + new File(UpdateChecker.class.getResource("/fabric.mod.json").getFile())); -// String version = json.get("version").getAsString(); -// System.out.println("Reading fabric.mod.json"); -// System.out.println("Parsed version: " + version); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } - - @SuppressWarnings("deprecation") - public static String getPrinterVersion() { - try (InputStream inputStream = new URL("https://api.github.com/repos/aleksilassila/litematica-printer/tags").openStream(); Scanner scanner = new Scanner(inputStream)) { - if (scanner.hasNext()) { - JsonArray tags = new JsonParser().parse(scanner.next()).getAsJsonArray(); - return ((JsonObject) tags.get(0)).get("name").getAsString(); - } - } catch (Exception exception) { - System.out.println("Cannot look for updates: " + exception.getMessage()); - } - - return ""; - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/actions/Action.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/actions/Action.java deleted file mode 100644 index 6bfd0077c..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/actions/Action.java +++ /dev/null @@ -1,8 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.actions; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; - -public abstract class Action { - abstract public void send(MinecraftClient client, ClientPlayerEntity player); -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/actions/InteractAction.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/actions/InteractAction.java deleted file mode 100644 index 6b318d97f..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/actions/InteractAction.java +++ /dev/null @@ -1,33 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.actions; - -import me.aleksilassila.litematica.printer.v1_19_4.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_19_4.implementation.PrinterPlacementContext; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; - -abstract public class InteractAction extends Action { - public final PrinterPlacementContext context; - - public InteractAction(PrinterPlacementContext context) { - this.context = context; - } - - protected abstract void interact(MinecraftClient client, ClientPlayerEntity player, Hand hand, BlockHitResult hitResult); - - @Override - public void send(MinecraftClient client, ClientPlayerEntity player) { - interact(client, player, Hand.MAIN_HAND, context.hitResult); - - if (LitematicaMixinMod.DEBUG) - System.out.println("InteractAction.send: Blockpos: " + context.getBlockPos() + " Side: " + context.getSide() + " HitPos: " + context.getHitPos()); - } - - @Override - public String toString() { - return "InteractAction{" + - "context=" + context + - '}'; - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/actions/PrepareAction.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/actions/PrepareAction.java deleted file mode 100644 index 54824c05a..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/actions/PrepareAction.java +++ /dev/null @@ -1,109 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.actions; - -import me.aleksilassila.litematica.printer.v1_19_4.implementation.PrinterPlacementContext; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; -import net.minecraft.util.Hand; -import net.minecraft.util.math.Direction; - -public class PrepareAction extends Action { -// public final Direction lookDirection; -// public final boolean requireSneaking; -// public final Item item; - -// public PrepareAction(Direction lookDirection, boolean requireSneaking, Item item) { -// this.lookDirection = lookDirection; -// this.requireSneaking = requireSneaking; -// this.item = item; -// } -// -// public PrepareAction(Direction lookDirection, boolean requireSneaking, BlockState requiredState) { -// this(lookDirection, requireSneaking, requiredState.getBlock().asItem()); -// } - - public final PrinterPlacementContext context; - - public boolean modifyYaw = true; - public boolean modifyPitch = true; - public float yaw = 0; - public float pitch = 0; - - public PrepareAction(PrinterPlacementContext context) { - this.context = context; - - Direction lookDirection = context.lookDirection; - - if (lookDirection != null && lookDirection.getAxis().isHorizontal()) { - this.yaw = lookDirection.asRotation(); - } else { - this.modifyYaw = false; - } - - if (lookDirection == Direction.UP) { - this.pitch = -90; - } else if (lookDirection == Direction.DOWN) { - this.pitch = 90; - } else if (lookDirection != null) { - this.pitch = 0; - } else { - this.modifyPitch = false; - } - } - - public PrepareAction(PrinterPlacementContext context, float yaw, float pitch) { - this.context = context; - - this.yaw = yaw; - this.pitch = pitch; - } - - @Override - public void send(MinecraftClient client, ClientPlayerEntity player) { - ItemStack itemStack = context.getStack(); - int slot = context.requiredItemSlot; - - if (itemStack != null) { - PlayerInventory inventory = player.getInventory(); - - // This thing is straight from MinecraftClient#doItemPick() - if (player.getAbilities().creativeMode) { - inventory.addPickBlock(itemStack); - client.interactionManager.clickCreativeStack(player.getStackInHand(Hand.MAIN_HAND), 36 + inventory.selectedSlot); - } else if (slot != -1) { - if (PlayerInventory.isValidHotbarIndex(slot)) { - inventory.selectedSlot = slot; - } else { - client.interactionManager.pickFromInventory(slot); - } - } - } - - if (modifyPitch || modifyYaw) { - float yaw = modifyYaw ? this.yaw : player.getYaw(); - float pitch = modifyPitch ? this.pitch : player.getPitch(); - - PlayerMoveC2SPacket packet = new PlayerMoveC2SPacket.Full(player.getX(), player.getY(), player.getZ(), yaw, pitch, player.isOnGround()); - - player.networkHandler.sendPacket(packet); - } - - if (context.shouldSneak) { - player.input.sneaking = true; - player.networkHandler.sendPacket(new ClientCommandC2SPacket(player, ClientCommandC2SPacket.Mode.PRESS_SHIFT_KEY)); - } else { - player.input.sneaking = false; - player.networkHandler.sendPacket(new ClientCommandC2SPacket(player, ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY)); - } - } - - @Override - public String toString() { - return "PrepareAction{" + - "context=" + context + - '}'; - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/actions/ReleaseShiftAction.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/actions/ReleaseShiftAction.java deleted file mode 100644 index 7418b874a..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/actions/ReleaseShiftAction.java +++ /dev/null @@ -1,13 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.actions; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; - -public class ReleaseShiftAction extends Action { - @Override - public void send(MinecraftClient client, ClientPlayerEntity player) { - player.input.sneaking = false; - player.networkHandler.sendPacket(new ClientCommandC2SPacket(player, ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY)); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/Guide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/Guide.java deleted file mode 100644 index e55843591..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/Guide.java +++ /dev/null @@ -1,130 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides; - -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19_4.actions.Action; -import me.aleksilassila.litematica.printer.v1_19_4.implementation.BlockHelperImpl; -import net.minecraft.block.BlockState; -import net.minecraft.block.CoralBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.state.property.Properties; -import net.minecraft.state.property.Property; -import org.jetbrains.annotations.NotNull; - -import java.util.List; -import java.util.Optional; - -abstract public class Guide extends BlockHelperImpl { - protected final SchematicBlockState state; - protected final BlockState currentState; - protected final BlockState targetState; - - public Guide(SchematicBlockState state) { - this.state = state; - - this.currentState = state.currentState; - this.targetState = state.targetState; - } - - protected boolean playerHasRightItem(ClientPlayerEntity player) { - return getRequiredItemStackSlot(player) != -1; - } - - protected int getSlotWithItem(ClientPlayerEntity player, ItemStack itemStack) { - PlayerInventory inventory = player.getInventory(); - - for (int i = 0; i < inventory.main.size(); ++i) { - if (itemStack.isEmpty() && inventory.main.get(i).isOf(itemStack.getItem())) return i; - if (!inventory.main.get(i).isEmpty() && inventory.main.get(i).isItemEqual(itemStack)) { - return i; - } - } - - return -1; - } - - protected int getRequiredItemStackSlot(ClientPlayerEntity player) { - if (player.getAbilities().creativeMode) { - return player.getInventory().selectedSlot; - } - - Optional requiredItem = getRequiredItem(player); - if (requiredItem.isEmpty()) return -1; - - return getSlotWithItem(player, requiredItem.get()); - } - - public boolean canExecute(ClientPlayerEntity player) { - if (!playerHasRightItem(player)) return false; - - BlockState targetState = state.targetState; - BlockState currentState = state.currentState; - - return !statesEqual(targetState, currentState); - } - - abstract public @NotNull List execute(ClientPlayerEntity player); - - abstract protected @NotNull List getRequiredItems(); - - /** - * Returns the first required item that player has access to, - * or empty if the items are inaccessible. - */ - protected Optional getRequiredItem(ClientPlayerEntity player) { - List requiredItems = getRequiredItems(); - - for (ItemStack requiredItem : requiredItems) { - if (player.getAbilities().creativeMode) return Optional.of(requiredItem); - - int slot = getSlotWithItem(player, requiredItem); - if (slot > -1) - return Optional.of(requiredItem); - } - - return Optional.empty(); - } - - protected boolean statesEqualIgnoreProperties(BlockState state1, BlockState state2, Property... propertiesToIgnore) { - if (state1.getBlock() != state2.getBlock()) return false; - - loop: - for (Property property : state1.getProperties()) { - if (property == Properties.WATERLOGGED && !(state1.getBlock() instanceof CoralBlock)) continue; - - for (Property ignoredProperty : propertiesToIgnore) { - if (property == ignoredProperty) continue loop; - } - - try { - if (state1.get(property) != state2.get(property)) { - return false; - } - } catch (Exception e) { - return false; - } - } - - return true; - } - - protected static > Optional getProperty(BlockState blockState, Property property) { - if (blockState.contains(property)) { - return Optional.of(blockState.get(property)); - } - return Optional.empty(); - } - - /** - * Returns true if - */ - protected boolean statesEqual(BlockState state1, BlockState state2) { - return statesEqualIgnoreProperties(state1, state2); - } - - public boolean skipOtherGuides() { - return false; - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/Guides.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/Guides.java deleted file mode 100644 index 8a0df34eb..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/Guides.java +++ /dev/null @@ -1,81 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides; - -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19_4.guides.interaction.*; -import me.aleksilassila.litematica.printer.v1_19_4.guides.placement.*; -import net.minecraft.block.*; -import net.minecraft.util.Pair; - -import java.util.ArrayList; - -public class Guides { - protected final static ArrayList, Class[]>> guides = new ArrayList<>(); - - @SafeVarargs - protected static void registerGuide(Class guideClass, Class... blocks) { - guides.add(new Pair<>(guideClass, blocks)); - } - - static { -// registerGuide(SkipGuide.class, AbstractSignBlock.class, SkullBlock.class, BannerBlock.class); - - registerGuide(RotatingBlockGuide.class, AbstractSkullBlock.class, AbstractSignBlock.class, AbstractBannerBlock.class); - registerGuide(SlabGuide.class, SlabBlock.class); - registerGuide(TorchGuide.class, TorchBlock.class); - registerGuide(FarmlandGuide.class, FarmlandBlock.class); - registerGuide(TillingGuide.class, FarmlandBlock.class); - registerGuide(RailGuesserGuide.class, AbstractRailBlock.class); - registerGuide(ChestGuide.class, ChestBlock.class); - registerGuide(FlowerPotGuide.class, FlowerPotBlock.class); - registerGuide(FlowerPotFillGuide.class, FlowerPotBlock.class); - - registerGuide(PropertySpecificGuesserGuide.class, - RepeaterBlock.class, ComparatorBlock.class, RedstoneWireBlock.class, RedstoneTorchBlock.class, - BambooBlock.class, CactusBlock.class, SaplingBlock.class, ScaffoldingBlock.class, PointedDripstoneBlock.class, - HorizontalConnectingBlock.class, DoorBlock.class, TrapdoorBlock.class, FenceGateBlock.class, ChestBlock.class, - SnowBlock.class, SeaPickleBlock.class, CandleBlock.class, LeverBlock.class, EndPortalFrameBlock.class, - NoteBlock.class, CampfireBlock.class, PoweredRailBlock.class, LeavesBlock.class, TripwireHookBlock.class); - registerGuide(FallingBlockGuide.class, FallingBlock.class); - registerGuide(BlockIndifferentGuesserGuide.class, BambooBlock.class, BigDripleafStemBlock.class, BigDripleafBlock.class, - TwistingVinesPlantBlock.class, TripwireBlock.class); - - registerGuide(CampfireExtinguishGuide.class, CampfireBlock.class); - registerGuide(LightCandleGuide.class, AbstractCandleBlock.class); - registerGuide(EnderEyeGuide.class, EndPortalFrameBlock.class); - registerGuide(CycleStateGuide.class, - DoorBlock.class, FenceGateBlock.class, TrapdoorBlock.class, - LeverBlock.class, - RepeaterBlock.class, ComparatorBlock.class, NoteBlock.class); - registerGuide(BlockReplacementGuide.class, SnowBlock.class, SeaPickleBlock.class, CandleBlock.class, SlabBlock.class); - registerGuide(LogGuide.class); - registerGuide(LogStrippingGuide.class); - registerGuide(GuesserGuide.class); - } - - public ArrayList, Class[]>> getGuides() { - return guides; - } - - public Guide[] getInteractionGuides(SchematicBlockState state) { - ArrayList, Class[]>> guides = getGuides(); - - ArrayList applicableGuides = new ArrayList<>(); - for (Pair, Class[]> guidePair : guides) { - try { - if (guidePair.getRight().length == 0) { - applicableGuides.add(guidePair.getLeft().getConstructor(SchematicBlockState.class).newInstance(state)); - continue; - } - - for (Class clazz : guidePair.getRight()) { - if (clazz.isInstance(state.targetState.getBlock())) { - applicableGuides.add(guidePair.getLeft().getConstructor(SchematicBlockState.class).newInstance(state)); - } - } - } catch (Exception ignored) { - } - } - - return applicableGuides.toArray(Guide[]::new); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/SkipGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/SkipGuide.java deleted file mode 100644 index d8e89d74e..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/SkipGuide.java +++ /dev/null @@ -1,37 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides; - -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19_4.actions.Action; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class SkipGuide extends Guide { - public SkipGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - return false; - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - return new ArrayList<>(); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(ItemStack.EMPTY); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/CampfireExtinguishGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/CampfireExtinguishGuide.java deleted file mode 100644 index add95f20a..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/CampfireExtinguishGuide.java +++ /dev/null @@ -1,36 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import net.minecraft.block.CampfireBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; - -public class CampfireExtinguishGuide extends InteractionGuide { - boolean shouldBeLit; - boolean isLit; - - public CampfireExtinguishGuide(SchematicBlockState state) { - super(state); - - shouldBeLit = getProperty(targetState, CampfireBlock.LIT).orElse(false); - isLit = getProperty(currentState, CampfireBlock.LIT).orElse(false); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return (currentState.getBlock() instanceof CampfireBlock) && !shouldBeLit && isLit; - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(SHOVEL_ITEMS).map(ItemStack::new).toList(); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/CycleStateGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/CycleStateGuide.java deleted file mode 100644 index 01bc21d8e..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/CycleStateGuide.java +++ /dev/null @@ -1,45 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.LeverBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.state.property.Properties; -import net.minecraft.state.property.Property; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class CycleStateGuide extends InteractionGuide { - private static final Property[] propertiesToIgnore = new Property[]{ - Properties.POWERED, - Properties.LIT - }; - - public CycleStateGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return targetState.getBlock() == currentState.getBlock(); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(ItemStack.EMPTY); - } - - @Override - protected boolean statesEqual(BlockState state1, BlockState state2) { - if (state2.getBlock() instanceof LeverBlock) { - return super.statesEqual(state1, state2); - } - - return statesEqualIgnoreProperties(state1, state2, propertiesToIgnore); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/EnderEyeGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/EnderEyeGuide.java deleted file mode 100644 index 3b34d5866..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/EnderEyeGuide.java +++ /dev/null @@ -1,33 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.state.property.Properties; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class EnderEyeGuide extends InteractionGuide { - public EnderEyeGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - if (currentState.contains(Properties.EYE) && targetState.contains(Properties.EYE)) { - return !currentState.get(Properties.EYE) && targetState.get(Properties.EYE); - } - - return false; - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(new ItemStack(Items.ENDER_EYE)); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/FlowerPotFillGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/FlowerPotFillGuide.java deleted file mode 100644 index 331e8d8f5..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/FlowerPotFillGuide.java +++ /dev/null @@ -1,40 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import net.minecraft.block.Block; -import net.minecraft.block.FlowerPotBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class FlowerPotFillGuide extends InteractionGuide { - private final Block content; - - public FlowerPotFillGuide(SchematicBlockState state) { - super(state); - - Block targetBlock = state.targetState.getBlock(); - if (targetBlock instanceof FlowerPotBlock) { - this.content = ((FlowerPotBlock) targetBlock).getContent(); - } else { - this.content = null; - } - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (content == null) return false; - if (!(currentState.getBlock() instanceof FlowerPotBlock)) return false; - - return super.canExecute(player); - } - - @Override - protected @NotNull List getRequiredItems() { - if (content == null) return Collections.emptyList(); - else return Collections.singletonList(new ItemStack(content)); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/InteractionGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/InteractionGuide.java deleted file mode 100644 index 6d6813d18..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/InteractionGuide.java +++ /dev/null @@ -1,49 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_19_4.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19_4.actions.Action; -import me.aleksilassila.litematica.printer.v1_19_4.actions.PrepareAction; -import me.aleksilassila.litematica.printer.v1_19_4.actions.ReleaseShiftAction; -import me.aleksilassila.litematica.printer.v1_19_4.guides.Guide; -import me.aleksilassila.litematica.printer.v1_19_4.implementation.actions.InteractActionImpl; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.List; - -/** - * A guide that clicks the current block to change its state. - */ -public abstract class InteractionGuide extends Guide { - public InteractionGuide(SchematicBlockState state) { - super(state); - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - List actions = new ArrayList<>(); - - BlockHitResult hitResult = new BlockHitResult(Vec3d.ofCenter(state.blockPos), Direction.UP, state.blockPos, false); - ItemStack requiredItem = getRequiredItem(player).orElse(ItemStack.EMPTY); - int requiredSlot = getRequiredItemStackSlot(player); - - if (requiredSlot == -1) return actions; - - PrinterPlacementContext ctx = new PrinterPlacementContext(player, hitResult, requiredItem, requiredSlot); - - actions.add(new ReleaseShiftAction()); - actions.add(new PrepareAction(ctx)); - actions.add(new InteractActionImpl(ctx)); - - return actions; - } - - @Override - abstract protected @NotNull List getRequiredItems(); -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/LightCandleGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/LightCandleGuide.java deleted file mode 100644 index a358008b9..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/LightCandleGuide.java +++ /dev/null @@ -1,36 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import net.minecraft.block.AbstractCandleBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.state.property.Properties; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class LightCandleGuide extends InteractionGuide { - boolean shouldBeLit; - boolean isLit; - - public LightCandleGuide(SchematicBlockState state) { - super(state); - - shouldBeLit = getProperty(targetState, Properties.LIT).orElse(false); - isLit = getProperty(currentState, Properties.LIT).orElse(false); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(new ItemStack(Items.FLINT_AND_STEEL)); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return (currentState.getBlock() instanceof AbstractCandleBlock) && shouldBeLit && !isLit; - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/LogStrippingGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/LogStrippingGuide.java deleted file mode 100644 index 2e0861329..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/LogStrippingGuide.java +++ /dev/null @@ -1,47 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_19_4.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19_4.mixin.AxeItemAccessor; -import net.minecraft.block.Block; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -public class LogStrippingGuide extends InteractionGuide { - static final Item[] AXE_ITEMS = new Item[]{ - Items.NETHERITE_AXE, - Items.DIAMOND_AXE, - Items.GOLDEN_AXE, - Items.IRON_AXE, - Items.STONE_AXE, - Items.WOODEN_AXE - }; - - public static final Map STRIPPED_BLOCKS = AxeItemAccessor.getStrippedBlocks(); - - public LogStrippingGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!LitematicaMixinMod.STRIP_LOGS.getBooleanValue()) return false; - - if (!super.canExecute(player)) return false; - - Block strippingResult = STRIPPED_BLOCKS.get(currentState.getBlock()); - return strippingResult == targetState.getBlock(); - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(AXE_ITEMS).map(ItemStack::new).toList(); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/TillingGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/TillingGuide.java deleted file mode 100644 index 7d3b95746..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/interaction/TillingGuide.java +++ /dev/null @@ -1,39 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19_4.guides.placement.FarmlandGuide; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; - -public class TillingGuide extends InteractionGuide { - public static final Item[] HOE_ITEMS = new Item[]{ - Items.NETHERITE_HOE, - Items.DIAMOND_HOE, - Items.GOLDEN_HOE, - Items.IRON_HOE, - Items.STONE_HOE, - Items.WOODEN_HOE - }; - - public TillingGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return Arrays.stream(FarmlandGuide.TILLABLE_BLOCKS).anyMatch(b -> b == currentState.getBlock()); - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(HOE_ITEMS).map(ItemStack::new).toList(); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/BlockIndifferentGuesserGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/BlockIndifferentGuesserGuide.java deleted file mode 100644 index d167845bc..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/BlockIndifferentGuesserGuide.java +++ /dev/null @@ -1,42 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import net.minecraft.block.*; - -public class BlockIndifferentGuesserGuide extends GuesserGuide { - public BlockIndifferentGuesserGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected boolean statesEqual(BlockState resultState, BlockState targetState) { - Block targetBlock = targetState.getBlock(); - Block resultBlock = resultState.getBlock(); - - if (targetBlock instanceof BambooBlock) { - return resultBlock instanceof BambooBlock || resultBlock instanceof BambooSaplingBlock; - } - - if (targetBlock instanceof BigDripleafStemBlock) { - if (resultBlock instanceof BigDripleafBlock || resultBlock instanceof BigDripleafStemBlock) { - return resultState.get(HorizontalFacingBlock.FACING) == targetState.get(HorizontalFacingBlock.FACING); - } - } - - if (targetBlock instanceof TwistingVinesPlantBlock) { - if (resultBlock instanceof TwistingVinesBlock) { - return true; - } else if (resultBlock instanceof TwistingVinesPlantBlock) { - return statesEqualIgnoreProperties(resultState, targetState, TwistingVinesBlock.AGE); - } - } - - if (targetBlock instanceof TripwireBlock && resultBlock instanceof TripwireBlock) { - return statesEqualIgnoreProperties(resultState, targetState, - TripwireBlock.ATTACHED, TripwireBlock.DISARMED, TripwireBlock.POWERED, TripwireBlock.NORTH, - TripwireBlock.EAST, TripwireBlock.SOUTH, TripwireBlock.WEST); - } - - return super.statesEqual(resultState, targetState); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/BlockReplacementGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/BlockReplacementGuide.java deleted file mode 100644 index c686b8248..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/BlockReplacementGuide.java +++ /dev/null @@ -1,75 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_4.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import net.minecraft.block.CandleBlock; -import net.minecraft.block.SeaPickleBlock; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.SnowBlock; -import net.minecraft.block.enums.SlabType; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.state.property.IntProperty; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.Nullable; - -import java.util.HashMap; -import java.util.Optional; - -public class BlockReplacementGuide extends PlacementGuide { - private static final HashMap increasingProperties = new HashMap<>(); - - static { - increasingProperties.put(SnowBlock.LAYERS, null); - increasingProperties.put(SeaPickleBlock.PICKLES, null); - increasingProperties.put(CandleBlock.CANDLES, null); - } - - private Integer currentLevel = null; - private Integer targetLevel = null; - private IntProperty increasingProperty = null; - - public BlockReplacementGuide(SchematicBlockState state) { - super(state); - - for (IntProperty property : increasingProperties.keySet()) { - if (targetState.contains(property) && currentState.contains(property)) { - currentLevel = currentState.get(property); - targetLevel = targetState.get(property); - increasingProperty = property; - break; - } - } - } - - @Override - protected boolean getUseShift(SchematicBlockState state) { - return false; - } - - @Override - public @Nullable PrinterPlacementContext getPlacementContext(ClientPlayerEntity player) { - Optional requiredItem = getRequiredItem(player); - int slot = getRequiredItemStackSlot(player); - if (requiredItem.isEmpty() || slot == -1) return null; - - BlockHitResult hitResult = new BlockHitResult(Vec3d.ofCenter(state.blockPos), Direction.UP, state.blockPos, false); - return new PrinterPlacementContext(player, hitResult, requiredItem.get(), slot); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (getProperty(targetState, SlabBlock.TYPE).orElse(null) == SlabType.DOUBLE && getProperty(currentState, SlabBlock.TYPE).orElse(SlabType.DOUBLE) != SlabType.DOUBLE) { - return super.canExecute(player); - } - - if (currentLevel == null || targetLevel == null || increasingProperty == null) return false; - if (!statesEqualIgnoreProperties(currentState, targetState, CandleBlock.LIT, increasingProperty)) return false; - if (currentLevel >= targetLevel) return false; - - return super.canExecute(player); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/ChestGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/ChestGuide.java deleted file mode 100644 index 14dbee26c..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/ChestGuide.java +++ /dev/null @@ -1,92 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.ChestBlock; -import net.minecraft.block.enums.ChestType; -import net.minecraft.util.math.Direction; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -/** - * Whilst making this guide, I learned that chests are much like humans. - * Some prefer to stay single, and some want to connect with another of its kind. - * Also that reversing chest connection logic is an enormous pain in the ass. I spent way too long on this. - * Thanks for coming to my ted talk - */ -public class ChestGuide extends GeneralPlacementGuide { - public ChestGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected boolean getRequiresExplicitShift() { - return true; - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - protected Optional getLookDirection() { - return getProperty(targetState, ChestBlock.FACING) - .flatMap(facing -> Optional.of(facing.getOpposite())); - } - - @Override - protected List getPossibleSides() { - ChestType targetType = getProperty(targetState, ChestBlock.CHEST_TYPE).orElse(null); - Direction targetFacing = getProperty(targetState, ChestBlock.FACING).orElse(null); - - List sides = new ArrayList<>(); - - if (targetFacing == null || targetType == null) return sides; - - for (Direction direction : Direction.values()) { - if (targetType == ChestType.SINGLE && !willConnectToSide(state, direction)) { - sides.add(direction); - } else if (wantsToConnectToSide(state, direction) && willConnectToSide(state, direction)) { // :D - sides.add(direction); - } - } - - // Place single chests if cannot connect any existing chests - if (sides.isEmpty()) { - for (Direction direction : Direction.values()) { - if (!wantsToConnectToSide(state, direction) && !willConnectToSide(state, direction)) { - sides.add(direction); - } - } - } - - return sides; - } - - private boolean willConnectToSide(SchematicBlockState state, Direction neighborDirection) { - BlockState neighbor = state.offset(neighborDirection).currentState; - ChestType neighborType = getProperty(neighbor, ChestBlock.CHEST_TYPE).orElse(null); - Direction neighborFacing = getProperty(neighbor, ChestBlock.FACING).orElse(null); - Direction facing = getProperty(state.targetState, ChestBlock.FACING).orElse(null); - - if (neighborType == null || neighborFacing == null || facing == null) return false; - - if (facing.getAxis() == neighborDirection.getAxis() || neighborDirection.getAxis() == Direction.Axis.Y) - return false; - - return neighborType == ChestType.SINGLE && neighborFacing == facing && state.targetState.getBlock() == neighbor.getBlock(); - } - - private boolean wantsToConnectToSide(SchematicBlockState state, Direction direction) { - ChestType type = getProperty(state.targetState, ChestBlock.CHEST_TYPE).orElse(null); - Direction facing = getProperty(state.targetState, ChestBlock.FACING).orElse(null); - if (type == null || facing == null || type == ChestType.SINGLE) return false; - - Direction neighborDirection = type == ChestType.LEFT ? facing.rotateYClockwise() : facing.rotateYCounterclockwise(); - - return direction == neighborDirection; - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/FallingBlockGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/FallingBlockGuide.java deleted file mode 100644 index ef419bd87..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/FallingBlockGuide.java +++ /dev/null @@ -1,37 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.FallingBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.math.Direction; - -public class FallingBlockGuide extends GuesserGuide { - - public FallingBlockGuide(SchematicBlockState state) { - super(state); - } - - boolean blockPlacement() { - if (targetState.getBlock() instanceof FallingBlock) { - BlockState below = state.world.getBlockState(state.blockPos.offset(Direction.DOWN)); - return FallingBlock.canFallThrough(below); - } - - return false; - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (blockPlacement()) return false; - - return super.canExecute(player); - } - - @Override - public boolean skipOtherGuides() { - if (blockPlacement()) return true; - - return super.skipOtherGuides(); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/FarmlandGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/FarmlandGuide.java deleted file mode 100644 index 0e9870ee2..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/FarmlandGuide.java +++ /dev/null @@ -1,29 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; - -public class FarmlandGuide extends GeneralPlacementGuide { - public static final Block[] TILLABLE_BLOCKS = new Block[]{ - Blocks.DIRT, - Blocks.GRASS_BLOCK, - Blocks.COARSE_DIRT, - Blocks.ROOTED_DIRT, - Blocks.DIRT_PATH, - }; - - public FarmlandGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(TILLABLE_BLOCKS).map(b -> getBlockItem(b.getDefaultState())).toList(); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/FlowerPotGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/FlowerPotGuide.java deleted file mode 100644 index e83611246..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/FlowerPotGuide.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class FlowerPotGuide extends GeneralPlacementGuide { - public FlowerPotGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(new ItemStack(Items.FLOWER_POT)); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/GeneralPlacementGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/GeneralPlacementGuide.java deleted file mode 100644 index 90ce0d801..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/GeneralPlacementGuide.java +++ /dev/null @@ -1,119 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_4.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.enums.SlabType; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -/** - * An old school guide where there are defined specific conditions - * for player state depending on the block being placed. - */ -public class GeneralPlacementGuide extends PlacementGuide { - public GeneralPlacementGuide(SchematicBlockState state) { - super(state); - } - - protected List getPossibleSides() { - return Arrays.asList(Direction.values()); - } - - protected Optional getLookDirection() { - return Optional.empty(); - } - - protected boolean getRequiresSupport() { - return false; - } - - protected boolean getRequiresExplicitShift() { - return false; - } - - protected Vec3d getHitModifier(Direction validSide) { - return new Vec3d(0, 0, 0); - } - - private Optional getValidSide(SchematicBlockState state) { - boolean printInAir = false; // LitematicaMixinMod.PRINT_IN_AIR.getBooleanValue(); - - List sides = getPossibleSides(); - - if (sides.isEmpty()) { - return Optional.empty(); - } - - List validSides = new ArrayList<>(); - for (Direction side : sides) { - if (printInAir && !getRequiresSupport()) { - return Optional.of(side); - } else { - SchematicBlockState neighborState = state.offset(side); - - if (getProperty(neighborState.currentState, SlabBlock.TYPE).orElse(null) == SlabType.DOUBLE) { - validSides.add(side); - continue; - } - - if (canBeClicked(neighborState.world, neighborState.blockPos) && // Handle unclickable grass for example - !neighborState.currentState.getMaterial().isReplaceable()) - validSides.add(side); - } - } - - for (Direction validSide : validSides) { - if (!isInteractive(state.offset(validSide).currentState.getBlock())) { - return Optional.of(validSide); - } - } - - return validSides.isEmpty() ? Optional.empty() : Optional.of(validSides.get(0)); - } - - protected boolean getUseShift(SchematicBlockState state) { - if (getRequiresExplicitShift()) return true; - - Direction clickSide = getValidSide(state).orElse(null); - if (clickSide == null) return false; - return isInteractive(state.offset(clickSide).currentState.getBlock()); - } - - private Optional getHitVector(SchematicBlockState state) { - return getValidSide(state).map(side -> Vec3d.ofCenter(state.blockPos) - .add(Vec3d.of(side.getVector()).multiply(0.5)) - .add(getHitModifier(side))); - } - - @Nullable - public PrinterPlacementContext getPlacementContext(ClientPlayerEntity player) { - try { - Optional validSide = getValidSide(state); - Optional hitVec = getHitVector(state); - Optional requiredItem = getRequiredItem(player); - int requiredSlot = getRequiredItemStackSlot(player); - - if (validSide.isEmpty() || hitVec.isEmpty() || requiredItem.isEmpty() || requiredSlot == -1) return null; - - Optional lookDirection = getLookDirection(); - boolean requiresShift = getUseShift(state); - - BlockHitResult blockHitResult = new BlockHitResult(hitVec.get(), validSide.get().getOpposite(), state.blockPos.offset(validSide.get()), false); - - return new PrinterPlacementContext(player, blockHitResult, requiredItem.get(), requiredSlot, lookDirection.orElse(null), requiresShift); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/GuesserGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/GuesserGuide.java deleted file mode 100644 index 0cb137d96..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/GuesserGuide.java +++ /dev/null @@ -1,110 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_4.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_19_4.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.ChestBlock; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.enums.ChestType; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.Nullable; - -/** - * This is the placement guide that most blocks will use. - * It will try to predict the correct player state for producing the right blockState - * by brute forcing the correct hit vector and look direction. - */ -public class GuesserGuide extends GeneralPlacementGuide { - private PrinterPlacementContext contextCache = null; - - protected static Direction[] directionsToTry = new Direction[]{ - Direction.NORTH, - Direction.SOUTH, - Direction.EAST, - Direction.WEST, - Direction.UP, - Direction.DOWN - }; - protected static Vec3d[] hitVecsToTry = new Vec3d[]{ - new Vec3d(-0.25, -0.25, -0.25), - new Vec3d(+0.25, -0.25, -0.25), - new Vec3d(-0.25, +0.25, -0.25), - new Vec3d(-0.25, -0.25, +0.25), - new Vec3d(+0.25, +0.25, -0.25), - new Vec3d(-0.25, +0.25, +0.25), - new Vec3d(+0.25, -0.25, +0.25), - new Vec3d(+0.25, +0.25, +0.25), - }; - - public GuesserGuide(SchematicBlockState state) { - super(state); - } - - @Nullable - @Override - public PrinterPlacementContext getPlacementContext(ClientPlayerEntity player) { - if (contextCache != null && !LitematicaMixinMod.DEBUG) return contextCache; - - ItemStack requiredItem = getRequiredItem(player).orElse(ItemStack.EMPTY); - int slot = getRequiredItemStackSlot(player); - - if (slot == -1) return null; - - for (Direction lookDirection : directionsToTry) { - for (Direction side : directionsToTry) { - BlockPos neighborPos = state.blockPos.offset(side); - BlockState neighborState = state.world.getBlockState(neighborPos); - boolean requiresShift = getRequiresExplicitShift() || isInteractive(neighborState.getBlock()); - - if (!canBeClicked(state.world, neighborPos) || // Handle unclickable grass for example - neighborState.getMaterial().isReplaceable()) - continue; - - Vec3d hitVec = Vec3d.ofCenter(state.blockPos) - .add(Vec3d.of(side.getVector()).multiply(0.5)); - - for (Vec3d hitVecToTry : hitVecsToTry) { - Vec3d multiplier = Vec3d.of(side.getVector()); - multiplier = new Vec3d(multiplier.x == 0 ? 1 : 0, multiplier.y == 0 ? 1 : 0, multiplier.z == 0 ? 1 : 0); - - BlockHitResult hitResult = new BlockHitResult(hitVec.add(hitVecToTry.multiply(multiplier)), side.getOpposite(), neighborPos, false); - PrinterPlacementContext context = new PrinterPlacementContext(player, hitResult, requiredItem, slot, lookDirection, requiresShift); - BlockState result = getRequiredItemAsBlock(player) - .orElse(targetState.getBlock()) - .getPlacementState(context); // FIXME torch shift clicks another torch and getPlacementState is the clicked block, which is true - - if (result != null && (statesEqual(result, targetState) || correctChestPlacement(targetState, result))) { - contextCache = context; - return context; - } - } - } - } - - return null; - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (targetState.getBlock() instanceof SlabBlock) return false; // Slabs are a special case - - return super.canExecute(player); - } - - private boolean correctChestPlacement(BlockState targetState, BlockState result) { - if (targetState.contains(ChestBlock.CHEST_TYPE) && result.contains(ChestBlock.CHEST_TYPE) && result.get(ChestBlock.FACING) == targetState.get(ChestBlock.FACING)) { - ChestType targetChestType = targetState.get(ChestBlock.CHEST_TYPE); - ChestType resultChestType = result.get(ChestBlock.CHEST_TYPE); - - return targetChestType != ChestType.SINGLE && resultChestType == ChestType.SINGLE; - } - - return false; - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/LogGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/LogGuide.java deleted file mode 100644 index e5b66b9be..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/LogGuide.java +++ /dev/null @@ -1,54 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_4.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19_4.guides.interaction.LogStrippingGuide; -import net.minecraft.block.Block; -import net.minecraft.block.PillarBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.Direction; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -public class LogGuide extends GeneralPlacementGuide { - public LogGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - if (targetState.contains(PillarBlock.AXIS)) { - Direction.Axis axis = targetState.get(PillarBlock.AXIS); - return Arrays.stream(Direction.values()).filter(d -> d.getAxis() == axis).toList(); - } - - return new ArrayList<>(); - } - - @Override - protected @NotNull List getRequiredItems() { - for (Block log : LogStrippingGuide.STRIPPED_BLOCKS.keySet()) { - if (targetState.getBlock() == LogStrippingGuide.STRIPPED_BLOCKS.get(log)) { - return Collections.singletonList(new ItemStack(log)); - } - } - - return super.getRequiredItems(); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!LitematicaMixinMod.STRIP_LOGS.getBooleanValue()) return false; - - if (LogStrippingGuide.STRIPPED_BLOCKS.containsValue(targetState.getBlock())) { - return super.canExecute(player); - } - - return false; - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/PlacementGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/PlacementGuide.java deleted file mode 100644 index 6058a4ee1..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/PlacementGuide.java +++ /dev/null @@ -1,138 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_4.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_19_4.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19_4.actions.Action; -import me.aleksilassila.litematica.printer.v1_19_4.actions.PrepareAction; -import me.aleksilassila.litematica.printer.v1_19_4.actions.ReleaseShiftAction; -import me.aleksilassila.litematica.printer.v1_19_4.guides.Guide; -import me.aleksilassila.litematica.printer.v1_19_4.implementation.actions.InteractActionImpl; -import net.minecraft.block.*; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.World; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -/** - * Guide that clicks its neighbors to create a placement in target position. - */ -abstract public class PlacementGuide extends Guide { - public PlacementGuide(SchematicBlockState state) { - super(state); - } - - protected ItemStack getBlockItem(BlockState state) { - return state.getBlock().getPickStack(this.state.world, this.state.blockPos, state); - } - - protected Optional getRequiredItemAsBlock(ClientPlayerEntity player) { - Optional requiredItem = getRequiredItem(player); - - if (requiredItem.isEmpty()) { - return Optional.empty(); - } else { - ItemStack itemStack = requiredItem.get(); - - if (itemStack.getItem() instanceof BlockItem) - return Optional.of(((BlockItem) itemStack.getItem()).getBlock()); - else return Optional.empty(); - } - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(getBlockItem(state.targetState)); - } - - abstract protected boolean getUseShift(SchematicBlockState state); - - @Nullable - abstract public PrinterPlacementContext getPlacementContext(ClientPlayerEntity player); - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - List requiredItems = getRequiredItems(); - if (requiredItems.isEmpty() || requiredItems.stream().allMatch(i -> i.isOf(Items.AIR))) - return false; - - ItemPlacementContext ctx = getPlacementContext(player); - if (ctx == null || !ctx.canPlace()) return false; -// if (!state.currentState.getMaterial().isReplaceable()) return false; - if (!LitematicaMixinMod.REPLACE_FLUIDS_SOURCE_BLOCKS.getBooleanValue() - && getProperty(state.currentState, FluidBlock.LEVEL).orElse(1) == 0) - return false; - - BlockState resultState = getRequiredItemAsBlock(player) - .orElse(targetState.getBlock()) - .getPlacementState(ctx); - - if (resultState != null) { - if (!resultState.canPlaceAt(state.world, state.blockPos)) return false; - return !(currentState.getBlock() instanceof FluidBlock) || canPlaceInWater(resultState); - } else { - return false; - } - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - List actions = new ArrayList<>(); - PrinterPlacementContext ctx = getPlacementContext(player); - - if (ctx == null) return actions; - actions.add(new PrepareAction(ctx)); - actions.add(new InteractActionImpl(ctx)); - if (ctx.shouldSneak) actions.add(new ReleaseShiftAction()); - - return actions; - } - - protected static boolean canBeClicked(World world, BlockPos pos) { - return getOutlineShape(world, pos) != VoxelShapes.empty() && !(world.getBlockState(pos).getBlock() instanceof AbstractSignBlock); // FIXME signs - } - - private static VoxelShape getOutlineShape(World world, BlockPos pos) { - return world.getBlockState(pos).getOutlineShape(world, pos); - } - - public boolean isInteractive(Block block) { - for (Class clazz : interactiveBlocks) { - if (clazz.isInstance(block)) { - return true; - } - } - - return false; - } - - private boolean canPlaceInWater(BlockState blockState) { - Block block = blockState.getBlock(); - if (block instanceof FluidFillable) { - return true; - } else if (!(block instanceof DoorBlock) && !(blockState.getBlock() instanceof AbstractSignBlock) && !blockState.isOf(Blocks.LADDER) && !blockState.isOf(Blocks.SUGAR_CANE) && !blockState.isOf(Blocks.BUBBLE_COLUMN)) { - Material material = blockState.getMaterial(); - if (material != Material.PORTAL && material != Material.STRUCTURE_VOID && material != Material.UNDERWATER_PLANT && material != Material.REPLACEABLE_UNDERWATER_PLANT) { - return material.blocksMovement(); - } else { - return true; - } - } - - return true; - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/PropertySpecificGuesserGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/PropertySpecificGuesserGuide.java deleted file mode 100644 index 9d7b6a722..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/PropertySpecificGuesserGuide.java +++ /dev/null @@ -1,52 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import net.minecraft.block.*; -import net.minecraft.state.property.Properties; -import net.minecraft.state.property.Property; - -public class PropertySpecificGuesserGuide extends GuesserGuide { - protected static Property[] ignoredProperties = new Property[]{ - RepeaterBlock.DELAY, - ComparatorBlock.MODE, - RedstoneWireBlock.POWER, - RedstoneWireBlock.WIRE_CONNECTION_EAST, - RedstoneWireBlock.WIRE_CONNECTION_NORTH, - RedstoneWireBlock.WIRE_CONNECTION_SOUTH, - RedstoneWireBlock.WIRE_CONNECTION_WEST, - Properties.POWERED, - Properties.OPEN, - PointedDripstoneBlock.THICKNESS, - ScaffoldingBlock.DISTANCE, - ScaffoldingBlock.BOTTOM, - CactusBlock.AGE, - BambooBlock.AGE, - BambooBlock.LEAVES, - BambooBlock.STAGE, - SaplingBlock.STAGE, - HorizontalConnectingBlock.EAST, - HorizontalConnectingBlock.NORTH, - HorizontalConnectingBlock.SOUTH, - HorizontalConnectingBlock.WEST, - SnowBlock.LAYERS, - SeaPickleBlock.PICKLES, - CandleBlock.CANDLES, - EndPortalFrameBlock.EYE, - Properties.LIT, - LeavesBlock.DISTANCE, - LeavesBlock.PERSISTENT, - Properties.ATTACHED, - Properties.NOTE, - Properties.INSTRUMENT, - - }; - - public PropertySpecificGuesserGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected boolean statesEqual(BlockState resultState, BlockState targetState) { - return statesEqualIgnoreProperties(resultState, targetState, ignoredProperties); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/RailGuesserGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/RailGuesserGuide.java deleted file mode 100644 index e9be5c9a1..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/RailGuesserGuide.java +++ /dev/null @@ -1,128 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.enums.RailShape; -import net.minecraft.state.property.Properties; -import net.minecraft.util.math.Direction; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -public class RailGuesserGuide extends GuesserGuide { - static final RailShape[] STRAIGHT_RAIL_SHAPES = new RailShape[]{ - RailShape.NORTH_SOUTH, - RailShape.EAST_WEST - }; - - public RailGuesserGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - protected boolean statesEqual(BlockState resultState, BlockState targetState) { - if (!wouldConnectCorrectly()) return false; -// if (wouldBlockAnotherConnection()) return false; - /*TODO: Fully working rail guesser - * If has a neighbor that: - * - Has not been placed yet - * - OR Has been placed but can change shape - * - AND this placement should connect to only one rail, that is not the neighbor - * Then return false - * */ - - if (getRailShape(resultState).isPresent()) { - if (Arrays.stream(STRAIGHT_RAIL_SHAPES).anyMatch(shape -> shape == getRailShape(resultState).orElse(null))) { - return super.statesEqualIgnoreProperties(resultState, targetState, Properties.RAIL_SHAPE, Properties.STRAIGHT_RAIL_SHAPE, Properties.POWERED); - } - } - - return super.statesEqual(resultState, targetState); - } - - private boolean wouldConnectCorrectly() { - RailShape targetShape = getRailShape(state.targetState).orElse(null); - if (targetShape == null) return false; - - List allowedConnections = getRailDirections(targetShape); - - List possibleConnections = new ArrayList<>(); - for (Direction d : Direction.values()) { - if (d.getAxis().isVertical()) continue; - SchematicBlockState neighbor = state.offset(d); - - if (hasFreeConnections(neighbor)) { - possibleConnections.add(d); - } - } - - if (possibleConnections.size() > 2) return false; - - return allowedConnections.containsAll(possibleConnections); - } - -// private boolean wouldBlockAnotherConnection() { -// List possibleConnections = new ArrayList<>(); -// -// for (Direction d : Direction.values()) { -// if (d.getAxis().isVertical()) continue; -// SchematicBlockState neighbor = state.offset(d); -// -// if (couldConnectWrongly(neighbor)) { -// possibleConnections.add(d); -// } -// } -// -// return possibleConnections.size() > 1; -// } - - private boolean hasFreeConnections(SchematicBlockState state) { - List possibleConnections = getRailDirections(state); - if (possibleConnections.isEmpty()) return false; - - for (Direction d : possibleConnections) { - SchematicBlockState neighbor = state.offset(d); - if (neighbor.currentState.getBlock() != neighbor.currentState.getBlock()) { - return false; - } - } - - return possibleConnections.stream().anyMatch(possibleDirection -> { - SchematicBlockState neighbor = state.offset(possibleDirection); - return !getRailDirections(neighbor).contains(possibleDirection.getOpposite()); - }); - } - - private List getRailDirections(SchematicBlockState state) { - RailShape shape = getRailShape(state.currentState).orElse(null); - if (shape == null) return new ArrayList<>(); - - return getRailDirections(shape); - } - - private List getRailDirections(RailShape railShape) { - String name = railShape.getName(); - - if (railShape.isAscending()) { - Direction d = Direction.valueOf(name.replace("ascending_", "").toUpperCase()); - return Arrays.asList(d, d.getOpposite()); - } else { - Direction d1 = Direction.valueOf(name.split("_")[0].toUpperCase()); - Direction d2 = Direction.valueOf(name.split("_")[1].toUpperCase()); - return Arrays.asList(d1, d2); - } - } - - Optional getRailShape(BlockState state) { - Optional shape = getProperty(state, Properties.RAIL_SHAPE); - if (shape.isEmpty()) return getProperty(state, Properties.STRAIGHT_RAIL_SHAPE); - return shape; - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/RotatingBlockGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/RotatingBlockGuide.java deleted file mode 100644 index 29c79e2d2..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/RotatingBlockGuide.java +++ /dev/null @@ -1,58 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_4.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19_4.actions.Action; -import me.aleksilassila.litematica.printer.v1_19_4.actions.PrepareAction; -import net.minecraft.block.*; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.state.property.Properties; -import net.minecraft.util.math.Direction; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -public class RotatingBlockGuide extends GeneralPlacementGuide { - public RotatingBlockGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - Block block = state.targetState.getBlock(); - if (block instanceof WallSkullBlock || block instanceof WallSignBlock || block instanceof WallBannerBlock) { - Optional side = getProperty(state.targetState, Properties.HORIZONTAL_FACING).map(Direction::getOpposite); - return side.map(Collections::singletonList).orElseGet(Collections::emptyList); - } - - return Collections.singletonList(Direction.DOWN); - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - PrinterPlacementContext ctx = getPlacementContext(player); - - if (ctx == null) return new ArrayList<>(); - - int rotation = getProperty(state.targetState, Properties.ROTATION).orElse(0); - if (targetState.getBlock() instanceof BannerBlock || targetState.getBlock() instanceof SignBlock) { - rotation = (rotation + 8) % 16; - } - - int distTo0 = rotation > 8 ? 16 - rotation : rotation; - float yaw = Math.round(distTo0 / 8f * 180f * (rotation > 8 ? -1 : 1)); - - List actions = super.execute(player); - actions.set(0, new PrepareAction(ctx, yaw, 0)); - - return actions; - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/SlabGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/SlabGuide.java deleted file mode 100644 index 17c1549a7..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/SlabGuide.java +++ /dev/null @@ -1,48 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.enums.SlabType; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; - -import java.util.Arrays; -import java.util.List; - -public class SlabGuide extends GeneralPlacementGuide { - public SlabGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - return Arrays.stream(Direction.values()) - .filter(d -> d != (getRequiredHalf(state).getOpposite()) && - getProperty(state.offset(d).currentState, SlabBlock.TYPE).orElse(SlabType.DOUBLE) == SlabType.DOUBLE) - .toList(); - } - - @Override - protected Vec3d getHitModifier(Direction validSide) { - Direction requiredHalf = getRequiredHalf(state); - if (validSide.getHorizontal() != -1) { - return new Vec3d(0, requiredHalf.getOffsetY() * 0.25, 0); - } else { - return new Vec3d(0, 0, 0); - } - } - - private Direction getRequiredHalf(SchematicBlockState state) { - BlockState targetState = state.targetState; - BlockState currentState = state.currentState; - - if (!currentState.contains(SlabBlock.TYPE)) { - return targetState.get(SlabBlock.TYPE) == SlabType.TOP ? Direction.UP : Direction.DOWN; - } else if (currentState.get(SlabBlock.TYPE) != targetState.get(SlabBlock.TYPE)) { - return currentState.get(SlabBlock.TYPE) == SlabType.TOP ? Direction.DOWN : Direction.UP; - } else { - return Direction.DOWN; - } - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/TorchGuide.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/TorchGuide.java deleted file mode 100644 index 6a9e6df40..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/guides/placement/TorchGuide.java +++ /dev/null @@ -1,31 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import net.minecraft.block.Block; -import net.minecraft.block.HorizontalFacingBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.math.Direction; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -public class TorchGuide extends GeneralPlacementGuide { - public TorchGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - Optional facing = getProperty(targetState, HorizontalFacingBlock.FACING); - - return facing - .map(direction -> Collections.singletonList(direction.getOpposite())) - .orElseGet(() -> Collections.singletonList(Direction.DOWN)); - } - - @Override - protected Optional getRequiredItemAsBlock(ClientPlayerEntity player) { - return Optional.of(state.targetState.getBlock()); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/implementation/BlockHelperImpl.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/implementation/BlockHelperImpl.java deleted file mode 100644 index 094429e76..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/implementation/BlockHelperImpl.java +++ /dev/null @@ -1,14 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.implementation; - -import me.aleksilassila.litematica.printer.v1_19_4.BlockHelper; -import net.minecraft.block.ButtonBlock; - -import java.util.Arrays; - -public class BlockHelperImpl extends BlockHelper { - static { - interactiveBlocks.addAll(Arrays.asList( - ButtonBlock.class - )); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/implementation/PrinterPlacementContext.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/implementation/PrinterPlacementContext.java deleted file mode 100644 index 7a9ca7b5a..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/implementation/PrinterPlacementContext.java +++ /dev/null @@ -1,59 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.implementation; - -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import org.jetbrains.annotations.Nullable; - -public class PrinterPlacementContext extends ItemPlacementContext { - public final @Nullable Direction lookDirection; - public final boolean shouldSneak; - public final BlockHitResult hitResult; - public final int requiredItemSlot; - - public PrinterPlacementContext(PlayerEntity player, BlockHitResult hitResult, ItemStack requiredItem, int requiredItemSlot) { - this(player, hitResult, requiredItem, requiredItemSlot, null, false); - } - - public PrinterPlacementContext(PlayerEntity player, BlockHitResult hitResult, ItemStack requiredItem, int requiredItemSlot, @Nullable Direction lookDirection, boolean requiresSneaking) { - super(player, Hand.MAIN_HAND, requiredItem, hitResult); - - this.lookDirection = lookDirection; - this.shouldSneak = requiresSneaking; - this.hitResult = hitResult; - this.requiredItemSlot = requiredItemSlot; - } - - @Override - public Direction getPlayerLookDirection() { - return lookDirection == null ? super.getPlayerLookDirection() : lookDirection; - } - - @Override - public Direction getVerticalPlayerLookDirection() { - if (lookDirection != null && lookDirection.getOpposite() == super.getVerticalPlayerLookDirection()) - return lookDirection; - return super.getVerticalPlayerLookDirection(); - } - - @Override - public Direction getHorizontalPlayerFacing() { - if (lookDirection == null || !lookDirection.getAxis().isHorizontal()) return super.getHorizontalPlayerFacing(); - - return lookDirection; - } - - @Override - public String toString() { - return "PrinterPlacementContext{" + - "lookDirection=" + lookDirection + - ", requiresSneaking=" + shouldSneak + - ", blockPos=" + hitResult.getBlockPos() + - ", side=" + hitResult.getSide() + -// ", hitVec=" + hitResult + - '}'; - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/implementation/actions/InteractActionImpl.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/implementation/actions/InteractActionImpl.java deleted file mode 100644 index ffddbc979..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/implementation/actions/InteractActionImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.implementation.actions; - -import me.aleksilassila.litematica.printer.v1_19_4.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_19_4.actions.InteractAction; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; - -public class InteractActionImpl extends InteractAction { - public InteractActionImpl(PrinterPlacementContext context) { - super(context); - } - - @Override - protected void interact(MinecraftClient client, ClientPlayerEntity player, Hand hand, BlockHitResult hitResult) { - client.interactionManager.interactBlock(player, hand, hitResult); - client.interactionManager.interactItem(player, hand); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/implementation/mixin/MixinClientPlayerEntity.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/implementation/mixin/MixinClientPlayerEntity.java deleted file mode 100644 index 05b02ec2e..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/implementation/mixin/MixinClientPlayerEntity.java +++ /dev/null @@ -1,103 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.implementation.mixin; - -import com.mojang.authlib.GameProfile; -import fi.dy.masa.litematica.world.SchematicWorldHandler; -import fi.dy.masa.litematica.world.WorldSchematic; -import me.aleksilassila.litematica.printer.v1_19_4.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_19_4.Printer; -import me.aleksilassila.litematica.printer.v1_19_4.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_19_4.UpdateChecker; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.block.entity.SignBlockEntity; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.AbstractClientPlayerEntity; -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.network.encryption.PlayerPublicKey; -import net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket; -import net.minecraft.text.Text; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -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; - -import java.util.Optional; - -@Mixin(ClientPlayerEntity.class) -public class MixinClientPlayerEntity extends AbstractClientPlayerEntity { - - private static boolean didCheckForUpdates = false; - - @Shadow - protected MinecraftClient client; - @Shadow - public ClientPlayNetworkHandler networkHandler; - - public MixinClientPlayerEntity(ClientWorld world, GameProfile profile) { - super(world, profile); - } - - @Inject(at = @At("TAIL"), method = "tick") - public void tick(CallbackInfo ci) { - ClientPlayerEntity clientPlayer = (ClientPlayerEntity) (Object) this; - if (!didCheckForUpdates) { - didCheckForUpdates = true; - - checkForUpdates(); - } - - if (LitematicaMixinMod.printer == null || LitematicaMixinMod.printer.player != clientPlayer) { - System.out.println("Initializing printer, player: " + clientPlayer + ", client: " + client); - LitematicaMixinMod.printer = new Printer(client, clientPlayer); - } - - // Dirty optimization - boolean didFindPlacement = true; - for (int i = 0; i < 10; i++) { - if (didFindPlacement) { - didFindPlacement = LitematicaMixinMod.printer.onGameTick(); - } - LitematicaMixinMod.printer.actionHandler.onGameTick(); - } - } - - public void checkForUpdates() { - new Thread(() -> { - String version = UpdateChecker.version; - String newVersion = UpdateChecker.getPrinterVersion(); - - if (!version.equals(newVersion)) { - client.inGameHud.getChatHud().addMessage(Text.literal("New version of Litematica Printer available in https://github.com/aleksilassila/litematica-printer/releases")); - } - }).start(); - } - - @Inject(method = "openEditSignScreen", at = @At("HEAD"), cancellable = true) - public void openEditSignScreen(SignBlockEntity sign, CallbackInfo ci) { - getTargetSignEntity(sign).ifPresent(signBlockEntity -> { - UpdateSignC2SPacket packet = new UpdateSignC2SPacket(sign.getPos(), - signBlockEntity.getTextOnRow(0, false).getString(), - signBlockEntity.getTextOnRow(1, false).getString(), - signBlockEntity.getTextOnRow(2, false).getString(), - signBlockEntity.getTextOnRow(3, false).getString()); - this.networkHandler.sendPacket(packet); - ci.cancel(); - }); - } - - private Optional getTargetSignEntity(SignBlockEntity sign) { - WorldSchematic worldSchematic = SchematicWorldHandler.getSchematicWorld(); - SchematicBlockState state = new SchematicBlockState(sign.getWorld(), worldSchematic, sign.getPos()); - - BlockEntity targetBlockEntity = worldSchematic.getBlockEntity(state.blockPos); - - if (targetBlockEntity instanceof SignBlockEntity targetSignEntity) { - return Optional.of(targetSignEntity); - } - - return Optional.empty(); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/mixin/AxeItemAccessor.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/mixin/AxeItemAccessor.java deleted file mode 100644 index 42fd6bba9..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/mixin/AxeItemAccessor.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.mixin; - -import net.minecraft.block.Block; -import net.minecraft.item.AxeItem; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.util.Map; - -/** - * This class apparently fixes an issue with Quilt. - */ -@Mixin(AxeItem.class) -public interface AxeItemAccessor { - @Accessor("STRIPPED_BLOCKS") - static Map getStrippedBlocks() { - throw new AssertionError("Untransformed @Accessor"); - } - -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/mixin/ConfigsMixin.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/mixin/ConfigsMixin.java deleted file mode 100644 index a5f22bc8d..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/mixin/ConfigsMixin.java +++ /dev/null @@ -1,35 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.mixin; - -import com.google.common.collect.ImmutableList; -import fi.dy.masa.litematica.config.Configs; -import fi.dy.masa.malilib.config.IConfigBase; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import me.aleksilassila.litematica.printer.v1_19_4.LitematicaMixinMod; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.List; - -@Mixin(value = Configs.class, remap = false) -public class ConfigsMixin { - @Redirect(method = "loadFromFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Configs$Generic;OPTIONS:Lcom/google/common/collect/ImmutableList;")) - private static ImmutableList moreOptions() { - return LitematicaMixinMod.getConfigList(); - } - - @Redirect(method = "saveToFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Configs$Generic;OPTIONS:Lcom/google/common/collect/ImmutableList;")) - private static ImmutableList moreeOptions() { - return LitematicaMixinMod.getConfigList(); - } - - @Redirect(method = "loadFromFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private static List moreHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } - - @Redirect(method = "saveToFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private static List moreeHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/mixin/GuiConfigsMixin.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/mixin/GuiConfigsMixin.java deleted file mode 100644 index bf978fcc2..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/mixin/GuiConfigsMixin.java +++ /dev/null @@ -1,61 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.mixin; - -import com.google.common.collect.ImmutableList; -import fi.dy.masa.litematica.gui.GuiConfigs; -import fi.dy.masa.malilib.config.IConfigBase; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import me.aleksilassila.litematica.printer.v1_19_4.LitematicaMixinMod; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.List; - -@Mixin(value = GuiConfigs.class, remap = false) -public class GuiConfigsMixin { - - /*@Overwrite - public List getConfigs() - { - List configs; - ConfigGuiTab tab = DataManager.getConfigGuiTab(); - - if (tab == ConfigGuiTab.GENERIC) - { - configs = LitematicaMixinMod.betterConfigList; - } - else if (tab == ConfigGuiTab.INFO_OVERLAYS) - { - configs = Configs.InfoOverlays.OPTIONS; - } - else if (tab == ConfigGuiTab.VISUALS) - { - configs = Configs.Visuals.OPTIONS; - } - else if (tab == ConfigGuiTab.COLORS) - { - configs = Configs.Colors.OPTIONS; - } - else if (tab == ConfigGuiTab.HOTKEYS) - { - configs = LitematicaMixinMod.betterHotkeyList; - } - else - { - return Collections.emptyList(); - } - - return ConfigOptionWrapper.createFor(configs); - }*/ - - - @Redirect(method = "getConfigs", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Configs$Generic;OPTIONS:Lcom/google/common/collect/ImmutableList;")) - private ImmutableList moreOptions() { - return LitematicaMixinMod.getConfigList(); - } - - @Redirect(method = "getConfigs", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private List moreHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/mixin/InputHandlerMixin.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/mixin/InputHandlerMixin.java deleted file mode 100644 index fe68dcf3f..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/mixin/InputHandlerMixin.java +++ /dev/null @@ -1,25 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.mixin; - -import fi.dy.masa.litematica.event.InputHandler; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import me.aleksilassila.litematica.printer.v1_19_4.LitematicaMixinMod; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.List; - -@Mixin(value = InputHandler.class, remap = false) -public class InputHandlerMixin { - - @Redirect(method = "addHotkeys", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private List moreHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } - - @Redirect(method = "addKeysToMap", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private List moreeHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } - -} diff --git a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/mixin/PlayerMoveC2SPacketMixin.java b/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/mixin/PlayerMoveC2SPacketMixin.java deleted file mode 100644 index 18a0e82e2..000000000 --- a/v1_19_4/src/main/java/me/aleksilassila/litematica/printer/v1_19_4/mixin/PlayerMoveC2SPacketMixin.java +++ /dev/null @@ -1,36 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_19_4.mixin; - -import me.aleksilassila.litematica.printer.v1_19_4.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_19_4.Printer; -import me.aleksilassila.litematica.printer.v1_19_4.actions.PrepareAction; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; - -@Mixin(PlayerMoveC2SPacket.class) -public class PlayerMoveC2SPacketMixin { - @ModifyVariable(method = "(DDDFFZZZ)V", at = @At("HEAD"), ordinal = 0) - private static float modifyLookYaw(float yaw) { - Printer printer = LitematicaMixinMod.printer; - if (printer == null) return yaw; - - PrepareAction action = printer.actionHandler.lookAction; - if (action != null && action.modifyYaw) { - if (LitematicaMixinMod.DEBUG) System.out.println("YAW: " + action.yaw); - return action.yaw; - } else return yaw; - } - - @ModifyVariable(method = "(DDDFFZZZ)V", at = @At("HEAD"), ordinal = 1) - private static float modifyLookPitch(float pitch) { - Printer printer = LitematicaMixinMod.printer; - if (printer == null) return pitch; - - PrepareAction action = printer.actionHandler.lookAction; - if (action != null && action.modifyPitch) { - if (LitematicaMixinMod.DEBUG) System.out.println("PITCH: " + action.pitch); - return action.pitch; - } else return pitch; - } -} diff --git a/v1_19_4/src/main/resources/assets/modid/icon.png b/v1_19_4/src/main/resources/assets/modid/icon.png deleted file mode 100644 index 047b91f2347de5cf95f23284476fddbe21ba23fe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 453 zcmV;$0XqJPP)QAFYGys`80vegN0XDFh0OXKz&i8?Le#x7{1X)R+00000NkvXXu0mjf73i~T diff --git a/v1_19_4/src/main/resources/fabric.mod.json b/v1_19_4/src/main/resources/fabric.mod.json deleted file mode 100644 index 9ca4f7c2a..000000000 --- a/v1_19_4/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "schemaVersion": 1, - "id": "litematica_printer", - "version": "${version}", - "name": "Litematica Printer", - "description": "A fork of Litematica that adds the missing printer functionality", - "authors": [ - "aleksilassila" - ], - "contact": { - "homepage": "https://github.com/aleksilassila/litematica-printer", - "sources": "https://github.com/aleksilassila/litematica-printer" - }, - "license": "CC0-1.0", - "icon": "assets/modid/icon.png", - "environment": "*", - "entrypoints": { - "main": [ - "me.aleksilassila.litematica.printer.v1_19_4.LitematicaMixinMod" - ] - }, - "mixins": [ - "litematica-printer.mixins.json", - "litematica-printer-implementation.mixins.json" - ], - "depends": { - "fabricloader": ">=0.14.7", - "fabric": "*", - "minecraft": "1.19.x", - "java": ">=17" - }, - "custom": { - "modmenu": { - "parent": "carpet" - } - } -} - diff --git a/v1_19_4/src/main/resources/litematica-printer-implementation.mixins.json b/v1_19_4/src/main/resources/litematica-printer-implementation.mixins.json deleted file mode 100644 index cadfd99d7..000000000 --- a/v1_19_4/src/main/resources/litematica-printer-implementation.mixins.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "me.aleksilassila.litematica.printer.v1_19_4.implementation.mixin", - "compatibilityLevel": "JAVA_16", - "mixins": [ - ], - "client": [ - "MixinClientPlayerEntity" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/v1_19_4/src/main/resources/litematica-printer.mixins.json b/v1_19_4/src/main/resources/litematica-printer.mixins.json deleted file mode 100644 index e9644b914..000000000 --- a/v1_19_4/src/main/resources/litematica-printer.mixins.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "me.aleksilassila.litematica.printer.v1_19_4.mixin", - "compatibilityLevel": "JAVA_16", - "mixins": [ - ], - "client": [ - "ConfigsMixin", - "GuiConfigsMixin", - "InputHandlerMixin", - "PlayerMoveC2SPacketMixin", - "AxeItemAccessor" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/v1_20/build.gradle.kts b/v1_20/build.gradle.kts deleted file mode 100644 index c3b72eeb4..000000000 --- a/v1_20/build.gradle.kts +++ /dev/null @@ -1,88 +0,0 @@ -plugins { - id("fabric-loom").version("1.0-SNAPSHOT") - id("maven-publish") -} - -java.sourceCompatibility = JavaVersion.VERSION_17 -java.targetCompatibility = JavaVersion.VERSION_17 - -val archives_base_name: String by project -val minecraft_version: String by project -val yarn_mappings: String by project -val loader_version: String by project -val fabric_version: String by project -val malilib_version: String by project -val litematica_projectid: String by project -val litematica_fileid: String by project - -val mod_version: String by project - -dependencies { -// implementation(project(":common")) - minecraft("com.mojang:minecraft:${minecraft_version}") - mappings("net.fabricmc:yarn:${yarn_mappings}:v2") - - modImplementation("net.fabricmc:fabric-loader:${loader_version}") - modImplementation("net.fabricmc.fabric-api:fabric-api:${fabric_version}") - modImplementation("fi.dy.masa.malilib:malilib-fabric-${malilib_version}") - modImplementation("curse.maven:litematica-${litematica_projectid}:${litematica_fileid}") -} - -repositories { - maven("https://masa.dy.fi/maven") - maven("https://www.cursemaven.com") -} - -// Process resources -tasks.withType { - inputs.property("version", mod_version) - - filesMatching("fabric.mod.json") { - expand(mapOf("version" to mod_version)) - } -} - -val sourceModule = "v1_19_4" -val targetModules = arrayOf("v1_19", "v1_18", "v1_17") - -fun copyFile(source: File) { - for (targetModule in targetModules) { - val destination = file(source.absolutePath.replace(sourceModule, targetModule)) - println("Copying ${source.absolutePath} to ${destination.absolutePath}") - destination.parentFile.mkdirs() - source.copyTo(destination, true) - destination.writeText(destination.readText().replace(sourceModule, targetModule)) - } -} - -fun deleteOldFiles(sourceBase: File) { - for (targetModule in targetModules) { - val targetBase = file(sourceBase.absolutePath.replace(sourceModule, targetModule)) - - for (file in targetBase.listFiles()) { - if (file.name.equals("implementation")) continue - println("Deleting recursively ${file.absolutePath}") - file.deleteRecursively() - } - } -} - -val syncImplementations = tasks.create("syncImplementations") { - doFirst { - val sourceStart = - this.project.projectDir.absolutePath + "/src/main/java/me/aleksilassila/litematica/printer/" + sourceModule - val sourceDir = file(sourceStart) - - deleteOldFiles(sourceDir) - - for (sourceFile in sourceDir.listFiles()) { - if (sourceFile.name.equals("implementation")) continue - - sourceFile.walk() - .filter { it.isFile } - .forEach { - copyFile(it) - } - } - } -} diff --git a/v1_20/gradle.properties b/v1_20/gradle.properties deleted file mode 100644 index eb468a4ae..000000000 --- a/v1_20/gradle.properties +++ /dev/null @@ -1,13 +0,0 @@ -# Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx1G -# https://masa.dy.fi/maven/fi/dy/masa/malilib/ -malilib_version=1.20.1:0.16.0 -# https://www.curseforge.com/minecraft/mc-mods/litematica/files -litematica_fileid=4593296 -litematica_projectid=308892 -# Fabric Properties: https://fabricmc.net/develop/ -minecraft_version=1.20.1 -yarn_mappings=1.20.1+build.5 -loader_version=0.14.21 -#Fabric api -fabric_version=0.84.0+1.20.1 diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/ActionHandler.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/ActionHandler.java deleted file mode 100644 index c205ae488..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/ActionHandler.java +++ /dev/null @@ -1,57 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20; - -import me.aleksilassila.litematica.printer.v1_20.actions.Action; -import me.aleksilassila.litematica.printer.v1_20.actions.PrepareAction; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; - -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; - -public class ActionHandler { - private final MinecraftClient client; - private final ClientPlayerEntity player; - - private final Queue actionQueue = new LinkedList<>(); - public PrepareAction lookAction = null; - - public ActionHandler(MinecraftClient client, ClientPlayerEntity player) { - this.client = client; - this.player = player; - } - - private int tick = 0; - - public void onGameTick() { - int tickRate = LitematicaMixinMod.PRINTING_INTERVAL.getIntegerValue(); - - tick = tick % tickRate == tickRate - 1 ? 0 : tick + 1; - if (tick % tickRate != 0) { - return; - } - - Action nextAction = actionQueue.poll(); - if (nextAction != null) { - if (LitematicaMixinMod.DEBUG) System.out.println("Sending action " + nextAction); - nextAction.send(client, player); - } else { - lookAction = null; - } - } - - public boolean acceptsActions() { - return actionQueue.isEmpty(); - } - - public void addActions(Action... actions) { - if (!acceptsActions()) return; - - for (Action action : actions) { - if (action instanceof PrepareAction) - lookAction = (PrepareAction) action; - } - - actionQueue.addAll(List.of(actions)); - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/BlockHelper.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/BlockHelper.java deleted file mode 100644 index 488b39ca6..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/BlockHelper.java +++ /dev/null @@ -1,31 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20; - -import net.minecraft.block.*; -import net.minecraft.item.Item; -import net.minecraft.item.Items; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -abstract public class BlockHelper { - public static List> interactiveBlocks = new ArrayList<>(Arrays.asList( - AbstractChestBlock.class, AbstractFurnaceBlock.class, CraftingTableBlock.class, LeverBlock.class, - DoorBlock.class, TrapdoorBlock.class, BedBlock.class, RedstoneWireBlock.class, ScaffoldingBlock.class, - HopperBlock.class, EnchantingTableBlock.class, NoteBlock.class, JukeboxBlock.class, CakeBlock.class, - FenceGateBlock.class, BrewingStandBlock.class, DragonEggBlock.class, CommandBlock.class, - BeaconBlock.class, AnvilBlock.class, ComparatorBlock.class, RepeaterBlock.class, - DropperBlock.class, DispenserBlock.class, ShulkerBoxBlock.class, LecternBlock.class, - FlowerPotBlock.class, BarrelBlock.class, BellBlock.class, SmithingTableBlock.class, - LoomBlock.class, CartographyTableBlock.class, GrindstoneBlock.class, - StonecutterBlock.class, AbstractSignBlock.class, AbstractCandleBlock.class)); - - public static final Item[] SHOVEL_ITEMS = new Item[]{ - Items.NETHERITE_SHOVEL, - Items.DIAMOND_SHOVEL, - Items.GOLDEN_SHOVEL, - Items.IRON_SHOVEL, - Items.STONE_SHOVEL, - Items.WOODEN_SHOVEL - }; -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/LitematicaMixinMod.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/LitematicaMixinMod.java deleted file mode 100644 index f48b46125..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/LitematicaMixinMod.java +++ /dev/null @@ -1,58 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20; - -import com.google.common.collect.ImmutableList; -import fi.dy.masa.litematica.config.Configs; -import fi.dy.masa.litematica.config.Hotkeys; -import fi.dy.masa.malilib.config.IConfigBase; -import fi.dy.masa.malilib.config.options.ConfigBoolean; -import fi.dy.masa.malilib.config.options.ConfigDouble; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import fi.dy.masa.malilib.config.options.ConfigInteger; -import fi.dy.masa.malilib.hotkeys.KeyCallbackToggleBooleanConfigWithMessage; -import fi.dy.masa.malilib.hotkeys.KeybindSettings; -import net.fabricmc.api.ModInitializer; - -import java.util.List; - -public class LitematicaMixinMod implements ModInitializer { - - public static Printer printer; - public static boolean DEBUG = false; - // Config settings - public static final ConfigInteger PRINTING_INTERVAL = new ConfigInteger("printingInterval", 12, 1, 40, "Printing interval. Lower values mean faster printing speed.\nIf the printer creates \"ghost blocks\" or blocks are facing the wrong way, raise this value."); - public static final ConfigDouble PRINTING_RANGE = new ConfigDouble("printingRange", 5, 2.5, 5, "Printing block place range\nLower values are recommended for servers."); - // public static final ConfigBoolean PRINT_WATER = new ConfigBoolean("printWater", false, "Whether the printer should place water\n source blocks or make blocks waterlogged."); -// public static final ConfigBoolean PRINT_IN_AIR = new ConfigBoolean("printInAir", true, "Whether or not the printer should place blocks without anything to build on.\nBe aware that some anti-cheat plugins might notice this."); - public static final ConfigBoolean PRINT_MODE = new ConfigBoolean("printingMode", false, "Autobuild / print loaded selection.\nBe aware that some servers and anticheat plugins do not allow printing."); - public static final ConfigBoolean REPLACE_FLUIDS_SOURCE_BLOCKS = new ConfigBoolean("replaceFluidSourceBlocks", true, "Whether or not fluid source blocks should be replaced by the printer."); - public static final ConfigBoolean STRIP_LOGS = new ConfigBoolean("stripLogs", true, "Whether or not the printer should use normal logs if stripped\nversions are not available and then strip them with an axe."); - - public static ImmutableList getConfigList() { - List list = new java.util.ArrayList<>(Configs.Generic.OPTIONS); - list.add(PRINT_MODE); - list.add(PRINTING_INTERVAL); - list.add(PRINTING_RANGE); -// list.add(PRINT_IN_AIR); - list.add(REPLACE_FLUIDS_SOURCE_BLOCKS); - list.add(STRIP_LOGS); - - return ImmutableList.copyOf(list); - } - - // Hotkeys - public static final ConfigHotkey PRINT = new ConfigHotkey("print", "V", KeybindSettings.PRESS_ALLOWEXTRA_EMPTY, "Prints while pressed"); - public static final ConfigHotkey TOGGLE_PRINTING_MODE = new ConfigHotkey("togglePrintingMode", "CAPS_LOCK", KeybindSettings.PRESS_ALLOWEXTRA_EMPTY, "Allows quickly toggling on/off Printing mode"); - - public static List getHotkeyList() { - List list = new java.util.ArrayList<>(Hotkeys.HOTKEY_LIST); - list.add(PRINT); - list.add(TOGGLE_PRINTING_MODE); - - return ImmutableList.copyOf(list); - } - - @Override - public void onInitialize() { - TOGGLE_PRINTING_MODE.getKeybind().setCallback(new KeyCallbackToggleBooleanConfigWithMessage(PRINT_MODE)); - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/SchematicBlockState.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/SchematicBlockState.java deleted file mode 100644 index fc970fd08..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/SchematicBlockState.java +++ /dev/null @@ -1,42 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20; - -import fi.dy.masa.litematica.world.WorldSchematic; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.World; - -public class SchematicBlockState { - public final World world; - public final WorldSchematic schematic; - - public final BlockPos blockPos; - - public final BlockState targetState; - public final BlockState currentState; - - public SchematicBlockState(World world, WorldSchematic schematic, BlockPos blockPos) { - this.world = world; - this.schematic = schematic; - - this.blockPos = blockPos; - - this.targetState = schematic.getBlockState(blockPos); - this.currentState = world.getBlockState(blockPos); - } - - public SchematicBlockState offset(Direction direction) { - return new SchematicBlockState(world, schematic, blockPos.offset(direction)); - } - - @Override - public String toString() { - return "SchematicBlockState{" + - "world=" + world + - ", schematic=" + schematic + - ", blockPos=" + blockPos + - ", targetState=" + targetState + - ", currentState=" + currentState + - '}'; - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/UpdateChecker.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/UpdateChecker.java deleted file mode 100644 index 9ea41e510..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/UpdateChecker.java +++ /dev/null @@ -1,49 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import org.apache.commons.io.IOUtils; - -import java.io.BufferedReader; -import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.util.Scanner; - -public class UpdateChecker { - public static final String version = "v3.2.1"; - - // Try to get this to work at some point -// static { -// try (InputStream in = UpdateChecker.class.getResourceAsStream("/fabric.mod.json")) { -// String jsonString = IOUtils.toString(in, StandardCharsets.UTF_8); -// JsonObject json = JsonParser.parseString(jsonString).getAsJsonObject(); -// System.out.println("JSON object: " + json); -// System.out.println("Raw json: " + jsonString); -// System.out.println("File: " + new File(UpdateChecker.class.getResource("/fabric.mod.json").getFile())); -// String version = json.get("version").getAsString(); -// System.out.println("Reading fabric.mod.json"); -// System.out.println("Parsed version: " + version); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } - - @SuppressWarnings("deprecation") - public static String getPrinterVersion() { - try (InputStream inputStream = new URL("https://api.github.com/repos/aleksilassila/litematica-printer/tags").openStream(); Scanner scanner = new Scanner(inputStream)) { - if (scanner.hasNext()) { - JsonArray tags = new JsonParser().parse(scanner.next()).getAsJsonArray(); - return ((JsonObject) tags.get(0)).get("name").getAsString(); - } - } catch (Exception exception) { - System.out.println("Cannot look for updates: " + exception.getMessage()); - } - - return ""; - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/actions/Action.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/actions/Action.java deleted file mode 100644 index 956d2df2a..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/actions/Action.java +++ /dev/null @@ -1,8 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.actions; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; - -public abstract class Action { - abstract public void send(MinecraftClient client, ClientPlayerEntity player); -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/actions/InteractAction.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/actions/InteractAction.java deleted file mode 100644 index d74f814b5..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/actions/InteractAction.java +++ /dev/null @@ -1,33 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.actions; - -import me.aleksilassila.litematica.printer.v1_20.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_20.implementation.PrinterPlacementContext; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; - -abstract public class InteractAction extends Action { - public final PrinterPlacementContext context; - - public InteractAction(PrinterPlacementContext context) { - this.context = context; - } - - protected abstract void interact(MinecraftClient client, ClientPlayerEntity player, Hand hand, BlockHitResult hitResult); - - @Override - public void send(MinecraftClient client, ClientPlayerEntity player) { - interact(client, player, Hand.MAIN_HAND, context.hitResult); - - if (LitematicaMixinMod.DEBUG) - System.out.println("InteractAction.send: Blockpos: " + context.getBlockPos() + " Side: " + context.getSide() + " HitPos: " + context.getHitPos()); - } - - @Override - public String toString() { - return "InteractAction{" + - "context=" + context + - '}'; - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/actions/PrepareAction.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/actions/PrepareAction.java deleted file mode 100644 index e809baefa..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/actions/PrepareAction.java +++ /dev/null @@ -1,109 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.actions; - -import me.aleksilassila.litematica.printer.v1_20.implementation.PrinterPlacementContext; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; -import net.minecraft.util.Hand; -import net.minecraft.util.math.Direction; - -public class PrepareAction extends Action { -// public final Direction lookDirection; -// public final boolean requireSneaking; -// public final Item item; - -// public PrepareAction(Direction lookDirection, boolean requireSneaking, Item item) { -// this.lookDirection = lookDirection; -// this.requireSneaking = requireSneaking; -// this.item = item; -// } -// -// public PrepareAction(Direction lookDirection, boolean requireSneaking, BlockState requiredState) { -// this(lookDirection, requireSneaking, requiredState.getBlock().asItem()); -// } - - public final PrinterPlacementContext context; - - public boolean modifyYaw = true; - public boolean modifyPitch = true; - public float yaw = 0; - public float pitch = 0; - - public PrepareAction(PrinterPlacementContext context) { - this.context = context; - - Direction lookDirection = context.lookDirection; - - if (lookDirection != null && lookDirection.getAxis().isHorizontal()) { - this.yaw = lookDirection.asRotation(); - } else { - this.modifyYaw = false; - } - - if (lookDirection == Direction.UP) { - this.pitch = -90; - } else if (lookDirection == Direction.DOWN) { - this.pitch = 90; - } else if (lookDirection != null) { - this.pitch = 0; - } else { - this.modifyPitch = false; - } - } - - public PrepareAction(PrinterPlacementContext context, float yaw, float pitch) { - this.context = context; - - this.yaw = yaw; - this.pitch = pitch; - } - - @Override - public void send(MinecraftClient client, ClientPlayerEntity player) { - ItemStack itemStack = context.getStack(); - int slot = context.requiredItemSlot; - - if (itemStack != null) { - PlayerInventory inventory = player.getInventory(); - - // This thing is straight from MinecraftClient#doItemPick() - if (player.getAbilities().creativeMode) { - inventory.addPickBlock(itemStack); - client.interactionManager.clickCreativeStack(player.getStackInHand(Hand.MAIN_HAND), 36 + inventory.selectedSlot); - } else if (slot != -1) { - if (PlayerInventory.isValidHotbarIndex(slot)) { - inventory.selectedSlot = slot; - } else { - client.interactionManager.pickFromInventory(slot); - } - } - } - - if (modifyPitch || modifyYaw) { - float yaw = modifyYaw ? this.yaw : player.getYaw(); - float pitch = modifyPitch ? this.pitch : player.getPitch(); - - PlayerMoveC2SPacket packet = new PlayerMoveC2SPacket.Full(player.getX(), player.getY(), player.getZ(), yaw, pitch, player.isOnGround()); - - player.networkHandler.sendPacket(packet); - } - - if (context.shouldSneak) { - player.input.sneaking = true; - player.networkHandler.sendPacket(new ClientCommandC2SPacket(player, ClientCommandC2SPacket.Mode.PRESS_SHIFT_KEY)); - } else { - player.input.sneaking = false; - player.networkHandler.sendPacket(new ClientCommandC2SPacket(player, ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY)); - } - } - - @Override - public String toString() { - return "PrepareAction{" + - "context=" + context + - '}'; - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/actions/ReleaseShiftAction.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/actions/ReleaseShiftAction.java deleted file mode 100644 index 685e52243..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/actions/ReleaseShiftAction.java +++ /dev/null @@ -1,13 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.actions; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; - -public class ReleaseShiftAction extends Action { - @Override - public void send(MinecraftClient client, ClientPlayerEntity player) { - player.input.sneaking = false; - player.networkHandler.sendPacket(new ClientCommandC2SPacket(player, ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY)); - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/Guides.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/Guides.java deleted file mode 100644 index 0d826384f..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/Guides.java +++ /dev/null @@ -1,83 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.guides; - -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_20.guides.interaction.*; -import me.aleksilassila.litematica.printer.v1_20.guides.placement.*; -import me.aleksilassila.litematica.printer.v1_20.guides.interaction.*; -import me.aleksilassila.litematica.printer.v1_20.guides.placement.*; -import net.minecraft.block.*; -import net.minecraft.util.Pair; - -import java.util.ArrayList; - -public class Guides { - protected final static ArrayList, Class[]>> guides = new ArrayList<>(); - - @SafeVarargs - protected static void registerGuide(Class guideClass, Class... blocks) { - guides.add(new Pair<>(guideClass, blocks)); - } - - static { -// registerGuide(SkipGuide.class, AbstractSignBlock.class, SkullBlock.class, BannerBlock.class); - - registerGuide(RotatingBlockGuide.class, AbstractSkullBlock.class, AbstractSignBlock.class, AbstractBannerBlock.class); - registerGuide(SlabGuide.class, SlabBlock.class); - registerGuide(TorchGuide.class, TorchBlock.class); - registerGuide(FarmlandGuide.class, FarmlandBlock.class); - registerGuide(TillingGuide.class, FarmlandBlock.class); - registerGuide(RailGuesserGuide.class, AbstractRailBlock.class); - registerGuide(ChestGuide.class, ChestBlock.class); - registerGuide(FlowerPotGuide.class, FlowerPotBlock.class); - registerGuide(FlowerPotFillGuide.class, FlowerPotBlock.class); - - registerGuide(PropertySpecificGuesserGuide.class, - RepeaterBlock.class, ComparatorBlock.class, RedstoneWireBlock.class, RedstoneTorchBlock.class, - BambooBlock.class, CactusBlock.class, SaplingBlock.class, ScaffoldingBlock.class, PointedDripstoneBlock.class, - HorizontalConnectingBlock.class, DoorBlock.class, TrapdoorBlock.class, FenceGateBlock.class, ChestBlock.class, - SnowBlock.class, SeaPickleBlock.class, CandleBlock.class, LeverBlock.class, EndPortalFrameBlock.class, - NoteBlock.class, CampfireBlock.class, PoweredRailBlock.class, LeavesBlock.class, TripwireHookBlock.class); - registerGuide(FallingBlockGuide.class, FallingBlock.class); - registerGuide(BlockIndifferentGuesserGuide.class, BambooBlock.class, BigDripleafStemBlock.class, BigDripleafBlock.class, - TwistingVinesPlantBlock.class, TripwireBlock.class); - - registerGuide(CampfireExtinguishGuide.class, CampfireBlock.class); - registerGuide(LightCandleGuide.class, AbstractCandleBlock.class); - registerGuide(EnderEyeGuide.class, EndPortalFrameBlock.class); - registerGuide(CycleStateGuide.class, - DoorBlock.class, FenceGateBlock.class, TrapdoorBlock.class, - LeverBlock.class, - RepeaterBlock.class, ComparatorBlock.class, NoteBlock.class); - registerGuide(BlockReplacementGuide.class, SnowBlock.class, SeaPickleBlock.class, CandleBlock.class, SlabBlock.class); - registerGuide(LogGuide.class); - registerGuide(LogStrippingGuide.class); - registerGuide(GuesserGuide.class); - } - - public ArrayList, Class[]>> getGuides() { - return guides; - } - - public Guide[] getInteractionGuides(SchematicBlockState state) { - ArrayList, Class[]>> guides = getGuides(); - - ArrayList applicableGuides = new ArrayList<>(); - for (Pair, Class[]> guidePair : guides) { - try { - if (guidePair.getRight().length == 0) { - applicableGuides.add(guidePair.getLeft().getConstructor(SchematicBlockState.class).newInstance(state)); - continue; - } - - for (Class clazz : guidePair.getRight()) { - if (clazz.isInstance(state.targetState.getBlock())) { - applicableGuides.add(guidePair.getLeft().getConstructor(SchematicBlockState.class).newInstance(state)); - } - } - } catch (Exception ignored) { - } - } - - return applicableGuides.toArray(Guide[]::new); - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/SkipGuide.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/SkipGuide.java deleted file mode 100644 index e7133cebc..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/SkipGuide.java +++ /dev/null @@ -1,37 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.guides; - -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_20.actions.Action; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class SkipGuide extends Guide { - public SkipGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - return false; - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - return new ArrayList<>(); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(ItemStack.EMPTY); - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/CycleStateGuide.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/CycleStateGuide.java deleted file mode 100644 index 9563dc66a..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/CycleStateGuide.java +++ /dev/null @@ -1,45 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.LeverBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.state.property.Properties; -import net.minecraft.state.property.Property; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class CycleStateGuide extends InteractionGuide { - private static final Property[] propertiesToIgnore = new Property[]{ - Properties.POWERED, - Properties.LIT - }; - - public CycleStateGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return targetState.getBlock() == currentState.getBlock(); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(ItemStack.EMPTY); - } - - @Override - protected boolean statesEqual(BlockState state1, BlockState state2) { - if (state2.getBlock() instanceof LeverBlock) { - return super.statesEqual(state1, state2); - } - - return statesEqualIgnoreProperties(state1, state2, propertiesToIgnore); - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/EnderEyeGuide.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/EnderEyeGuide.java deleted file mode 100644 index 720b112f5..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/EnderEyeGuide.java +++ /dev/null @@ -1,33 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.state.property.Properties; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class EnderEyeGuide extends InteractionGuide { - public EnderEyeGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - if (currentState.contains(Properties.EYE) && targetState.contains(Properties.EYE)) { - return !currentState.get(Properties.EYE) && targetState.get(Properties.EYE); - } - - return false; - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(new ItemStack(Items.ENDER_EYE)); - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/FlowerPotFillGuide.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/FlowerPotFillGuide.java deleted file mode 100644 index 43e29d26c..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/FlowerPotFillGuide.java +++ /dev/null @@ -1,40 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import net.minecraft.block.Block; -import net.minecraft.block.FlowerPotBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class FlowerPotFillGuide extends InteractionGuide { - private final Block content; - - public FlowerPotFillGuide(SchematicBlockState state) { - super(state); - - Block targetBlock = state.targetState.getBlock(); - if (targetBlock instanceof FlowerPotBlock) { - this.content = ((FlowerPotBlock) targetBlock).getContent(); - } else { - this.content = null; - } - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (content == null) return false; - if (!(currentState.getBlock() instanceof FlowerPotBlock)) return false; - - return super.canExecute(player); - } - - @Override - protected @NotNull List getRequiredItems() { - if (content == null) return Collections.emptyList(); - else return Collections.singletonList(new ItemStack(content)); - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/InteractionGuide.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/InteractionGuide.java deleted file mode 100644 index d41a120c7..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/InteractionGuide.java +++ /dev/null @@ -1,49 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_20.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_20.actions.Action; -import me.aleksilassila.litematica.printer.v1_20.actions.PrepareAction; -import me.aleksilassila.litematica.printer.v1_20.actions.ReleaseShiftAction; -import me.aleksilassila.litematica.printer.v1_20.guides.Guide; -import me.aleksilassila.litematica.printer.v1_20.implementation.actions.InteractActionImpl; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.List; - -/** - * A guide that clicks the current block to change its state. - */ -public abstract class InteractionGuide extends Guide { - public InteractionGuide(SchematicBlockState state) { - super(state); - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - List actions = new ArrayList<>(); - - BlockHitResult hitResult = new BlockHitResult(Vec3d.ofCenter(state.blockPos), Direction.UP, state.blockPos, false); - ItemStack requiredItem = getRequiredItem(player).orElse(ItemStack.EMPTY); - int requiredSlot = getRequiredItemStackSlot(player); - - if (requiredSlot == -1) return actions; - - PrinterPlacementContext ctx = new PrinterPlacementContext(player, hitResult, requiredItem, requiredSlot); - - actions.add(new ReleaseShiftAction()); - actions.add(new PrepareAction(ctx)); - actions.add(new InteractActionImpl(ctx)); - - return actions; - } - - @Override - abstract protected @NotNull List getRequiredItems(); -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/LightCandleGuide.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/LightCandleGuide.java deleted file mode 100644 index b0f352e0b..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/LightCandleGuide.java +++ /dev/null @@ -1,36 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import net.minecraft.block.AbstractCandleBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.state.property.Properties; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class LightCandleGuide extends InteractionGuide { - boolean shouldBeLit; - boolean isLit; - - public LightCandleGuide(SchematicBlockState state) { - super(state); - - shouldBeLit = getProperty(targetState, Properties.LIT).orElse(false); - isLit = getProperty(currentState, Properties.LIT).orElse(false); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(new ItemStack(Items.FLINT_AND_STEEL)); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return (currentState.getBlock() instanceof AbstractCandleBlock) && shouldBeLit && !isLit; - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/LogStrippingGuide.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/LogStrippingGuide.java deleted file mode 100644 index 2e6e474ae..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/LogStrippingGuide.java +++ /dev/null @@ -1,47 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_20.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_20.mixin.AxeItemAccessor; -import net.minecraft.block.Block; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -public class LogStrippingGuide extends InteractionGuide { - static final Item[] AXE_ITEMS = new Item[]{ - Items.NETHERITE_AXE, - Items.DIAMOND_AXE, - Items.GOLDEN_AXE, - Items.IRON_AXE, - Items.STONE_AXE, - Items.WOODEN_AXE - }; - - public static final Map STRIPPED_BLOCKS = AxeItemAccessor.getStrippedBlocks(); - - public LogStrippingGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!LitematicaMixinMod.STRIP_LOGS.getBooleanValue()) return false; - - if (!super.canExecute(player)) return false; - - Block strippingResult = STRIPPED_BLOCKS.get(currentState.getBlock()); - return strippingResult == targetState.getBlock(); - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(AXE_ITEMS).map(ItemStack::new).toList(); - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/TillingGuide.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/TillingGuide.java deleted file mode 100644 index e24a4efa1..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/interaction/TillingGuide.java +++ /dev/null @@ -1,39 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_20.guides.placement.FarmlandGuide; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; - -public class TillingGuide extends InteractionGuide { - public static final Item[] HOE_ITEMS = new Item[]{ - Items.NETHERITE_HOE, - Items.DIAMOND_HOE, - Items.GOLDEN_HOE, - Items.IRON_HOE, - Items.STONE_HOE, - Items.WOODEN_HOE - }; - - public TillingGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return Arrays.stream(FarmlandGuide.TILLABLE_BLOCKS).anyMatch(b -> b == currentState.getBlock()); - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(HOE_ITEMS).map(ItemStack::new).toList(); - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/BlockIndifferentGuesserGuide.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/BlockIndifferentGuesserGuide.java deleted file mode 100644 index 8dd53b2b0..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/BlockIndifferentGuesserGuide.java +++ /dev/null @@ -1,42 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import net.minecraft.block.*; - -public class BlockIndifferentGuesserGuide extends GuesserGuide { - public BlockIndifferentGuesserGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected boolean statesEqual(BlockState resultState, BlockState targetState) { - Block targetBlock = targetState.getBlock(); - Block resultBlock = resultState.getBlock(); - - if (targetBlock instanceof BambooBlock) { - return resultBlock instanceof BambooBlock || resultBlock instanceof BambooSaplingBlock; - } - - if (targetBlock instanceof BigDripleafStemBlock) { - if (resultBlock instanceof BigDripleafBlock || resultBlock instanceof BigDripleafStemBlock) { - return resultState.get(HorizontalFacingBlock.FACING) == targetState.get(HorizontalFacingBlock.FACING); - } - } - - if (targetBlock instanceof TwistingVinesPlantBlock) { - if (resultBlock instanceof TwistingVinesBlock) { - return true; - } else if (resultBlock instanceof TwistingVinesPlantBlock) { - return statesEqualIgnoreProperties(resultState, targetState, TwistingVinesBlock.AGE); - } - } - - if (targetBlock instanceof TripwireBlock && resultBlock instanceof TripwireBlock) { - return statesEqualIgnoreProperties(resultState, targetState, - TripwireBlock.ATTACHED, TripwireBlock.DISARMED, TripwireBlock.POWERED, TripwireBlock.NORTH, - TripwireBlock.EAST, TripwireBlock.SOUTH, TripwireBlock.WEST); - } - - return super.statesEqual(resultState, targetState); - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/ChestGuide.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/ChestGuide.java deleted file mode 100644 index 4d30e828b..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/ChestGuide.java +++ /dev/null @@ -1,92 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.ChestBlock; -import net.minecraft.block.enums.ChestType; -import net.minecraft.util.math.Direction; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -/** - * Whilst making this guide, I learned that chests are much like humans. - * Some prefer to stay single, and some want to connect with another of its kind. - * Also that reversing chest connection logic is an enormous pain in the ass. I spent way too long on this. - * Thanks for coming to my ted talk - */ -public class ChestGuide extends GeneralPlacementGuide { - public ChestGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected boolean getRequiresExplicitShift() { - return true; - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - protected Optional getLookDirection() { - return getProperty(targetState, ChestBlock.FACING) - .flatMap(facing -> Optional.of(facing.getOpposite())); - } - - @Override - protected List getPossibleSides() { - ChestType targetType = getProperty(targetState, ChestBlock.CHEST_TYPE).orElse(null); - Direction targetFacing = getProperty(targetState, ChestBlock.FACING).orElse(null); - - List sides = new ArrayList<>(); - - if (targetFacing == null || targetType == null) return sides; - - for (Direction direction : Direction.values()) { - if (targetType == ChestType.SINGLE && !willConnectToSide(state, direction)) { - sides.add(direction); - } else if (wantsToConnectToSide(state, direction) && willConnectToSide(state, direction)) { // :D - sides.add(direction); - } - } - - // Place single chests if cannot connect any existing chests - if (sides.isEmpty()) { - for (Direction direction : Direction.values()) { - if (!wantsToConnectToSide(state, direction) && !willConnectToSide(state, direction)) { - sides.add(direction); - } - } - } - - return sides; - } - - private boolean willConnectToSide(SchematicBlockState state, Direction neighborDirection) { - BlockState neighbor = state.offset(neighborDirection).currentState; - ChestType neighborType = getProperty(neighbor, ChestBlock.CHEST_TYPE).orElse(null); - Direction neighborFacing = getProperty(neighbor, ChestBlock.FACING).orElse(null); - Direction facing = getProperty(state.targetState, ChestBlock.FACING).orElse(null); - - if (neighborType == null || neighborFacing == null || facing == null) return false; - - if (facing.getAxis() == neighborDirection.getAxis() || neighborDirection.getAxis() == Direction.Axis.Y) - return false; - - return neighborType == ChestType.SINGLE && neighborFacing == facing && state.targetState.getBlock() == neighbor.getBlock(); - } - - private boolean wantsToConnectToSide(SchematicBlockState state, Direction direction) { - ChestType type = getProperty(state.targetState, ChestBlock.CHEST_TYPE).orElse(null); - Direction facing = getProperty(state.targetState, ChestBlock.FACING).orElse(null); - if (type == null || facing == null || type == ChestType.SINGLE) return false; - - Direction neighborDirection = type == ChestType.LEFT ? facing.rotateYClockwise() : facing.rotateYCounterclockwise(); - - return direction == neighborDirection; - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/FallingBlockGuide.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/FallingBlockGuide.java deleted file mode 100644 index b12c38b91..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/FallingBlockGuide.java +++ /dev/null @@ -1,37 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.FallingBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.math.Direction; - -public class FallingBlockGuide extends GuesserGuide { - - public FallingBlockGuide(SchematicBlockState state) { - super(state); - } - - boolean blockPlacement() { - if (targetState.getBlock() instanceof FallingBlock) { - BlockState below = state.world.getBlockState(state.blockPos.offset(Direction.DOWN)); - return FallingBlock.canFallThrough(below); - } - - return false; - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (blockPlacement()) return false; - - return super.canExecute(player); - } - - @Override - public boolean skipOtherGuides() { - if (blockPlacement()) return true; - - return super.skipOtherGuides(); - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/FarmlandGuide.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/FarmlandGuide.java deleted file mode 100644 index b611a4f25..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/FarmlandGuide.java +++ /dev/null @@ -1,29 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; - -public class FarmlandGuide extends GeneralPlacementGuide { - public static final Block[] TILLABLE_BLOCKS = new Block[]{ - Blocks.DIRT, - Blocks.GRASS_BLOCK, - Blocks.COARSE_DIRT, - Blocks.ROOTED_DIRT, - Blocks.DIRT_PATH, - }; - - public FarmlandGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(TILLABLE_BLOCKS).map(b -> getBlockItem(b.getDefaultState())).toList(); - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/FlowerPotGuide.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/FlowerPotGuide.java deleted file mode 100644 index f01f7e850..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/FlowerPotGuide.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class FlowerPotGuide extends GeneralPlacementGuide { - public FlowerPotGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(new ItemStack(Items.FLOWER_POT)); - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/LogGuide.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/LogGuide.java deleted file mode 100644 index 0316eb4e1..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/LogGuide.java +++ /dev/null @@ -1,54 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_20.guides.interaction.LogStrippingGuide; -import net.minecraft.block.Block; -import net.minecraft.block.PillarBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.Direction; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -public class LogGuide extends GeneralPlacementGuide { - public LogGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - if (targetState.contains(PillarBlock.AXIS)) { - Direction.Axis axis = targetState.get(PillarBlock.AXIS); - return Arrays.stream(Direction.values()).filter(d -> d.getAxis() == axis).toList(); - } - - return new ArrayList<>(); - } - - @Override - protected @NotNull List getRequiredItems() { - for (Block log : LogStrippingGuide.STRIPPED_BLOCKS.keySet()) { - if (targetState.getBlock() == LogStrippingGuide.STRIPPED_BLOCKS.get(log)) { - return Collections.singletonList(new ItemStack(log)); - } - } - - return super.getRequiredItems(); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!LitematicaMixinMod.STRIP_LOGS.getBooleanValue()) return false; - - if (LogStrippingGuide.STRIPPED_BLOCKS.containsValue(targetState.getBlock())) { - return super.canExecute(player); - } - - return false; - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/PropertySpecificGuesserGuide.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/PropertySpecificGuesserGuide.java deleted file mode 100644 index 144d23329..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/PropertySpecificGuesserGuide.java +++ /dev/null @@ -1,52 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import net.minecraft.block.*; -import net.minecraft.state.property.Properties; -import net.minecraft.state.property.Property; - -public class PropertySpecificGuesserGuide extends GuesserGuide { - protected static Property[] ignoredProperties = new Property[]{ - RepeaterBlock.DELAY, - ComparatorBlock.MODE, - RedstoneWireBlock.POWER, - RedstoneWireBlock.WIRE_CONNECTION_EAST, - RedstoneWireBlock.WIRE_CONNECTION_NORTH, - RedstoneWireBlock.WIRE_CONNECTION_SOUTH, - RedstoneWireBlock.WIRE_CONNECTION_WEST, - Properties.POWERED, - Properties.OPEN, - PointedDripstoneBlock.THICKNESS, - ScaffoldingBlock.DISTANCE, - ScaffoldingBlock.BOTTOM, - CactusBlock.AGE, - BambooBlock.AGE, - BambooBlock.LEAVES, - BambooBlock.STAGE, - SaplingBlock.STAGE, - HorizontalConnectingBlock.EAST, - HorizontalConnectingBlock.NORTH, - HorizontalConnectingBlock.SOUTH, - HorizontalConnectingBlock.WEST, - SnowBlock.LAYERS, - SeaPickleBlock.PICKLES, - CandleBlock.CANDLES, - EndPortalFrameBlock.EYE, - Properties.LIT, - LeavesBlock.DISTANCE, - LeavesBlock.PERSISTENT, - Properties.ATTACHED, - Properties.NOTE, - Properties.INSTRUMENT, - - }; - - public PropertySpecificGuesserGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected boolean statesEqual(BlockState resultState, BlockState targetState) { - return statesEqualIgnoreProperties(resultState, targetState, ignoredProperties); - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/RotatingBlockGuide.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/RotatingBlockGuide.java deleted file mode 100644 index c8ced5bdd..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/RotatingBlockGuide.java +++ /dev/null @@ -1,58 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_20.actions.Action; -import me.aleksilassila.litematica.printer.v1_20.actions.PrepareAction; -import net.minecraft.block.*; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.state.property.Properties; -import net.minecraft.util.math.Direction; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -public class RotatingBlockGuide extends GeneralPlacementGuide { - public RotatingBlockGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - Block block = state.targetState.getBlock(); - if (block instanceof WallSkullBlock || block instanceof WallSignBlock || block instanceof WallBannerBlock) { - Optional side = getProperty(state.targetState, Properties.HORIZONTAL_FACING).map(Direction::getOpposite); - return side.map(Collections::singletonList).orElseGet(Collections::emptyList); - } - - return Collections.singletonList(Direction.DOWN); - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - PrinterPlacementContext ctx = getPlacementContext(player); - - if (ctx == null) return new ArrayList<>(); - - int rotation = getProperty(state.targetState, Properties.ROTATION).orElse(0); - if (targetState.getBlock() instanceof BannerBlock || targetState.getBlock() instanceof SignBlock) { - rotation = (rotation + 8) % 16; - } - - int distTo0 = rotation > 8 ? 16 - rotation : rotation; - float yaw = Math.round(distTo0 / 8f * 180f * (rotation > 8 ? -1 : 1)); - - List actions = super.execute(player); - actions.set(0, new PrepareAction(ctx, yaw, 0)); - - return actions; - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/SlabGuide.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/SlabGuide.java deleted file mode 100644 index 449a5c8af..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/SlabGuide.java +++ /dev/null @@ -1,48 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.enums.SlabType; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; - -import java.util.Arrays; -import java.util.List; - -public class SlabGuide extends GeneralPlacementGuide { - public SlabGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - return Arrays.stream(Direction.values()) - .filter(d -> d != (getRequiredHalf(state).getOpposite()) && - getProperty(state.offset(d).currentState, SlabBlock.TYPE).orElse(SlabType.DOUBLE) == SlabType.DOUBLE) - .toList(); - } - - @Override - protected Vec3d getHitModifier(Direction validSide) { - Direction requiredHalf = getRequiredHalf(state); - if (validSide.getHorizontal() != -1) { - return new Vec3d(0, requiredHalf.getOffsetY() * 0.25, 0); - } else { - return new Vec3d(0, 0, 0); - } - } - - private Direction getRequiredHalf(SchematicBlockState state) { - BlockState targetState = state.targetState; - BlockState currentState = state.currentState; - - if (!currentState.contains(SlabBlock.TYPE)) { - return targetState.get(SlabBlock.TYPE) == SlabType.TOP ? Direction.UP : Direction.DOWN; - } else if (currentState.get(SlabBlock.TYPE) != targetState.get(SlabBlock.TYPE)) { - return currentState.get(SlabBlock.TYPE) == SlabType.TOP ? Direction.DOWN : Direction.UP; - } else { - return Direction.DOWN; - } - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/TorchGuide.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/TorchGuide.java deleted file mode 100644 index 099b30de5..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/guides/placement/TorchGuide.java +++ /dev/null @@ -1,31 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20.SchematicBlockState; -import net.minecraft.block.Block; -import net.minecraft.block.HorizontalFacingBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.math.Direction; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -public class TorchGuide extends GeneralPlacementGuide { - public TorchGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - Optional facing = getProperty(targetState, HorizontalFacingBlock.FACING); - - return facing - .map(direction -> Collections.singletonList(direction.getOpposite())) - .orElseGet(() -> Collections.singletonList(Direction.DOWN)); - } - - @Override - protected Optional getRequiredItemAsBlock(ClientPlayerEntity player) { - return Optional.of(state.targetState.getBlock()); - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/implementation/actions/InteractActionImpl.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/implementation/actions/InteractActionImpl.java deleted file mode 100644 index 6418f7e62..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/implementation/actions/InteractActionImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.implementation.actions; - -import me.aleksilassila.litematica.printer.v1_20.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_20.actions.InteractAction; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; - -public class InteractActionImpl extends InteractAction { - public InteractActionImpl(PrinterPlacementContext context) { - super(context); - } - - @Override - protected void interact(MinecraftClient client, ClientPlayerEntity player, Hand hand, BlockHitResult hitResult) { - client.interactionManager.interactBlock(player, hand, hitResult); - client.interactionManager.interactItem(player, hand); - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/mixin/AxeItemAccessor.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/mixin/AxeItemAccessor.java deleted file mode 100644 index 96057ecef..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/mixin/AxeItemAccessor.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.mixin; - -import net.minecraft.block.Block; -import net.minecraft.item.AxeItem; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.util.Map; - -/** - * This class apparently fixes an issue with Quilt. - */ -@Mixin(AxeItem.class) -public interface AxeItemAccessor { - @Accessor("STRIPPED_BLOCKS") - static Map getStrippedBlocks() { - throw new AssertionError("Untransformed @Accessor"); - } - -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/mixin/ConfigsMixin.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/mixin/ConfigsMixin.java deleted file mode 100644 index 2d8a44853..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/mixin/ConfigsMixin.java +++ /dev/null @@ -1,35 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.mixin; - -import com.google.common.collect.ImmutableList; -import fi.dy.masa.litematica.config.Configs; -import fi.dy.masa.malilib.config.IConfigBase; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import me.aleksilassila.litematica.printer.v1_20.LitematicaMixinMod; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.List; - -@Mixin(value = Configs.class, remap = false) -public class ConfigsMixin { - @Redirect(method = "loadFromFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Configs$Generic;OPTIONS:Lcom/google/common/collect/ImmutableList;")) - private static ImmutableList moreOptions() { - return LitematicaMixinMod.getConfigList(); - } - - @Redirect(method = "saveToFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Configs$Generic;OPTIONS:Lcom/google/common/collect/ImmutableList;")) - private static ImmutableList moreeOptions() { - return LitematicaMixinMod.getConfigList(); - } - - @Redirect(method = "loadFromFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private static List moreHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } - - @Redirect(method = "saveToFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private static List moreeHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/mixin/GuiConfigsMixin.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/mixin/GuiConfigsMixin.java deleted file mode 100644 index 2a6be8cf6..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/mixin/GuiConfigsMixin.java +++ /dev/null @@ -1,61 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.mixin; - -import com.google.common.collect.ImmutableList; -import fi.dy.masa.litematica.gui.GuiConfigs; -import fi.dy.masa.malilib.config.IConfigBase; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import me.aleksilassila.litematica.printer.v1_20.LitematicaMixinMod; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.List; - -@Mixin(value = GuiConfigs.class, remap = false) -public class GuiConfigsMixin { - - /*@Overwrite - public List getConfigs() - { - List configs; - ConfigGuiTab tab = DataManager.getConfigGuiTab(); - - if (tab == ConfigGuiTab.GENERIC) - { - configs = LitematicaMixinMod.betterConfigList; - } - else if (tab == ConfigGuiTab.INFO_OVERLAYS) - { - configs = Configs.InfoOverlays.OPTIONS; - } - else if (tab == ConfigGuiTab.VISUALS) - { - configs = Configs.Visuals.OPTIONS; - } - else if (tab == ConfigGuiTab.COLORS) - { - configs = Configs.Colors.OPTIONS; - } - else if (tab == ConfigGuiTab.HOTKEYS) - { - configs = LitematicaMixinMod.betterHotkeyList; - } - else - { - return Collections.emptyList(); - } - - return ConfigOptionWrapper.createFor(configs); - }*/ - - - @Redirect(method = "getConfigs", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Configs$Generic;OPTIONS:Lcom/google/common/collect/ImmutableList;")) - private ImmutableList moreOptions() { - return LitematicaMixinMod.getConfigList(); - } - - @Redirect(method = "getConfigs", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private List moreHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/mixin/InputHandlerMixin.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/mixin/InputHandlerMixin.java deleted file mode 100644 index 6ae175969..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/mixin/InputHandlerMixin.java +++ /dev/null @@ -1,25 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.mixin; - -import fi.dy.masa.litematica.event.InputHandler; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import me.aleksilassila.litematica.printer.v1_20.LitematicaMixinMod; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.List; - -@Mixin(value = InputHandler.class, remap = false) -public class InputHandlerMixin { - - @Redirect(method = "addHotkeys", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private List moreHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } - - @Redirect(method = "addKeysToMap", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private List moreeHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } - -} diff --git a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/mixin/PlayerMoveC2SPacketMixin.java b/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/mixin/PlayerMoveC2SPacketMixin.java deleted file mode 100644 index 38326667a..000000000 --- a/v1_20/src/main/java/me/aleksilassila/litematica/printer/v1_20/mixin/PlayerMoveC2SPacketMixin.java +++ /dev/null @@ -1,36 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20.mixin; - -import me.aleksilassila.litematica.printer.v1_20.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_20.Printer; -import me.aleksilassila.litematica.printer.v1_20.actions.PrepareAction; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; - -@Mixin(PlayerMoveC2SPacket.class) -public class PlayerMoveC2SPacketMixin { - @ModifyVariable(method = "(DDDFFZZZ)V", at = @At("HEAD"), ordinal = 0) - private static float modifyLookYaw(float yaw) { - Printer printer = LitematicaMixinMod.printer; - if (printer == null) return yaw; - - PrepareAction action = printer.actionHandler.lookAction; - if (action != null && action.modifyYaw) { - if (LitematicaMixinMod.DEBUG) System.out.println("YAW: " + action.yaw); - return action.yaw; - } else return yaw; - } - - @ModifyVariable(method = "(DDDFFZZZ)V", at = @At("HEAD"), ordinal = 1) - private static float modifyLookPitch(float pitch) { - Printer printer = LitematicaMixinMod.printer; - if (printer == null) return pitch; - - PrepareAction action = printer.actionHandler.lookAction; - if (action != null && action.modifyPitch) { - if (LitematicaMixinMod.DEBUG) System.out.println("PITCH: " + action.pitch); - return action.pitch; - } else return pitch; - } -} diff --git a/v1_20/src/main/resources/assets/modid/icon.png b/v1_20/src/main/resources/assets/modid/icon.png deleted file mode 100644 index 047b91f2347de5cf95f23284476fddbe21ba23fe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 453 zcmV;$0XqJPP)QAFYGys`80vegN0XDFh0OXKz&i8?Le#x7{1X)R+00000NkvXXu0mjf73i~T diff --git a/v1_20/src/main/resources/litematica-printer-implementation.mixins.json b/v1_20/src/main/resources/litematica-printer-implementation.mixins.json deleted file mode 100644 index 46d79fe99..000000000 --- a/v1_20/src/main/resources/litematica-printer-implementation.mixins.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "me.aleksilassila.litematica.printer.v1_20.implementation.mixin", - "compatibilityLevel": "JAVA_16", - "mixins": [ - ], - "client": [ - "MixinClientPlayerEntity" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/v1_20/src/main/resources/litematica-printer.mixins.json b/v1_20/src/main/resources/litematica-printer.mixins.json deleted file mode 100644 index bb8d1f41a..000000000 --- a/v1_20/src/main/resources/litematica-printer.mixins.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "me.aleksilassila.litematica.printer.v1_20.mixin", - "compatibilityLevel": "JAVA_16", - "mixins": [ - ], - "client": [ - "ConfigsMixin", - "GuiConfigsMixin", - "InputHandlerMixin", - "PlayerMoveC2SPacketMixin", - "AxeItemAccessor" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/v1_20_4/build.gradle.kts b/v1_20_4/build.gradle.kts deleted file mode 100644 index a0485044d..000000000 --- a/v1_20_4/build.gradle.kts +++ /dev/null @@ -1,88 +0,0 @@ -plugins { - id("fabric-loom").version("1.4-SNAPSHOT") - id("maven-publish") -} - -java.sourceCompatibility = JavaVersion.VERSION_17 -java.targetCompatibility = JavaVersion.VERSION_17 - -val archives_base_name: String by project -val minecraft_version: String by project -val yarn_mappings: String by project -val loader_version: String by project -val fabric_version: String by project -val malilib_version: String by project -val litematica_projectid: String by project -val litematica_fileid: String by project - -val mod_version: String by project - -dependencies { -// implementation(project(":common")) - minecraft("com.mojang:minecraft:${minecraft_version}") - mappings("net.fabricmc:yarn:${yarn_mappings}:v2") - - modImplementation("net.fabricmc:fabric-loader:${loader_version}") - modImplementation("net.fabricmc.fabric-api:fabric-api:${fabric_version}") - modImplementation("fi.dy.masa.malilib:malilib-fabric-${malilib_version}") - modImplementation("curse.maven:litematica-${litematica_projectid}:${litematica_fileid}") -} - -repositories { - maven("https://masa.dy.fi/maven") - maven("https://www.cursemaven.com") -} - -// Process resources -tasks.withType { - inputs.property("version", mod_version) - - filesMatching("fabric.mod.json") { - expand(mapOf("version" to mod_version)) - } -} - -val sourceModule = "v1_19_4" -val targetModules = arrayOf("v1_19", "v1_18", "v1_17") - -fun copyFile(source: File) { - for (targetModule in targetModules) { - val destination = file(source.absolutePath.replace(sourceModule, targetModule)) - println("Copying ${source.absolutePath} to ${destination.absolutePath}") - destination.parentFile.mkdirs() - source.copyTo(destination, true) - destination.writeText(destination.readText().replace(sourceModule, targetModule)) - } -} - -fun deleteOldFiles(sourceBase: File) { - for (targetModule in targetModules) { - val targetBase = file(sourceBase.absolutePath.replace(sourceModule, targetModule)) - - for (file in targetBase.listFiles()) { - if (file.name.equals("implementation")) continue - println("Deleting recursively ${file.absolutePath}") - file.deleteRecursively() - } - } -} - -val syncImplementations = tasks.create("syncImplementations") { - doFirst { - val sourceStart = - this.project.projectDir.absolutePath + "/src/main/java/me/aleksilassila/litematica/printer/" + sourceModule - val sourceDir = file(sourceStart) - - deleteOldFiles(sourceDir) - - for (sourceFile in sourceDir.listFiles()) { - if (sourceFile.name.equals("implementation")) continue - - sourceFile.walk() - .filter { it.isFile } - .forEach { - copyFile(it) - } - } - } -} diff --git a/v1_20_4/gradle.properties b/v1_20_4/gradle.properties deleted file mode 100644 index 0d793f826..000000000 --- a/v1_20_4/gradle.properties +++ /dev/null @@ -1,13 +0,0 @@ -# Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx1G -# https://masa.dy.fi/maven/fi/dy/masa/malilib/ -malilib_version=1.20.4:0.18.0 -# https://www.curseforge.com/minecraft/mc-mods/litematica/files -litematica_fileid=4946471 -litematica_projectid=308892 -# Fabric Properties: https://fabricmc.net/develop/ -minecraft_version=1.20.4 -yarn_mappings=1.20.4+build.3 -loader_version=0.15.3 -#Fabric api -fabric_version=0.91.3+1.20.4 \ No newline at end of file diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/ActionHandler.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/ActionHandler.java deleted file mode 100644 index dd68156ba..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/ActionHandler.java +++ /dev/null @@ -1,57 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4; - -import me.aleksilassila.litematica.printer.v1_20_4.actions.Action; -import me.aleksilassila.litematica.printer.v1_20_4.actions.PrepareAction; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; - -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; - -public class ActionHandler { - private final MinecraftClient client; - private final ClientPlayerEntity player; - - private final Queue actionQueue = new LinkedList<>(); - public PrepareAction lookAction = null; - - public ActionHandler(MinecraftClient client, ClientPlayerEntity player) { - this.client = client; - this.player = player; - } - - private int tick = 0; - - public void onGameTick() { - int tickRate = LitematicaMixinMod.PRINTING_INTERVAL.getIntegerValue(); - - tick = tick % tickRate == tickRate - 1 ? 0 : tick + 1; - if (tick % tickRate != 0) { - return; - } - - Action nextAction = actionQueue.poll(); - if (nextAction != null) { - if (LitematicaMixinMod.DEBUG) System.out.println("Sending action " + nextAction); - nextAction.send(client, player); - } else { - lookAction = null; - } - } - - public boolean acceptsActions() { - return actionQueue.isEmpty(); - } - - public void addActions(Action... actions) { - if (!acceptsActions()) return; - - for (Action action : actions) { - if (action instanceof PrepareAction) - lookAction = (PrepareAction) action; - } - - actionQueue.addAll(List.of(actions)); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/BlockHelper.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/BlockHelper.java deleted file mode 100644 index d6bb8f6a4..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/BlockHelper.java +++ /dev/null @@ -1,31 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4; - -import net.minecraft.block.*; -import net.minecraft.item.Item; -import net.minecraft.item.Items; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -abstract public class BlockHelper { - public static List> interactiveBlocks = new ArrayList<>(Arrays.asList( - AbstractChestBlock.class, AbstractFurnaceBlock.class, CraftingTableBlock.class, LeverBlock.class, - DoorBlock.class, TrapdoorBlock.class, BedBlock.class, RedstoneWireBlock.class, ScaffoldingBlock.class, - HopperBlock.class, EnchantingTableBlock.class, NoteBlock.class, JukeboxBlock.class, CakeBlock.class, - FenceGateBlock.class, BrewingStandBlock.class, DragonEggBlock.class, CommandBlock.class, - BeaconBlock.class, AnvilBlock.class, ComparatorBlock.class, RepeaterBlock.class, - DropperBlock.class, DispenserBlock.class, ShulkerBoxBlock.class, LecternBlock.class, - FlowerPotBlock.class, BarrelBlock.class, BellBlock.class, SmithingTableBlock.class, - LoomBlock.class, CartographyTableBlock.class, GrindstoneBlock.class, - StonecutterBlock.class, AbstractSignBlock.class, AbstractCandleBlock.class)); - - public static final Item[] SHOVEL_ITEMS = new Item[]{ - Items.NETHERITE_SHOVEL, - Items.DIAMOND_SHOVEL, - Items.GOLDEN_SHOVEL, - Items.IRON_SHOVEL, - Items.STONE_SHOVEL, - Items.WOODEN_SHOVEL - }; -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/LitematicaMixinMod.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/LitematicaMixinMod.java deleted file mode 100644 index b4356cb9c..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/LitematicaMixinMod.java +++ /dev/null @@ -1,58 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4; - -import com.google.common.collect.ImmutableList; -import fi.dy.masa.litematica.config.Configs; -import fi.dy.masa.litematica.config.Hotkeys; -import fi.dy.masa.malilib.config.IConfigBase; -import fi.dy.masa.malilib.config.options.ConfigBoolean; -import fi.dy.masa.malilib.config.options.ConfigDouble; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import fi.dy.masa.malilib.config.options.ConfigInteger; -import fi.dy.masa.malilib.hotkeys.KeyCallbackToggleBooleanConfigWithMessage; -import fi.dy.masa.malilib.hotkeys.KeybindSettings; -import net.fabricmc.api.ModInitializer; - -import java.util.List; - -public class LitematicaMixinMod implements ModInitializer { - - public static Printer printer; - public static boolean DEBUG = false; - // Config settings - public static final ConfigInteger PRINTING_INTERVAL = new ConfigInteger("printingInterval", 12, 1, 40, "Printing interval. Lower values mean faster printing speed.\nIf the printer creates \"ghost blocks\" or blocks are facing the wrong way, raise this value."); - public static final ConfigDouble PRINTING_RANGE = new ConfigDouble("printingRange", 5, 2.5, 5, "Printing block place range\nLower values are recommended for servers."); - // public static final ConfigBoolean PRINT_WATER = new ConfigBoolean("printWater", false, "Whether the printer should place water\n source blocks or make blocks waterlogged."); -// public static final ConfigBoolean PRINT_IN_AIR = new ConfigBoolean("printInAir", true, "Whether or not the printer should place blocks without anything to build on.\nBe aware that some anti-cheat plugins might notice this."); - public static final ConfigBoolean PRINT_MODE = new ConfigBoolean("printingMode", false, "Autobuild / print loaded selection.\nBe aware that some servers and anticheat plugins do not allow printing."); - public static final ConfigBoolean REPLACE_FLUIDS_SOURCE_BLOCKS = new ConfigBoolean("replaceFluidSourceBlocks", true, "Whether or not fluid source blocks should be replaced by the printer."); - public static final ConfigBoolean STRIP_LOGS = new ConfigBoolean("stripLogs", true, "Whether or not the printer should use normal logs if stripped\nversions are not available and then strip them with an axe."); - - public static ImmutableList getConfigList() { - List list = new java.util.ArrayList<>(Configs.Generic.OPTIONS); - list.add(PRINT_MODE); - list.add(PRINTING_INTERVAL); - list.add(PRINTING_RANGE); -// list.add(PRINT_IN_AIR); - list.add(REPLACE_FLUIDS_SOURCE_BLOCKS); - list.add(STRIP_LOGS); - - return ImmutableList.copyOf(list); - } - - // Hotkeys - public static final ConfigHotkey PRINT = new ConfigHotkey("print", "V", KeybindSettings.PRESS_ALLOWEXTRA_EMPTY, "Prints while pressed"); - public static final ConfigHotkey TOGGLE_PRINTING_MODE = new ConfigHotkey("togglePrintingMode", "CAPS_LOCK", KeybindSettings.PRESS_ALLOWEXTRA_EMPTY, "Allows quickly toggling on/off Printing mode"); - - public static List getHotkeyList() { - List list = new java.util.ArrayList<>(Hotkeys.HOTKEY_LIST); - list.add(PRINT); - list.add(TOGGLE_PRINTING_MODE); - - return ImmutableList.copyOf(list); - } - - @Override - public void onInitialize() { - TOGGLE_PRINTING_MODE.getKeybind().setCallback(new KeyCallbackToggleBooleanConfigWithMessage(PRINT_MODE)); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/Printer.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/Printer.java deleted file mode 100644 index d447a597f..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/Printer.java +++ /dev/null @@ -1,107 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4; - -import fi.dy.masa.litematica.data.DataManager; -import fi.dy.masa.litematica.util.RayTraceUtils; -import fi.dy.masa.litematica.world.SchematicWorldHandler; -import fi.dy.masa.litematica.world.WorldSchematic; -import me.aleksilassila.litematica.printer.v1_20_4.actions.Action; -import me.aleksilassila.litematica.printer.v1_20_4.guides.Guide; -import me.aleksilassila.litematica.printer.v1_20_4.guides.Guides; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerAbilities; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.List; - -public class Printer { - @NotNull - public final ClientPlayerEntity player; - - public final ActionHandler actionHandler; - - private final Guides interactionGuides = new Guides(); - - public Printer(@NotNull MinecraftClient client, @NotNull ClientPlayerEntity player) { - this.player = player; - - this.actionHandler = new ActionHandler(client, player); - } - - public boolean onGameTick() { - WorldSchematic worldSchematic = SchematicWorldHandler.getSchematicWorld(); - - if (!actionHandler.acceptsActions()) return false; - - if (worldSchematic == null) return false; - - if (!LitematicaMixinMod.PRINT_MODE.getBooleanValue() && !LitematicaMixinMod.PRINT.getKeybind().isPressed()) - return false; - - PlayerAbilities abilities = player.getAbilities(); - if (!abilities.allowModifyWorld) - return false; - - List positions = getReachablePositions(); - findBlock: - for (BlockPos position : positions) { - SchematicBlockState state = new SchematicBlockState(player.getWorld(), worldSchematic, position); - if (state.targetState.equals(state.currentState) || state.targetState.isAir()) continue; - - Guide[] guides = interactionGuides.getInteractionGuides(state); - - BlockHitResult result = RayTraceUtils.traceToSchematicWorld(player, 10, true, true); - boolean isCurrentlyLookingSchematic = result != null && result.getBlockPos().equals(position); - - for (Guide guide : guides) { - if (guide.canExecute(player)) { - System.out.println("Executing " + guide + " for " + state); - List actions = guide.execute(player); - actionHandler.addActions(actions.toArray(Action[]::new)); - return true; - } - if (guide.skipOtherGuides()) continue findBlock; - } - } - - return false; - } - - private List getReachablePositions() { - int maxReach = (int) Math.ceil(LitematicaMixinMod.PRINTING_RANGE.getDoubleValue()); - double maxReachSquared = MathHelper.square(LitematicaMixinMod.PRINTING_RANGE.getDoubleValue()); - - ArrayList positions = new ArrayList<>(); - - for (int y = -maxReach; y < maxReach + 1; y++) { - for (int x = -maxReach; x < maxReach + 1; x++) { - for (int z = -maxReach; z < maxReach + 1; z++) { - BlockPos blockPos = player.getBlockPos().north(x).west(z).up(y); - - if (!DataManager.getRenderLayerRange().isPositionWithinRange(blockPos)) continue; - if (this.player.getEyePos().squaredDistanceTo(Vec3d.ofCenter(blockPos)) > maxReachSquared) { - continue; - } - - positions.add(blockPos); - } - } - } - - return positions.stream() - .filter(p -> { - Vec3d vec = Vec3d.ofCenter(p); - return this.player.getPos().squaredDistanceTo(vec) > 1 && this.player.getEyePos().squaredDistanceTo(vec) > 1; - }) - .sorted((a, b) -> { - double aDistance = this.player.getPos().squaredDistanceTo(Vec3d.ofCenter(a)); - double bDistance = this.player.getPos().squaredDistanceTo(Vec3d.ofCenter(b)); - return Double.compare(aDistance, bDistance); - }).toList(); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/SchematicBlockState.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/SchematicBlockState.java deleted file mode 100644 index baf1b35b1..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/SchematicBlockState.java +++ /dev/null @@ -1,42 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4; - -import fi.dy.masa.litematica.world.WorldSchematic; -import net.minecraft.block.BlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.World; - -public class SchematicBlockState { - public final World world; - public final WorldSchematic schematic; - - public final BlockPos blockPos; - - public final BlockState targetState; - public final BlockState currentState; - - public SchematicBlockState(World world, WorldSchematic schematic, BlockPos blockPos) { - this.world = world; - this.schematic = schematic; - - this.blockPos = blockPos; - - this.targetState = schematic.getBlockState(blockPos); - this.currentState = world.getBlockState(blockPos); - } - - public SchematicBlockState offset(Direction direction) { - return new SchematicBlockState(world, schematic, blockPos.offset(direction)); - } - - @Override - public String toString() { - return "SchematicBlockState{" + - "world=" + world + - ", schematic=" + schematic + - ", blockPos=" + blockPos + - ", targetState=" + targetState + - ", currentState=" + currentState + - '}'; - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/actions/Action.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/actions/Action.java deleted file mode 100644 index 150d547f0..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/actions/Action.java +++ /dev/null @@ -1,8 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.actions; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; - -public abstract class Action { - abstract public void send(MinecraftClient client, ClientPlayerEntity player); -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/actions/InteractAction.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/actions/InteractAction.java deleted file mode 100644 index e71d8aa6e..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/actions/InteractAction.java +++ /dev/null @@ -1,33 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.actions; - -import me.aleksilassila.litematica.printer.v1_20_4.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_20_4.implementation.PrinterPlacementContext; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; - -abstract public class InteractAction extends Action { - public final PrinterPlacementContext context; - - public InteractAction(PrinterPlacementContext context) { - this.context = context; - } - - protected abstract void interact(MinecraftClient client, ClientPlayerEntity player, Hand hand, BlockHitResult hitResult); - - @Override - public void send(MinecraftClient client, ClientPlayerEntity player) { - interact(client, player, Hand.MAIN_HAND, context.hitResult); - - if (LitematicaMixinMod.DEBUG) - System.out.println("InteractAction.send: Blockpos: " + context.getBlockPos() + " Side: " + context.getSide() + " HitPos: " + context.getHitPos()); - } - - @Override - public String toString() { - return "InteractAction{" + - "context=" + context + - '}'; - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/actions/PrepareAction.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/actions/PrepareAction.java deleted file mode 100644 index 608e04079..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/actions/PrepareAction.java +++ /dev/null @@ -1,109 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.actions; - -import me.aleksilassila.litematica.printer.v1_20_4.implementation.PrinterPlacementContext; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; -import net.minecraft.util.Hand; -import net.minecraft.util.math.Direction; - -public class PrepareAction extends Action { -// public final Direction lookDirection; -// public final boolean requireSneaking; -// public final Item item; - -// public PrepareAction(Direction lookDirection, boolean requireSneaking, Item item) { -// this.lookDirection = lookDirection; -// this.requireSneaking = requireSneaking; -// this.item = item; -// } -// -// public PrepareAction(Direction lookDirection, boolean requireSneaking, BlockState requiredState) { -// this(lookDirection, requireSneaking, requiredState.getBlock().asItem()); -// } - - public final PrinterPlacementContext context; - - public boolean modifyYaw = true; - public boolean modifyPitch = true; - public float yaw = 0; - public float pitch = 0; - - public PrepareAction(PrinterPlacementContext context) { - this.context = context; - - Direction lookDirection = context.lookDirection; - - if (lookDirection != null && lookDirection.getAxis().isHorizontal()) { - this.yaw = lookDirection.asRotation(); - } else { - this.modifyYaw = false; - } - - if (lookDirection == Direction.UP) { - this.pitch = -90; - } else if (lookDirection == Direction.DOWN) { - this.pitch = 90; - } else if (lookDirection != null) { - this.pitch = 0; - } else { - this.modifyPitch = false; - } - } - - public PrepareAction(PrinterPlacementContext context, float yaw, float pitch) { - this.context = context; - - this.yaw = yaw; - this.pitch = pitch; - } - - @Override - public void send(MinecraftClient client, ClientPlayerEntity player) { - ItemStack itemStack = context.getStack(); - int slot = context.requiredItemSlot; - - if (itemStack != null) { - PlayerInventory inventory = player.getInventory(); - - // This thing is straight from MinecraftClient#doItemPick() - if (player.getAbilities().creativeMode) { - inventory.addPickBlock(itemStack); - client.interactionManager.clickCreativeStack(player.getStackInHand(Hand.MAIN_HAND), 36 + inventory.selectedSlot); - } else if (slot != -1) { - if (PlayerInventory.isValidHotbarIndex(slot)) { - inventory.selectedSlot = slot; - } else { - client.interactionManager.pickFromInventory(slot); - } - } - } - - if (modifyPitch || modifyYaw) { - float yaw = modifyYaw ? this.yaw : player.getYaw(); - float pitch = modifyPitch ? this.pitch : player.getPitch(); - - PlayerMoveC2SPacket packet = new PlayerMoveC2SPacket.Full(player.getX(), player.getY(), player.getZ(), yaw, pitch, player.isOnGround()); - - player.networkHandler.sendPacket(packet); - } - - if (context.shouldSneak) { - player.input.sneaking = true; - player.networkHandler.sendPacket(new ClientCommandC2SPacket(player, ClientCommandC2SPacket.Mode.PRESS_SHIFT_KEY)); - } else { - player.input.sneaking = false; - player.networkHandler.sendPacket(new ClientCommandC2SPacket(player, ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY)); - } - } - - @Override - public String toString() { - return "PrepareAction{" + - "context=" + context + - '}'; - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/actions/ReleaseShiftAction.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/actions/ReleaseShiftAction.java deleted file mode 100644 index f4342ebe8..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/actions/ReleaseShiftAction.java +++ /dev/null @@ -1,13 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.actions; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; - -public class ReleaseShiftAction extends Action { - @Override - public void send(MinecraftClient client, ClientPlayerEntity player) { - player.input.sneaking = false; - player.networkHandler.sendPacket(new ClientCommandC2SPacket(player, ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY)); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/Guide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/Guide.java deleted file mode 100644 index 4670ca0f6..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/Guide.java +++ /dev/null @@ -1,129 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides; - -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_20_4.actions.Action; -import me.aleksilassila.litematica.printer.v1_20_4.implementation.BlockHelperImpl; -import net.minecraft.block.BlockState; -import net.minecraft.block.CoralBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.state.property.Properties; -import net.minecraft.state.property.Property; -import org.jetbrains.annotations.NotNull; - -import java.util.List; -import java.util.Optional; - -abstract public class Guide extends BlockHelperImpl { - protected final SchematicBlockState state; - protected final BlockState currentState; - protected final BlockState targetState; - - public Guide(SchematicBlockState state) { - this.state = state; - - this.currentState = state.currentState; - this.targetState = state.targetState; - } - - protected boolean playerHasRightItem(ClientPlayerEntity player) { - return getRequiredItemStackSlot(player) != -1; - } - - protected int getSlotWithItem(ClientPlayerEntity player, ItemStack itemStack) { - PlayerInventory inventory = player.getInventory(); - - for (int i = 0; i < inventory.main.size(); ++i) { - if (itemStack.isEmpty() && inventory.main.get(i).isOf(itemStack.getItem())) return i; - if (!inventory.main.get(i).isEmpty() && ItemStack.areItemsEqual(inventory.main.get(i), itemStack)) { - return i; - } - } - - return -1; - } - - protected int getRequiredItemStackSlot(ClientPlayerEntity player) { - if (player.getAbilities().creativeMode) { - return player.getInventory().selectedSlot; - } - - Optional requiredItem = getRequiredItem(player); - if (requiredItem.isEmpty()) return -1; - - return getSlotWithItem(player, requiredItem.get()); - } - - public boolean canExecute(ClientPlayerEntity player) { - if (!playerHasRightItem(player)) return false; - - BlockState targetState = state.targetState; - BlockState currentState = state.currentState; - - return !statesEqual(targetState, currentState); - } - - abstract public @NotNull List execute(ClientPlayerEntity player); - - abstract protected @NotNull List getRequiredItems(); - - /** - * Returns the first required item that player has access to, - * or empty if the items are inaccessible. - */ - protected Optional getRequiredItem(ClientPlayerEntity player) { - List requiredItems = getRequiredItems(); - - for (ItemStack requiredItem : requiredItems) { - if (player.getAbilities().creativeMode) return Optional.of(requiredItem); - - int slot = getSlotWithItem(player, requiredItem); - if (slot > -1) - return Optional.of(requiredItem); - } - - return Optional.empty(); - } - - protected boolean statesEqualIgnoreProperties(BlockState state1, BlockState state2, Property... propertiesToIgnore) { - if (state1.getBlock() != state2.getBlock()) return false; - - loop: - for (Property property : state1.getProperties()) { - if (property == Properties.WATERLOGGED && !(state1.getBlock() instanceof CoralBlock)) continue; - - for (Property ignoredProperty : propertiesToIgnore) { - if (property == ignoredProperty) continue loop; - } - - try { - if (state1.get(property) != state2.get(property)) { - return false; - } - } catch (Exception e) { - return false; - } - } - - return true; - } - - protected static > Optional getProperty(BlockState blockState, Property property) { - if (blockState.contains(property)) { - return Optional.of(blockState.get(property)); - } - return Optional.empty(); - } - - /** - * Returns true if - */ - protected boolean statesEqual(BlockState state1, BlockState state2) { - return statesEqualIgnoreProperties(state1, state2); - } - - public boolean skipOtherGuides() { - return false; - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/Guides.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/Guides.java deleted file mode 100644 index a3c4b3333..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/Guides.java +++ /dev/null @@ -1,81 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides; - -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_20_4.guides.interaction.*; -import me.aleksilassila.litematica.printer.v1_20_4.guides.placement.*; -import net.minecraft.block.*; -import net.minecraft.util.Pair; - -import java.util.ArrayList; - -public class Guides { - protected final static ArrayList, Class[]>> guides = new ArrayList<>(); - - @SafeVarargs - protected static void registerGuide(Class guideClass, Class... blocks) { - guides.add(new Pair<>(guideClass, blocks)); - } - - static { -// registerGuide(SkipGuide.class, AbstractSignBlock.class, SkullBlock.class, BannerBlock.class); - - registerGuide(RotatingBlockGuide.class, AbstractSkullBlock.class, AbstractSignBlock.class, AbstractBannerBlock.class); - registerGuide(SlabGuide.class, SlabBlock.class); - registerGuide(TorchGuide.class, TorchBlock.class); - registerGuide(FarmlandGuide.class, FarmlandBlock.class); - registerGuide(TillingGuide.class, FarmlandBlock.class); - registerGuide(RailGuesserGuide.class, AbstractRailBlock.class); - registerGuide(ChestGuide.class, ChestBlock.class); - registerGuide(FlowerPotGuide.class, FlowerPotBlock.class); - registerGuide(FlowerPotFillGuide.class, FlowerPotBlock.class); - - registerGuide(PropertySpecificGuesserGuide.class, - RepeaterBlock.class, ComparatorBlock.class, RedstoneWireBlock.class, RedstoneTorchBlock.class, - BambooBlock.class, CactusBlock.class, SaplingBlock.class, ScaffoldingBlock.class, PointedDripstoneBlock.class, - HorizontalConnectingBlock.class, DoorBlock.class, TrapdoorBlock.class, FenceGateBlock.class, ChestBlock.class, - SnowBlock.class, SeaPickleBlock.class, CandleBlock.class, LeverBlock.class, EndPortalFrameBlock.class, - NoteBlock.class, CampfireBlock.class, PoweredRailBlock.class, LeavesBlock.class, TripwireHookBlock.class); - registerGuide(FallingBlockGuide.class, FallingBlock.class); - registerGuide(BlockIndifferentGuesserGuide.class, BambooBlock.class, BigDripleafStemBlock.class, BigDripleafBlock.class, - TwistingVinesPlantBlock.class, TripwireBlock.class); - - registerGuide(CampfireExtinguishGuide.class, CampfireBlock.class); - registerGuide(LightCandleGuide.class, AbstractCandleBlock.class); - registerGuide(EnderEyeGuide.class, EndPortalFrameBlock.class); - registerGuide(CycleStateGuide.class, - DoorBlock.class, FenceGateBlock.class, TrapdoorBlock.class, - LeverBlock.class, - RepeaterBlock.class, ComparatorBlock.class, NoteBlock.class); - registerGuide(BlockReplacementGuide.class, SnowBlock.class, SeaPickleBlock.class, CandleBlock.class, SlabBlock.class); - registerGuide(LogGuide.class); - registerGuide(LogStrippingGuide.class); - registerGuide(GuesserGuide.class); - } - - public ArrayList, Class[]>> getGuides() { - return guides; - } - - public Guide[] getInteractionGuides(SchematicBlockState state) { - ArrayList, Class[]>> guides = getGuides(); - - ArrayList applicableGuides = new ArrayList<>(); - for (Pair, Class[]> guidePair : guides) { - try { - if (guidePair.getRight().length == 0) { - applicableGuides.add(guidePair.getLeft().getConstructor(SchematicBlockState.class).newInstance(state)); - continue; - } - - for (Class clazz : guidePair.getRight()) { - if (clazz.isInstance(state.targetState.getBlock())) { - applicableGuides.add(guidePair.getLeft().getConstructor(SchematicBlockState.class).newInstance(state)); - } - } - } catch (Exception ignored) { - } - } - - return applicableGuides.toArray(Guide[]::new); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/SkipGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/SkipGuide.java deleted file mode 100644 index 26f1beab2..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/SkipGuide.java +++ /dev/null @@ -1,37 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides; - -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_20_4.actions.Action; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class SkipGuide extends Guide { - public SkipGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - return false; - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - return new ArrayList<>(); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(ItemStack.EMPTY); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/CampfireExtinguishGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/CampfireExtinguishGuide.java deleted file mode 100644 index 0d32058ce..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/CampfireExtinguishGuide.java +++ /dev/null @@ -1,34 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import net.minecraft.block.CampfireBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; - -public class CampfireExtinguishGuide extends InteractionGuide { - boolean shouldBeLit; - boolean isLit; - - public CampfireExtinguishGuide(SchematicBlockState state) { - super(state); - - shouldBeLit = getProperty(targetState, CampfireBlock.LIT).orElse(false); - isLit = getProperty(currentState, CampfireBlock.LIT).orElse(false); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return (currentState.getBlock() instanceof CampfireBlock) && !shouldBeLit && isLit; - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(SHOVEL_ITEMS).map(ItemStack::new).toList(); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/CycleStateGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/CycleStateGuide.java deleted file mode 100644 index f4e843e83..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/CycleStateGuide.java +++ /dev/null @@ -1,45 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.LeverBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.state.property.Properties; -import net.minecraft.state.property.Property; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class CycleStateGuide extends InteractionGuide { - private static final Property[] propertiesToIgnore = new Property[]{ - Properties.POWERED, - Properties.LIT - }; - - public CycleStateGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return targetState.getBlock() == currentState.getBlock(); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(ItemStack.EMPTY); - } - - @Override - protected boolean statesEqual(BlockState state1, BlockState state2) { - if (state2.getBlock() instanceof LeverBlock) { - return super.statesEqual(state1, state2); - } - - return statesEqualIgnoreProperties(state1, state2, propertiesToIgnore); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/EnderEyeGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/EnderEyeGuide.java deleted file mode 100644 index 64d6c7212..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/EnderEyeGuide.java +++ /dev/null @@ -1,33 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.state.property.Properties; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class EnderEyeGuide extends InteractionGuide { - public EnderEyeGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - if (currentState.contains(Properties.EYE) && targetState.contains(Properties.EYE)) { - return !currentState.get(Properties.EYE) && targetState.get(Properties.EYE); - } - - return false; - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(new ItemStack(Items.ENDER_EYE)); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/FlowerPotFillGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/FlowerPotFillGuide.java deleted file mode 100644 index 84905ea89..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/FlowerPotFillGuide.java +++ /dev/null @@ -1,40 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import net.minecraft.block.Block; -import net.minecraft.block.FlowerPotBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class FlowerPotFillGuide extends InteractionGuide { - private final Block content; - - public FlowerPotFillGuide(SchematicBlockState state) { - super(state); - - Block targetBlock = state.targetState.getBlock(); - if (targetBlock instanceof FlowerPotBlock) { - this.content = ((FlowerPotBlock) targetBlock).getContent(); - } else { - this.content = null; - } - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (content == null) return false; - if (!(currentState.getBlock() instanceof FlowerPotBlock)) return false; - - return super.canExecute(player); - } - - @Override - protected @NotNull List getRequiredItems() { - if (content == null) return Collections.emptyList(); - else return Collections.singletonList(new ItemStack(content)); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/InteractionGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/InteractionGuide.java deleted file mode 100644 index f139368c5..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/InteractionGuide.java +++ /dev/null @@ -1,49 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_20_4.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_20_4.actions.Action; -import me.aleksilassila.litematica.printer.v1_20_4.actions.PrepareAction; -import me.aleksilassila.litematica.printer.v1_20_4.actions.ReleaseShiftAction; -import me.aleksilassila.litematica.printer.v1_20_4.guides.Guide; -import me.aleksilassila.litematica.printer.v1_20_4.implementation.actions.InteractActionImpl; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.List; - -/** - * A guide that clicks the current block to change its state. - */ -public abstract class InteractionGuide extends Guide { - public InteractionGuide(SchematicBlockState state) { - super(state); - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - List actions = new ArrayList<>(); - - BlockHitResult hitResult = new BlockHitResult(Vec3d.ofCenter(state.blockPos), Direction.UP, state.blockPos, false); - ItemStack requiredItem = getRequiredItem(player).orElse(ItemStack.EMPTY); - int requiredSlot = getRequiredItemStackSlot(player); - - if (requiredSlot == -1) return actions; - - PrinterPlacementContext ctx = new PrinterPlacementContext(player, hitResult, requiredItem, requiredSlot); - - actions.add(new ReleaseShiftAction()); - actions.add(new PrepareAction(ctx)); - actions.add(new InteractActionImpl(ctx)); - - return actions; - } - - @Override - abstract protected @NotNull List getRequiredItems(); -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/LightCandleGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/LightCandleGuide.java deleted file mode 100644 index f1677a058..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/LightCandleGuide.java +++ /dev/null @@ -1,36 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import net.minecraft.block.AbstractCandleBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.state.property.Properties; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class LightCandleGuide extends InteractionGuide { - boolean shouldBeLit; - boolean isLit; - - public LightCandleGuide(SchematicBlockState state) { - super(state); - - shouldBeLit = getProperty(targetState, Properties.LIT).orElse(false); - isLit = getProperty(currentState, Properties.LIT).orElse(false); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(new ItemStack(Items.FLINT_AND_STEEL)); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return (currentState.getBlock() instanceof AbstractCandleBlock) && shouldBeLit && !isLit; - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/LogStrippingGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/LogStrippingGuide.java deleted file mode 100644 index 3be48f732..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/LogStrippingGuide.java +++ /dev/null @@ -1,47 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_20_4.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_20_4.mixin.AxeItemAccessor; -import net.minecraft.block.Block; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -public class LogStrippingGuide extends InteractionGuide { - static final Item[] AXE_ITEMS = new Item[]{ - Items.NETHERITE_AXE, - Items.DIAMOND_AXE, - Items.GOLDEN_AXE, - Items.IRON_AXE, - Items.STONE_AXE, - Items.WOODEN_AXE - }; - - public static final Map STRIPPED_BLOCKS = AxeItemAccessor.getStrippedBlocks(); - - public LogStrippingGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!LitematicaMixinMod.STRIP_LOGS.getBooleanValue()) return false; - - if (!super.canExecute(player)) return false; - - Block strippingResult = STRIPPED_BLOCKS.get(currentState.getBlock()); - return strippingResult == targetState.getBlock(); - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(AXE_ITEMS).map(ItemStack::new).toList(); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/TillingGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/TillingGuide.java deleted file mode 100644 index 9ad7ea99b..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/interaction/TillingGuide.java +++ /dev/null @@ -1,39 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.interaction; - -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_20_4.guides.placement.FarmlandGuide; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; - -public class TillingGuide extends InteractionGuide { - public static final Item[] HOE_ITEMS = new Item[]{ - Items.NETHERITE_HOE, - Items.DIAMOND_HOE, - Items.GOLDEN_HOE, - Items.IRON_HOE, - Items.STONE_HOE, - Items.WOODEN_HOE - }; - - public TillingGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - return Arrays.stream(FarmlandGuide.TILLABLE_BLOCKS).anyMatch(b -> b == currentState.getBlock()); - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(HOE_ITEMS).map(ItemStack::new).toList(); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/BlockReplacementGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/BlockReplacementGuide.java deleted file mode 100644 index e88fcf258..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/BlockReplacementGuide.java +++ /dev/null @@ -1,76 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20_4.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_20_4.guides.Guide; -import net.minecraft.block.CandleBlock; -import net.minecraft.block.SeaPickleBlock; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.SnowBlock; -import net.minecraft.block.enums.SlabType; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.state.property.IntProperty; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.Nullable; - -import java.util.HashMap; -import java.util.Optional; - -public class BlockReplacementGuide extends PlacementGuide { - private static final HashMap increasingProperties = new HashMap<>(); - - static { - increasingProperties.put(SnowBlock.LAYERS, null); - increasingProperties.put(SeaPickleBlock.PICKLES, null); - increasingProperties.put(CandleBlock.CANDLES, null); - } - - private Integer currentLevel = null; - private Integer targetLevel = null; - private IntProperty increasingProperty = null; - - public BlockReplacementGuide(SchematicBlockState state) { - super(state); - - for (IntProperty property : increasingProperties.keySet()) { - if (targetState.contains(property) && currentState.contains(property)) { - currentLevel = currentState.get(property); - targetLevel = targetState.get(property); - increasingProperty = property; - break; - } - } - } - - @Override - protected boolean getUseShift(SchematicBlockState state) { - return false; - } - - @Override - public @Nullable PrinterPlacementContext getPlacementContext(ClientPlayerEntity player) { - Optional requiredItem = getRequiredItem(player); - int slot = getRequiredItemStackSlot(player); - if (requiredItem.isEmpty() || slot == -1) return null; - - BlockHitResult hitResult = new BlockHitResult(Vec3d.ofCenter(state.blockPos), Direction.UP, state.blockPos, false); - return new PrinterPlacementContext(player, hitResult, requiredItem.get(), slot); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (Guide.getProperty(targetState, SlabBlock.TYPE).orElse(null) == SlabType.DOUBLE && Guide.getProperty(currentState, SlabBlock.TYPE).orElse(SlabType.DOUBLE) != SlabType.DOUBLE) { - return super.canExecute(player); - } - - if (currentLevel == null || targetLevel == null || increasingProperty == null) return false; - if (!statesEqualIgnoreProperties(currentState, targetState, CandleBlock.LIT, increasingProperty)) return false; - if (currentLevel >= targetLevel) return false; - - return super.canExecute(player); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/ChestGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/ChestGuide.java deleted file mode 100644 index 724eff513..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/ChestGuide.java +++ /dev/null @@ -1,92 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.ChestBlock; -import net.minecraft.block.enums.ChestType; -import net.minecraft.util.math.Direction; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -/** - * Whilst making this guide, I learned that chests are much like humans. - * Some prefer to stay single, and some want to connect with another of its kind. - * Also that reversing chest connection logic is an enormous pain in the ass. I spent way too long on this. - * Thanks for coming to my ted talk - */ -public class ChestGuide extends GeneralPlacementGuide { - public ChestGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected boolean getRequiresExplicitShift() { - return true; - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - protected Optional getLookDirection() { - return getProperty(targetState, ChestBlock.FACING) - .flatMap(facing -> Optional.of(facing.getOpposite())); - } - - @Override - protected List getPossibleSides() { - ChestType targetType = getProperty(targetState, ChestBlock.CHEST_TYPE).orElse(null); - Direction targetFacing = getProperty(targetState, ChestBlock.FACING).orElse(null); - - List sides = new ArrayList<>(); - - if (targetFacing == null || targetType == null) return sides; - - for (Direction direction : Direction.values()) { - if (targetType == ChestType.SINGLE && !willConnectToSide(state, direction)) { - sides.add(direction); - } else if (wantsToConnectToSide(state, direction) && willConnectToSide(state, direction)) { // :D - sides.add(direction); - } - } - - // Place single chests if cannot connect any existing chests - if (sides.isEmpty()) { - for (Direction direction : Direction.values()) { - if (!wantsToConnectToSide(state, direction) && !willConnectToSide(state, direction)) { - sides.add(direction); - } - } - } - - return sides; - } - - private boolean willConnectToSide(SchematicBlockState state, Direction neighborDirection) { - BlockState neighbor = state.offset(neighborDirection).currentState; - ChestType neighborType = getProperty(neighbor, ChestBlock.CHEST_TYPE).orElse(null); - Direction neighborFacing = getProperty(neighbor, ChestBlock.FACING).orElse(null); - Direction facing = getProperty(state.targetState, ChestBlock.FACING).orElse(null); - - if (neighborType == null || neighborFacing == null || facing == null) return false; - - if (facing.getAxis() == neighborDirection.getAxis() || neighborDirection.getAxis() == Direction.Axis.Y) - return false; - - return neighborType == ChestType.SINGLE && neighborFacing == facing && state.targetState.getBlock() == neighbor.getBlock(); - } - - private boolean wantsToConnectToSide(SchematicBlockState state, Direction direction) { - ChestType type = getProperty(state.targetState, ChestBlock.CHEST_TYPE).orElse(null); - Direction facing = getProperty(state.targetState, ChestBlock.FACING).orElse(null); - if (type == null || facing == null || type == ChestType.SINGLE) return false; - - Direction neighborDirection = type == ChestType.LEFT ? facing.rotateYClockwise() : facing.rotateYCounterclockwise(); - - return direction == neighborDirection; - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/FallingBlockGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/FallingBlockGuide.java deleted file mode 100644 index 30b52aaed..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/FallingBlockGuide.java +++ /dev/null @@ -1,37 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.FallingBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.math.Direction; - -public class FallingBlockGuide extends GuesserGuide { - - public FallingBlockGuide(SchematicBlockState state) { - super(state); - } - - boolean blockPlacement() { - if (targetState.getBlock() instanceof FallingBlock) { - BlockState below = state.world.getBlockState(state.blockPos.offset(Direction.DOWN)); - return FallingBlock.canFallThrough(below); - } - - return false; - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (blockPlacement()) return false; - - return super.canExecute(player); - } - - @Override - public boolean skipOtherGuides() { - if (blockPlacement()) return true; - - return super.skipOtherGuides(); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/FarmlandGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/FarmlandGuide.java deleted file mode 100644 index 81086c802..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/FarmlandGuide.java +++ /dev/null @@ -1,29 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import net.minecraft.block.Block; -import net.minecraft.block.Blocks; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.util.Arrays; -import java.util.List; - -public class FarmlandGuide extends GeneralPlacementGuide { - public static final Block[] TILLABLE_BLOCKS = new Block[]{ - Blocks.DIRT, - Blocks.GRASS_BLOCK, - Blocks.COARSE_DIRT, - Blocks.ROOTED_DIRT, - Blocks.DIRT_PATH, - }; - - public FarmlandGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected @NotNull List getRequiredItems() { - return Arrays.stream(TILLABLE_BLOCKS).map(b -> getBlockItem(b.getDefaultState())).toList(); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/FlowerPotGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/FlowerPotGuide.java deleted file mode 100644 index dd2b0dd1f..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/FlowerPotGuide.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class FlowerPotGuide extends GeneralPlacementGuide { - public FlowerPotGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(new ItemStack(Items.FLOWER_POT)); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/GeneralPlacementGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/GeneralPlacementGuide.java deleted file mode 100644 index 9c17376ef..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/GeneralPlacementGuide.java +++ /dev/null @@ -1,119 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20_4.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.enums.SlabType; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -/** - * An old school guide where there are defined specific conditions - * for player state depending on the block being placed. - */ -public class GeneralPlacementGuide extends PlacementGuide { - public GeneralPlacementGuide(SchematicBlockState state) { - super(state); - } - - protected List getPossibleSides() { - return Arrays.asList(Direction.values()); - } - - protected Optional getLookDirection() { - return Optional.empty(); - } - - protected boolean getRequiresSupport() { - return false; - } - - protected boolean getRequiresExplicitShift() { - return false; - } - - protected Vec3d getHitModifier(Direction validSide) { - return new Vec3d(0, 0, 0); - } - - private Optional getValidSide(SchematicBlockState state) { - boolean printInAir = false; // LitematicaMixinMod.PRINT_IN_AIR.getBooleanValue(); - - List sides = getPossibleSides(); - - if (sides.isEmpty()) { - return Optional.empty(); - } - - List validSides = new ArrayList<>(); - for (Direction side : sides) { - if (printInAir && !getRequiresSupport()) { - return Optional.of(side); - } else { - SchematicBlockState neighborState = state.offset(side); - - if (getProperty(neighborState.currentState, SlabBlock.TYPE).orElse(null) == SlabType.DOUBLE) { - validSides.add(side); - continue; - } - - if (canBeClicked(neighborState.world, neighborState.blockPos) && // Handle unclickable grass for example - !neighborState.currentState.isReplaceable()) - validSides.add(side); - } - } - - for (Direction validSide : validSides) { - if (!isInteractive(state.offset(validSide).currentState.getBlock())) { - return Optional.of(validSide); - } - } - - return validSides.isEmpty() ? Optional.empty() : Optional.of(validSides.get(0)); - } - - protected boolean getUseShift(SchematicBlockState state) { - if (getRequiresExplicitShift()) return true; - - Direction clickSide = getValidSide(state).orElse(null); - if (clickSide == null) return false; - return isInteractive(state.offset(clickSide).currentState.getBlock()); - } - - private Optional getHitVector(SchematicBlockState state) { - return getValidSide(state).map(side -> Vec3d.ofCenter(state.blockPos) - .add(Vec3d.of(side.getVector()).multiply(0.5)) - .add(getHitModifier(side))); - } - - @Nullable - public PrinterPlacementContext getPlacementContext(ClientPlayerEntity player) { - try { - Optional validSide = getValidSide(state); - Optional hitVec = getHitVector(state); - Optional requiredItem = getRequiredItem(player); - int requiredSlot = getRequiredItemStackSlot(player); - - if (validSide.isEmpty() || hitVec.isEmpty() || requiredItem.isEmpty() || requiredSlot == -1) return null; - - Optional lookDirection = getLookDirection(); - boolean requiresShift = getUseShift(state); - - BlockHitResult blockHitResult = new BlockHitResult(hitVec.get(), validSide.get().getOpposite(), state.blockPos.offset(validSide.get()), false); - - return new PrinterPlacementContext(player, blockHitResult, requiredItem.get(), requiredSlot, lookDirection.orElse(null), requiresShift); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/GuesserGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/GuesserGuide.java deleted file mode 100644 index ada31ba38..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/GuesserGuide.java +++ /dev/null @@ -1,110 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20_4.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_20_4.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.ChestBlock; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.enums.ChestType; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.Nullable; - -/** - * This is the placement guide that most blocks will use. - * It will try to predict the correct player state for producing the right blockState - * by brute forcing the correct hit vector and look direction. - */ -public class GuesserGuide extends GeneralPlacementGuide { - private PrinterPlacementContext contextCache = null; - - protected static Direction[] directionsToTry = new Direction[]{ - Direction.NORTH, - Direction.SOUTH, - Direction.EAST, - Direction.WEST, - Direction.UP, - Direction.DOWN - }; - protected static Vec3d[] hitVecsToTry = new Vec3d[]{ - new Vec3d(-0.25, -0.25, -0.25), - new Vec3d(+0.25, -0.25, -0.25), - new Vec3d(-0.25, +0.25, -0.25), - new Vec3d(-0.25, -0.25, +0.25), - new Vec3d(+0.25, +0.25, -0.25), - new Vec3d(-0.25, +0.25, +0.25), - new Vec3d(+0.25, -0.25, +0.25), - new Vec3d(+0.25, +0.25, +0.25), - }; - - public GuesserGuide(SchematicBlockState state) { - super(state); - } - - @Nullable - @Override - public PrinterPlacementContext getPlacementContext(ClientPlayerEntity player) { - if (contextCache != null && !LitematicaMixinMod.DEBUG) return contextCache; - - ItemStack requiredItem = getRequiredItem(player).orElse(ItemStack.EMPTY); - int slot = getRequiredItemStackSlot(player); - - if (slot == -1) return null; - - for (Direction lookDirection : directionsToTry) { - for (Direction side : directionsToTry) { - BlockPos neighborPos = state.blockPos.offset(side); - BlockState neighborState = state.world.getBlockState(neighborPos); - boolean requiresShift = getRequiresExplicitShift() || isInteractive(neighborState.getBlock()); - - if (!canBeClicked(state.world, neighborPos) || // Handle unclickable grass for example - neighborState.isReplaceable()) - continue; - - Vec3d hitVec = Vec3d.ofCenter(state.blockPos) - .add(Vec3d.of(side.getVector()).multiply(0.5)); - - for (Vec3d hitVecToTry : hitVecsToTry) { - Vec3d multiplier = Vec3d.of(side.getVector()); - multiplier = new Vec3d(multiplier.x == 0 ? 1 : 0, multiplier.y == 0 ? 1 : 0, multiplier.z == 0 ? 1 : 0); - - BlockHitResult hitResult = new BlockHitResult(hitVec.add(hitVecToTry.multiply(multiplier)), side.getOpposite(), neighborPos, false); - PrinterPlacementContext context = new PrinterPlacementContext(player, hitResult, requiredItem, slot, lookDirection, requiresShift); - BlockState result = getRequiredItemAsBlock(player) - .orElse(targetState.getBlock()) - .getPlacementState(context); // FIXME torch shift clicks another torch and getPlacementState is the clicked block, which is true - - if (result != null && (statesEqual(result, targetState) || correctChestPlacement(targetState, result))) { - contextCache = context; - return context; - } - } - } - } - - return null; - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (targetState.getBlock() instanceof SlabBlock) return false; // Slabs are a special case - - return super.canExecute(player); - } - - private boolean correctChestPlacement(BlockState targetState, BlockState result) { - if (targetState.contains(ChestBlock.CHEST_TYPE) && result.contains(ChestBlock.CHEST_TYPE) && result.get(ChestBlock.FACING) == targetState.get(ChestBlock.FACING)) { - ChestType targetChestType = targetState.get(ChestBlock.CHEST_TYPE); - ChestType resultChestType = result.get(ChestBlock.CHEST_TYPE); - - return targetChestType != ChestType.SINGLE && resultChestType == ChestType.SINGLE; - } - - return false; - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/LogGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/LogGuide.java deleted file mode 100644 index fd7c8be60..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/LogGuide.java +++ /dev/null @@ -1,54 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20_4.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_20_4.guides.interaction.LogStrippingGuide; -import net.minecraft.block.Block; -import net.minecraft.block.PillarBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.Direction; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -public class LogGuide extends GeneralPlacementGuide { - public LogGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - if (targetState.contains(PillarBlock.AXIS)) { - Direction.Axis axis = targetState.get(PillarBlock.AXIS); - return Arrays.stream(Direction.values()).filter(d -> d.getAxis() == axis).toList(); - } - - return new ArrayList<>(); - } - - @Override - protected @NotNull List getRequiredItems() { - for (Block log : LogStrippingGuide.STRIPPED_BLOCKS.keySet()) { - if (targetState.getBlock() == LogStrippingGuide.STRIPPED_BLOCKS.get(log)) { - return Collections.singletonList(new ItemStack(log)); - } - } - - return super.getRequiredItems(); - } - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!LitematicaMixinMod.STRIP_LOGS.getBooleanValue()) return false; - - if (LogStrippingGuide.STRIPPED_BLOCKS.containsValue(targetState.getBlock())) { - return super.canExecute(player); - } - - return false; - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/PlacementGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/PlacementGuide.java deleted file mode 100644 index a919a3b62..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/PlacementGuide.java +++ /dev/null @@ -1,139 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20_4.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_20_4.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_20_4.actions.Action; -import me.aleksilassila.litematica.printer.v1_20_4.actions.PrepareAction; -import me.aleksilassila.litematica.printer.v1_20_4.actions.ReleaseShiftAction; -import me.aleksilassila.litematica.printer.v1_20_4.guides.Guide; -import me.aleksilassila.litematica.printer.v1_20_4.implementation.actions.InteractActionImpl; -import net.minecraft.block.*; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.item.BlockItem; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.World; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -/** - * Guide that clicks its neighbors to create a placement in target position. - */ -abstract public class PlacementGuide extends Guide { - public PlacementGuide(SchematicBlockState state) { - super(state); - } - - protected ItemStack getBlockItem(BlockState state) { - return state.getBlock().getPickStack(this.state.world, this.state.blockPos, state); - } - - protected Optional getRequiredItemAsBlock(ClientPlayerEntity player) { - Optional requiredItem = getRequiredItem(player); - - if (requiredItem.isEmpty()) { - return Optional.empty(); - } else { - ItemStack itemStack = requiredItem.get(); - - if (itemStack.getItem() instanceof BlockItem) - return Optional.of(((BlockItem) itemStack.getItem()).getBlock()); - else return Optional.empty(); - } - } - - @Override - protected @NotNull List getRequiredItems() { - return Collections.singletonList(getBlockItem(state.targetState)); - } - - abstract protected boolean getUseShift(SchematicBlockState state); - - @Nullable - abstract public PrinterPlacementContext getPlacementContext(ClientPlayerEntity player); - - @Override - public boolean canExecute(ClientPlayerEntity player) { - if (!super.canExecute(player)) return false; - - List requiredItems = getRequiredItems(); - if (requiredItems.isEmpty() || requiredItems.stream().allMatch(i -> i.isOf(Items.AIR))) - return false; - - ItemPlacementContext ctx = getPlacementContext(player); - if (ctx == null || !ctx.canPlace()) return false; -// if (!state.currentState.getMaterial().isReplaceable()) return false; - if (!LitematicaMixinMod.REPLACE_FLUIDS_SOURCE_BLOCKS.getBooleanValue() - && getProperty(state.currentState, FluidBlock.LEVEL).orElse(1) == 0) - return false; - - BlockState resultState = getRequiredItemAsBlock(player) - .orElse(targetState.getBlock()) - .getPlacementState(ctx); - - if (resultState != null) { - if (!resultState.canPlaceAt(state.world, state.blockPos)) return false; - return !(currentState.getBlock() instanceof FluidBlock) || canPlaceInWater(resultState); - } else { - return false; - } - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - List actions = new ArrayList<>(); - PrinterPlacementContext ctx = getPlacementContext(player); - - if (ctx == null) return actions; - actions.add(new PrepareAction(ctx)); - actions.add(new InteractActionImpl(ctx)); - if (ctx.shouldSneak) actions.add(new ReleaseShiftAction()); - - return actions; - } - - protected static boolean canBeClicked(World world, BlockPos pos) { - return getOutlineShape(world, pos) != VoxelShapes.empty() && !(world.getBlockState(pos).getBlock() instanceof AbstractSignBlock); // FIXME signs - } - - private static VoxelShape getOutlineShape(World world, BlockPos pos) { - return world.getBlockState(pos).getOutlineShape(world, pos); - } - - public boolean isInteractive(Block block) { - for (Class clazz : interactiveBlocks) { - if (clazz.isInstance(block)) { - return true; - } - } - - return false; - } - - private boolean canPlaceInWater(BlockState blockState) { - Block block = blockState.getBlock(); - if (block instanceof FluidFillable) { - return true; - } else if (!(block instanceof DoorBlock) && !(blockState.getBlock() instanceof AbstractSignBlock) && !blockState.isOf(Blocks.LADDER) && !blockState.isOf(Blocks.SUGAR_CANE) && !blockState.isOf(Blocks.BUBBLE_COLUMN)) { -// Material material = blockState.getMaterial(); -// if (material != Material.PORTAL && material != Material.STRUCTURE_VOID && material != Material.UNDERWATER_PLANT && material != Material.REPLACEABLE_UNDERWATER_PLANT) { -// return material.blocksMovement(); -// } else { -// return true; -// } - return blockState.blocksMovement(); - } - - return true; - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/PropertySpecificGuesserGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/PropertySpecificGuesserGuide.java deleted file mode 100644 index 4ce973336..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/PropertySpecificGuesserGuide.java +++ /dev/null @@ -1,52 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import net.minecraft.block.*; -import net.minecraft.state.property.Properties; -import net.minecraft.state.property.Property; - -public class PropertySpecificGuesserGuide extends GuesserGuide { - protected static Property[] ignoredProperties = new Property[]{ - RepeaterBlock.DELAY, - ComparatorBlock.MODE, - RedstoneWireBlock.POWER, - RedstoneWireBlock.WIRE_CONNECTION_EAST, - RedstoneWireBlock.WIRE_CONNECTION_NORTH, - RedstoneWireBlock.WIRE_CONNECTION_SOUTH, - RedstoneWireBlock.WIRE_CONNECTION_WEST, - Properties.POWERED, - Properties.OPEN, - PointedDripstoneBlock.THICKNESS, - ScaffoldingBlock.DISTANCE, - ScaffoldingBlock.BOTTOM, - CactusBlock.AGE, - BambooBlock.AGE, - BambooBlock.LEAVES, - BambooBlock.STAGE, - SaplingBlock.STAGE, - HorizontalConnectingBlock.EAST, - HorizontalConnectingBlock.NORTH, - HorizontalConnectingBlock.SOUTH, - HorizontalConnectingBlock.WEST, - SnowBlock.LAYERS, - SeaPickleBlock.PICKLES, - CandleBlock.CANDLES, - EndPortalFrameBlock.EYE, - Properties.LIT, - LeavesBlock.DISTANCE, - LeavesBlock.PERSISTENT, - Properties.ATTACHED, - Properties.NOTE, - Properties.INSTRUMENT, - - }; - - public PropertySpecificGuesserGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected boolean statesEqual(BlockState resultState, BlockState targetState) { - return statesEqualIgnoreProperties(resultState, targetState, ignoredProperties); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/RailGuesserGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/RailGuesserGuide.java deleted file mode 100644 index 9c0fe60fe..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/RailGuesserGuide.java +++ /dev/null @@ -1,128 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.enums.RailShape; -import net.minecraft.state.property.Properties; -import net.minecraft.util.math.Direction; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -public class RailGuesserGuide extends GuesserGuide { - static final RailShape[] STRAIGHT_RAIL_SHAPES = new RailShape[]{ - RailShape.NORTH_SOUTH, - RailShape.EAST_WEST - }; - - public RailGuesserGuide(SchematicBlockState state) { - super(state); - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - protected boolean statesEqual(BlockState resultState, BlockState targetState) { - if (!wouldConnectCorrectly()) return false; -// if (wouldBlockAnotherConnection()) return false; - /*TODO: Fully working rail guesser - * If has a neighbor that: - * - Has not been placed yet - * - OR Has been placed but can change shape - * - AND this placement should connect to only one rail, that is not the neighbor - * Then return false - * */ - - if (getRailShape(resultState).isPresent()) { - if (Arrays.stream(STRAIGHT_RAIL_SHAPES).anyMatch(shape -> shape == getRailShape(resultState).orElse(null))) { - return super.statesEqualIgnoreProperties(resultState, targetState, Properties.RAIL_SHAPE, Properties.STRAIGHT_RAIL_SHAPE, Properties.POWERED); - } - } - - return super.statesEqual(resultState, targetState); - } - - private boolean wouldConnectCorrectly() { - RailShape targetShape = getRailShape(state.targetState).orElse(null); - if (targetShape == null) return false; - - List allowedConnections = getRailDirections(targetShape); - - List possibleConnections = new ArrayList<>(); - for (Direction d : Direction.values()) { - if (d.getAxis().isVertical()) continue; - SchematicBlockState neighbor = state.offset(d); - - if (hasFreeConnections(neighbor)) { - possibleConnections.add(d); - } - } - - if (possibleConnections.size() > 2) return false; - - return allowedConnections.containsAll(possibleConnections); - } - -// private boolean wouldBlockAnotherConnection() { -// List possibleConnections = new ArrayList<>(); -// -// for (Direction d : Direction.values()) { -// if (d.getAxis().isVertical()) continue; -// SchematicBlockState neighbor = state.offset(d); -// -// if (couldConnectWrongly(neighbor)) { -// possibleConnections.add(d); -// } -// } -// -// return possibleConnections.size() > 1; -// } - - private boolean hasFreeConnections(SchematicBlockState state) { - List possibleConnections = getRailDirections(state); - if (possibleConnections.isEmpty()) return false; - - for (Direction d : possibleConnections) { - SchematicBlockState neighbor = state.offset(d); - if (neighbor.currentState.getBlock() != neighbor.currentState.getBlock()) { - return false; - } - } - - return possibleConnections.stream().anyMatch(possibleDirection -> { - SchematicBlockState neighbor = state.offset(possibleDirection); - return !getRailDirections(neighbor).contains(possibleDirection.getOpposite()); - }); - } - - private List getRailDirections(SchematicBlockState state) { - RailShape shape = getRailShape(state.currentState).orElse(null); - if (shape == null) return new ArrayList<>(); - - return getRailDirections(shape); - } - - private List getRailDirections(RailShape railShape) { - String name = railShape.getName(); - - if (railShape.isAscending()) { - Direction d = Direction.valueOf(name.replace("ascending_", "").toUpperCase()); - return Arrays.asList(d, d.getOpposite()); - } else { - Direction d1 = Direction.valueOf(name.split("_")[0].toUpperCase()); - Direction d2 = Direction.valueOf(name.split("_")[1].toUpperCase()); - return Arrays.asList(d1, d2); - } - } - - Optional getRailShape(BlockState state) { - Optional shape = getProperty(state, Properties.RAIL_SHAPE); - if (shape.isEmpty()) return getProperty(state, Properties.STRAIGHT_RAIL_SHAPE); - return shape; - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/RotatingBlockGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/RotatingBlockGuide.java deleted file mode 100644 index 0f66b465c..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/RotatingBlockGuide.java +++ /dev/null @@ -1,58 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20_4.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_20_4.actions.Action; -import me.aleksilassila.litematica.printer.v1_20_4.actions.PrepareAction; -import net.minecraft.block.*; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.state.property.Properties; -import net.minecraft.util.math.Direction; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -public class RotatingBlockGuide extends GeneralPlacementGuide { - public RotatingBlockGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - Block block = state.targetState.getBlock(); - if (block instanceof WallSkullBlock || block instanceof WallSignBlock || block instanceof WallBannerBlock) { - Optional side = getProperty(state.targetState, Properties.HORIZONTAL_FACING).map(Direction::getOpposite); - return side.map(Collections::singletonList).orElseGet(Collections::emptyList); - } - - return Collections.singletonList(Direction.DOWN); - } - - @Override - public boolean skipOtherGuides() { - return true; - } - - @Override - public @NotNull List execute(ClientPlayerEntity player) { - PrinterPlacementContext ctx = getPlacementContext(player); - - if (ctx == null) return new ArrayList<>(); - - int rotation = getProperty(state.targetState, Properties.ROTATION).orElse(0); - if (targetState.getBlock() instanceof BannerBlock || targetState.getBlock() instanceof SignBlock) { - rotation = (rotation + 8) % 16; - } - - int distTo0 = rotation > 8 ? 16 - rotation : rotation; - float yaw = Math.round(distTo0 / 8f * 180f * (rotation > 8 ? -1 : 1)); - - List actions = super.execute(player); - actions.set(0, new PrepareAction(ctx, yaw, 0)); - - return actions; - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/SlabGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/SlabGuide.java deleted file mode 100644 index a062973d8..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/SlabGuide.java +++ /dev/null @@ -1,48 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import net.minecraft.block.BlockState; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.enums.SlabType; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; - -import java.util.Arrays; -import java.util.List; - -public class SlabGuide extends GeneralPlacementGuide { - public SlabGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - return Arrays.stream(Direction.values()) - .filter(d -> d != (getRequiredHalf(state).getOpposite()) && - getProperty(state.offset(d).currentState, SlabBlock.TYPE).orElse(SlabType.DOUBLE) == SlabType.DOUBLE) - .toList(); - } - - @Override - protected Vec3d getHitModifier(Direction validSide) { - Direction requiredHalf = getRequiredHalf(state); - if (validSide.getHorizontal() != -1) { - return new Vec3d(0, requiredHalf.getOffsetY() * 0.25, 0); - } else { - return new Vec3d(0, 0, 0); - } - } - - private Direction getRequiredHalf(SchematicBlockState state) { - BlockState targetState = state.targetState; - BlockState currentState = state.currentState; - - if (!currentState.contains(SlabBlock.TYPE)) { - return targetState.get(SlabBlock.TYPE) == SlabType.TOP ? Direction.UP : Direction.DOWN; - } else if (currentState.get(SlabBlock.TYPE) != targetState.get(SlabBlock.TYPE)) { - return currentState.get(SlabBlock.TYPE) == SlabType.TOP ? Direction.DOWN : Direction.UP; - } else { - return Direction.DOWN; - } - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/TorchGuide.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/TorchGuide.java deleted file mode 100644 index bd5d37df2..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/guides/placement/TorchGuide.java +++ /dev/null @@ -1,31 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.guides.placement; - -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import net.minecraft.block.Block; -import net.minecraft.block.HorizontalFacingBlock; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.math.Direction; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -public class TorchGuide extends GeneralPlacementGuide { - public TorchGuide(SchematicBlockState state) { - super(state); - } - - @Override - protected List getPossibleSides() { - Optional facing = getProperty(targetState, HorizontalFacingBlock.FACING); - - return facing - .map(direction -> Collections.singletonList(direction.getOpposite())) - .orElseGet(() -> Collections.singletonList(Direction.DOWN)); - } - - @Override - protected Optional getRequiredItemAsBlock(ClientPlayerEntity player) { - return Optional.of(state.targetState.getBlock()); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/implementation/BlockHelperImpl.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/implementation/BlockHelperImpl.java deleted file mode 100644 index 28cc06f2a..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/implementation/BlockHelperImpl.java +++ /dev/null @@ -1,14 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.implementation; - -import me.aleksilassila.litematica.printer.v1_20_4.BlockHelper; -import net.minecraft.block.ButtonBlock; - -import java.util.Arrays; - -public class BlockHelperImpl extends BlockHelper { - static { - interactiveBlocks.addAll(Arrays.asList( - ButtonBlock.class - )); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/implementation/PrinterPlacementContext.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/implementation/PrinterPlacementContext.java deleted file mode 100644 index cea7d344e..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/implementation/PrinterPlacementContext.java +++ /dev/null @@ -1,59 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.implementation; - -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemPlacementContext; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; -import net.minecraft.util.math.Direction; -import org.jetbrains.annotations.Nullable; - -public class PrinterPlacementContext extends ItemPlacementContext { - public final @Nullable Direction lookDirection; - public final boolean shouldSneak; - public final BlockHitResult hitResult; - public final int requiredItemSlot; - - public PrinterPlacementContext(PlayerEntity player, BlockHitResult hitResult, ItemStack requiredItem, int requiredItemSlot) { - this(player, hitResult, requiredItem, requiredItemSlot, null, false); - } - - public PrinterPlacementContext(PlayerEntity player, BlockHitResult hitResult, ItemStack requiredItem, int requiredItemSlot, @Nullable Direction lookDirection, boolean requiresSneaking) { - super(player, Hand.MAIN_HAND, requiredItem, hitResult); - - this.lookDirection = lookDirection; - this.shouldSneak = requiresSneaking; - this.hitResult = hitResult; - this.requiredItemSlot = requiredItemSlot; - } - - @Override - public Direction getPlayerLookDirection() { - return lookDirection == null ? super.getPlayerLookDirection() : lookDirection; - } - - @Override - public Direction getVerticalPlayerLookDirection() { - if (lookDirection != null && lookDirection.getOpposite() == super.getVerticalPlayerLookDirection()) - return lookDirection; - return super.getVerticalPlayerLookDirection(); - } - - @Override - public Direction getHorizontalPlayerFacing() { - if (lookDirection == null || !lookDirection.getAxis().isHorizontal()) return super.getHorizontalPlayerFacing(); - - return lookDirection; - } - - @Override - public String toString() { - return "PrinterPlacementContext{" + - "lookDirection=" + lookDirection + - ", requiresSneaking=" + shouldSneak + - ", blockPos=" + hitResult.getBlockPos() + - ", side=" + hitResult.getSide() + -// ", hitVec=" + hitResult + - '}'; - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/implementation/actions/InteractActionImpl.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/implementation/actions/InteractActionImpl.java deleted file mode 100644 index 7028e84bf..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/implementation/actions/InteractActionImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.implementation.actions; - -import me.aleksilassila.litematica.printer.v1_20_4.implementation.PrinterPlacementContext; -import me.aleksilassila.litematica.printer.v1_20_4.actions.InteractAction; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; - -public class InteractActionImpl extends InteractAction { - public InteractActionImpl(PrinterPlacementContext context) { - super(context); - } - - @Override - protected void interact(MinecraftClient client, ClientPlayerEntity player, Hand hand, BlockHitResult hitResult) { - client.interactionManager.interactBlock(player, hand, hitResult); - client.interactionManager.interactItem(player, hand); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/implementation/mixin/MixinClientPlayerEntity.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/implementation/mixin/MixinClientPlayerEntity.java deleted file mode 100644 index 837020c6f..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/implementation/mixin/MixinClientPlayerEntity.java +++ /dev/null @@ -1,102 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.implementation.mixin; - -import com.mojang.authlib.GameProfile; -import fi.dy.masa.litematica.world.SchematicWorldHandler; -import fi.dy.masa.litematica.world.WorldSchematic; -import me.aleksilassila.litematica.printer.v1_20_4.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_20_4.Printer; -import me.aleksilassila.litematica.printer.v1_20_4.SchematicBlockState; -import me.aleksilassila.litematica.printer.v1_20_4.UpdateChecker; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.block.entity.SignBlockEntity; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.AbstractClientPlayerEntity; -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket; -import net.minecraft.text.Text; -import org.spongepowered.asm.mixin.Mixin; -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; - -import java.util.Optional; - -@Mixin(ClientPlayerEntity.class) -public class MixinClientPlayerEntity extends AbstractClientPlayerEntity { - - private static boolean didCheckForUpdates = false; - - @Shadow - protected MinecraftClient client; - @Shadow - public ClientPlayNetworkHandler networkHandler; - - public MixinClientPlayerEntity(ClientWorld world, GameProfile profile) { - super(world, profile); - } - - @Inject(at = @At("TAIL"), method = "tick") - public void tick(CallbackInfo ci) { - ClientPlayerEntity clientPlayer = (ClientPlayerEntity) (Object) this; - if (!didCheckForUpdates) { - didCheckForUpdates = true; - - checkForUpdates(); - } - - if (LitematicaMixinMod.printer == null || LitematicaMixinMod.printer.player != clientPlayer) { - System.out.println("Initializing printer, player: " + clientPlayer + ", client: " + client); - LitematicaMixinMod.printer = new Printer(client, clientPlayer); - } - - // Dirty optimization - boolean didFindPlacement = true; - for (int i = 0; i < 10; i++) { - if (didFindPlacement) { - didFindPlacement = LitematicaMixinMod.printer.onGameTick(); - } - LitematicaMixinMod.printer.actionHandler.onGameTick(); - } - } - - public void checkForUpdates() { - new Thread(() -> { - String version = UpdateChecker.version; - String newVersion = UpdateChecker.getPrinterVersion(); - - if (!version.equals(newVersion)) { - client.inGameHud.getChatHud().addMessage(Text.literal("New version of Litematica Printer available in https://github.com/aleksilassila/litematica-printer/releases")); - } - }).start(); - } - - @Inject(method = "openEditSignScreen", at = @At("HEAD"), cancellable = true) - public void openEditSignScreen(SignBlockEntity sign, boolean front, CallbackInfo ci) { - getTargetSignEntity(sign).ifPresent(signBlockEntity -> { - UpdateSignC2SPacket packet = new UpdateSignC2SPacket(sign.getPos(), - front, - signBlockEntity.getText(front).getMessage(0, false).getString(), - signBlockEntity.getText(front).getMessage(1, false).getString(), - signBlockEntity.getText(front).getMessage(2, false).getString(), - signBlockEntity.getText(front).getMessage(3, false).getString()); - this.networkHandler.sendPacket(packet); - ci.cancel(); - }); - } - - private Optional getTargetSignEntity(SignBlockEntity sign) { - WorldSchematic worldSchematic = SchematicWorldHandler.getSchematicWorld(); - SchematicBlockState state = new SchematicBlockState(sign.getWorld(), worldSchematic, sign.getPos()); - - BlockEntity targetBlockEntity = worldSchematic.getBlockEntity(state.blockPos); - - if (targetBlockEntity instanceof SignBlockEntity targetSignEntity) { - return Optional.of(targetSignEntity); - } - - return Optional.empty(); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/mixin/AxeItemAccessor.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/mixin/AxeItemAccessor.java deleted file mode 100644 index 8f86d138e..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/mixin/AxeItemAccessor.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.mixin; - -import net.minecraft.block.Block; -import net.minecraft.item.AxeItem; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.util.Map; - -/** - * This class apparently fixes an issue with Quilt. - */ -@Mixin(AxeItem.class) -public interface AxeItemAccessor { - @Accessor("STRIPPED_BLOCKS") - static Map getStrippedBlocks() { - throw new AssertionError("Untransformed @Accessor"); - } - -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/mixin/ConfigsMixin.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/mixin/ConfigsMixin.java deleted file mode 100644 index b97d301d2..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/mixin/ConfigsMixin.java +++ /dev/null @@ -1,35 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.mixin; - -import com.google.common.collect.ImmutableList; -import fi.dy.masa.litematica.config.Configs; -import fi.dy.masa.malilib.config.IConfigBase; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import me.aleksilassila.litematica.printer.v1_20_4.LitematicaMixinMod; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.List; - -@Mixin(value = Configs.class, remap = false) -public class ConfigsMixin { - @Redirect(method = "loadFromFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Configs$Generic;OPTIONS:Lcom/google/common/collect/ImmutableList;")) - private static ImmutableList moreOptions() { - return LitematicaMixinMod.getConfigList(); - } - - @Redirect(method = "saveToFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Configs$Generic;OPTIONS:Lcom/google/common/collect/ImmutableList;")) - private static ImmutableList moreeOptions() { - return LitematicaMixinMod.getConfigList(); - } - - @Redirect(method = "loadFromFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private static List moreHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } - - @Redirect(method = "saveToFile", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private static List moreeHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/mixin/GuiConfigsMixin.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/mixin/GuiConfigsMixin.java deleted file mode 100644 index 91ea26d0f..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/mixin/GuiConfigsMixin.java +++ /dev/null @@ -1,61 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.mixin; - -import com.google.common.collect.ImmutableList; -import fi.dy.masa.litematica.gui.GuiConfigs; -import fi.dy.masa.malilib.config.IConfigBase; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import me.aleksilassila.litematica.printer.v1_20_4.LitematicaMixinMod; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.List; - -@Mixin(value = GuiConfigs.class, remap = false) -public class GuiConfigsMixin { - - /*@Overwrite - public List getConfigs() - { - List configs; - ConfigGuiTab tab = DataManager.getConfigGuiTab(); - - if (tab == ConfigGuiTab.GENERIC) - { - configs = LitematicaMixinMod.betterConfigList; - } - else if (tab == ConfigGuiTab.INFO_OVERLAYS) - { - configs = Configs.InfoOverlays.OPTIONS; - } - else if (tab == ConfigGuiTab.VISUALS) - { - configs = Configs.Visuals.OPTIONS; - } - else if (tab == ConfigGuiTab.COLORS) - { - configs = Configs.Colors.OPTIONS; - } - else if (tab == ConfigGuiTab.HOTKEYS) - { - configs = LitematicaMixinMod.betterHotkeyList; - } - else - { - return Collections.emptyList(); - } - - return ConfigOptionWrapper.createFor(configs); - }*/ - - - @Redirect(method = "getConfigs", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Configs$Generic;OPTIONS:Lcom/google/common/collect/ImmutableList;")) - private ImmutableList moreOptions() { - return LitematicaMixinMod.getConfigList(); - } - - @Redirect(method = "getConfigs", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private List moreHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/mixin/InputHandlerMixin.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/mixin/InputHandlerMixin.java deleted file mode 100644 index 1f269c67a..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/mixin/InputHandlerMixin.java +++ /dev/null @@ -1,25 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.mixin; - -import fi.dy.masa.litematica.event.InputHandler; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import me.aleksilassila.litematica.printer.v1_20_4.LitematicaMixinMod; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.List; - -@Mixin(value = InputHandler.class, remap = false) -public class InputHandlerMixin { - - @Redirect(method = "addHotkeys", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private List moreHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } - - @Redirect(method = "addKeysToMap", at = @At(value = "FIELD", target = "Lfi/dy/masa/litematica/config/Hotkeys;HOTKEY_LIST:Ljava/util/List;")) - private List moreeHotkeys() { - return LitematicaMixinMod.getHotkeyList(); - } - -} diff --git a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/mixin/PlayerMoveC2SPacketMixin.java b/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/mixin/PlayerMoveC2SPacketMixin.java deleted file mode 100644 index d078e89ac..000000000 --- a/v1_20_4/src/main/java/me/aleksilassila/litematica/printer/v1_20_4/mixin/PlayerMoveC2SPacketMixin.java +++ /dev/null @@ -1,36 +0,0 @@ -package me.aleksilassila.litematica.printer.v1_20_4.mixin; - -import me.aleksilassila.litematica.printer.v1_20_4.LitematicaMixinMod; -import me.aleksilassila.litematica.printer.v1_20_4.Printer; -import me.aleksilassila.litematica.printer.v1_20_4.actions.PrepareAction; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; - -@Mixin(PlayerMoveC2SPacket.class) -public class PlayerMoveC2SPacketMixin { - @ModifyVariable(method = "(DDDFFZZZ)V", at = @At("HEAD"), ordinal = 0) - private static float modifyLookYaw(float yaw) { - Printer printer = LitematicaMixinMod.printer; - if (printer == null) return yaw; - - PrepareAction action = printer.actionHandler.lookAction; - if (action != null && action.modifyYaw) { - if (LitematicaMixinMod.DEBUG) System.out.println("YAW: " + action.yaw); - return action.yaw; - } else return yaw; - } - - @ModifyVariable(method = "(DDDFFZZZ)V", at = @At("HEAD"), ordinal = 1) - private static float modifyLookPitch(float pitch) { - Printer printer = LitematicaMixinMod.printer; - if (printer == null) return pitch; - - PrepareAction action = printer.actionHandler.lookAction; - if (action != null && action.modifyPitch) { - if (LitematicaMixinMod.DEBUG) System.out.println("PITCH: " + action.pitch); - return action.pitch; - } else return pitch; - } -} diff --git a/v1_20_4/src/main/resources/assets/modid/icon.png b/v1_20_4/src/main/resources/assets/modid/icon.png deleted file mode 100644 index 047b91f2347de5cf95f23284476fddbe21ba23fe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 453 zcmV;$0XqJPP)QAFYGys`80vegN0XDFh0OXKz&i8?Le#x7{1X)R+00000NkvXXu0mjf73i~T diff --git a/v1_20_4/src/main/resources/fabric.mod.json b/v1_20_4/src/main/resources/fabric.mod.json deleted file mode 100644 index b5a506957..000000000 --- a/v1_20_4/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "schemaVersion": 1, - "id": "litematica_printer", - "version": "${version}", - "name": "Litematica Printer", - "description": "A fork of Litematica that adds the missing printer functionality", - "authors": [ - "aleksilassila" - ], - "contact": { - "homepage": "https://github.com/aleksilassila/litematica-printer", - "sources": "https://github.com/aleksilassila/litematica-printer" - }, - "license": "CC0-1.0", - "icon": "assets/modid/icon.png", - "environment": "*", - "entrypoints": { - "main": [ - "me.aleksilassila.litematica.printer.v1_20_4.LitematicaMixinMod" - ] - }, - "mixins": [ - "litematica-printer.mixins.json", - "litematica-printer-implementation.mixins.json" - ], - "depends": { - "fabricloader": ">=0.14.7", - "fabric": "*", - "minecraft": ">=1.20.3", - "java": ">=17" - }, - "custom": { - "modmenu": { - "parent": "carpet" - } - } -} - diff --git a/v1_20_4/src/main/resources/litematica-printer-implementation.mixins.json b/v1_20_4/src/main/resources/litematica-printer-implementation.mixins.json deleted file mode 100644 index f9edeb46d..000000000 --- a/v1_20_4/src/main/resources/litematica-printer-implementation.mixins.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "me.aleksilassila.litematica.printer.v1_20_4.implementation.mixin", - "compatibilityLevel": "JAVA_16", - "mixins": [ - ], - "client": [ - "MixinClientPlayerEntity" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/v1_20_4/src/main/resources/litematica-printer.mixins.json b/v1_20_4/src/main/resources/litematica-printer.mixins.json deleted file mode 100644 index d63dd6c33..000000000 --- a/v1_20_4/src/main/resources/litematica-printer.mixins.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "me.aleksilassila.litematica.printer.v1_20_4.mixin", - "compatibilityLevel": "JAVA_16", - "mixins": [ - ], - "client": [ - "ConfigsMixin", - "GuiConfigsMixin", - "InputHandlerMixin", - "PlayerMoveC2SPacketMixin", - "AxeItemAccessor" - ], - "injectors": { - "defaultRequire": 1 - } -}