From 5d2bbc930b6b48d91e9a8b635e40272be88d5685 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Wed, 4 Mar 2020 14:06:34 +0100 Subject: [PATCH] Minor refactors & Generic blockzapper - Finished builder pattern refactor in AllShapes - Generalized some blockzapper code for its upcoming cousin --- .../java/com/simibubi/create/AllItems.java | 2 +- .../java/com/simibubi/create/AllPackets.java | 2 +- .../java/com/simibubi/create/AllRecipes.java | 2 +- .../category/BlockzapperUpgradeCategory.java | 2 +- .../simibubi/create/config/CCuriosities.java | 17 ++-- .../create/foundation/utility/AllShapes.java | 75 +++++++---------- .../components/actors/DrillBlock.java | 2 +- .../components/deployer/DeployerBlock.java | 2 +- .../mixer/MechanicalMixerBlock.java | 3 +- .../press/MechanicalPressBlock.java | 2 +- .../contraptions/components/saw/SawBlock.java | 2 +- .../contraptions/relays/belt/BeltShapes.java | 6 +- .../modules/curiosities/zapper/ZapLog.java | 63 +++++++++++++++ .../curiosities/zapper/ZapperItem.java | 80 +++++++++++++++++++ .../blockzapper/BlockzapperBeamPacket.java | 4 +- .../blockzapper/BlockzapperHandler.java | 2 +- .../blockzapper/BlockzapperItem.java | 65 ++++----------- .../blockzapper/BlockzapperItemRenderer.java | 16 ++-- .../blockzapper/BlockzapperModel.java | 4 +- .../blockzapper/BlockzapperScreen.java | 2 +- .../blockzapper/BlockzapperUpgradeRecipe.java | 6 +- .../blockzapper/PlacementPatterns.java | 2 +- .../zapper/terrainzapper/CylinderBrush.java | 51 ++++++++++++ .../zapper/terrainzapper/SphereBrush.java | 46 +++++++++++ .../terrainzapper/TerrainZapperItem.java | 24 ++++++ .../resources/assets/create/lang/en_us.json | 28 ++++--- 26 files changed, 364 insertions(+), 146 deletions(-) create mode 100644 src/main/java/com/simibubi/create/modules/curiosities/zapper/ZapLog.java create mode 100644 src/main/java/com/simibubi/create/modules/curiosities/zapper/ZapperItem.java rename src/main/java/com/simibubi/create/modules/curiosities/{ => zapper}/blockzapper/BlockzapperBeamPacket.java (92%) rename src/main/java/com/simibubi/create/modules/curiosities/{ => zapper}/blockzapper/BlockzapperHandler.java (99%) rename src/main/java/com/simibubi/create/modules/curiosities/{ => zapper}/blockzapper/BlockzapperItem.java (91%) rename src/main/java/com/simibubi/create/modules/curiosities/{ => zapper}/blockzapper/BlockzapperItemRenderer.java (84%) rename src/main/java/com/simibubi/create/modules/curiosities/{ => zapper}/blockzapper/BlockzapperModel.java (86%) rename src/main/java/com/simibubi/create/modules/curiosities/{ => zapper}/blockzapper/BlockzapperScreen.java (99%) rename src/main/java/com/simibubi/create/modules/curiosities/{ => zapper}/blockzapper/BlockzapperUpgradeRecipe.java (93%) rename src/main/java/com/simibubi/create/modules/curiosities/{ => zapper}/blockzapper/PlacementPatterns.java (90%) create mode 100644 src/main/java/com/simibubi/create/modules/curiosities/zapper/terrainzapper/CylinderBrush.java create mode 100644 src/main/java/com/simibubi/create/modules/curiosities/zapper/terrainzapper/SphereBrush.java create mode 100644 src/main/java/com/simibubi/create/modules/curiosities/zapper/terrainzapper/TerrainZapperItem.java diff --git a/src/main/java/com/simibubi/create/AllItems.java b/src/main/java/com/simibubi/create/AllItems.java index 9209050bc..1398cdb5d 100644 --- a/src/main/java/com/simibubi/create/AllItems.java +++ b/src/main/java/com/simibubi/create/AllItems.java @@ -13,10 +13,10 @@ import com.simibubi.create.modules.contraptions.relays.gearbox.VerticalGearboxIt import com.simibubi.create.modules.curiosities.ChromaticCompoundCubeItem; import com.simibubi.create.modules.curiosities.RefinedRadianceItem; import com.simibubi.create.modules.curiosities.ShadowSteelItem; -import com.simibubi.create.modules.curiosities.blockzapper.BlockzapperItem; import com.simibubi.create.modules.curiosities.deforester.DeforesterItem; import com.simibubi.create.modules.curiosities.symmetry.SymmetryWandItem; import com.simibubi.create.modules.curiosities.tools.SandPaperItem; +import com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperItem; import com.simibubi.create.modules.gardens.TreeFertilizerItem; import com.simibubi.create.modules.logistics.item.filter.FilterItem; import com.simibubi.create.modules.schematics.item.SchematicAndQuillItem; diff --git a/src/main/java/com/simibubi/create/AllPackets.java b/src/main/java/com/simibubi/create/AllPackets.java index f8822fffa..6a0d021ec 100644 --- a/src/main/java/com/simibubi/create/AllPackets.java +++ b/src/main/java/com/simibubi/create/AllPackets.java @@ -11,8 +11,8 @@ import com.simibubi.create.foundation.packet.NbtPacket; import com.simibubi.create.foundation.packet.SimplePacketBase; import com.simibubi.create.foundation.utility.ServerSpeedProvider; import com.simibubi.create.modules.contraptions.components.contraptions.ContraptionStallPacket; -import com.simibubi.create.modules.curiosities.blockzapper.BlockzapperBeamPacket; import com.simibubi.create.modules.curiosities.symmetry.SymmetryEffectPacket; +import com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperBeamPacket; import com.simibubi.create.modules.logistics.item.filter.FilterScreenPacket; import com.simibubi.create.modules.logistics.packet.ConfigureFlexcratePacket; import com.simibubi.create.modules.logistics.packet.ConfigureStockswitchPacket; diff --git a/src/main/java/com/simibubi/create/AllRecipes.java b/src/main/java/com/simibubi/create/AllRecipes.java index 9ee40f860..fea4f12fc 100644 --- a/src/main/java/com/simibubi/create/AllRecipes.java +++ b/src/main/java/com/simibubi/create/AllRecipes.java @@ -13,8 +13,8 @@ import com.simibubi.create.modules.contraptions.components.saw.CuttingRecipe; import com.simibubi.create.modules.contraptions.processing.ProcessingRecipe; import com.simibubi.create.modules.contraptions.processing.ProcessingRecipeSerializer; import com.simibubi.create.modules.contraptions.processing.ProcessingRecipeSerializer.IRecipeFactory; -import com.simibubi.create.modules.curiosities.blockzapper.BlockzapperUpgradeRecipe; import com.simibubi.create.modules.curiosities.tools.SandPaperPolishingRecipe; +import com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperUpgradeRecipe; import net.minecraft.inventory.IInventory; import net.minecraft.item.crafting.IRecipe; diff --git a/src/main/java/com/simibubi/create/compat/jei/category/BlockzapperUpgradeCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/BlockzapperUpgradeCategory.java index 6bdc827f0..783d14774 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/BlockzapperUpgradeCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/BlockzapperUpgradeCategory.java @@ -14,7 +14,7 @@ import com.simibubi.create.compat.jei.DoubleItemIcon; import com.simibubi.create.compat.jei.ScreenResourceWrapper; import com.simibubi.create.foundation.gui.ScreenElementRenderer; import com.simibubi.create.foundation.utility.Lang; -import com.simibubi.create.modules.curiosities.blockzapper.BlockzapperUpgradeRecipe; +import com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperUpgradeRecipe; import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; diff --git a/src/main/java/com/simibubi/create/config/CCuriosities.java b/src/main/java/com/simibubi/create/config/CCuriosities.java index 90928dff2..a4d4ebea5 100644 --- a/src/main/java/com/simibubi/create/config/CCuriosities.java +++ b/src/main/java/com/simibubi/create/config/CCuriosities.java @@ -3,12 +3,13 @@ package com.simibubi.create.config; public class CCuriosities extends ConfigBase { public ConfigInt maxSymmetryWandRange = i(50, 10, "maxSymmetryWandRange", Comments.symmetryRange); - public ConfigInt lightSourceCountForRefinedRadiance = - i(10, 1, "lightSourceCountForRefinedRadiance", Comments.refinedRadiance); - public ConfigBool allowGlassPanesInPartialBlocks = - b(true, "allowGlassPanesInPartialBlocks", Comments.windowsInBlocks); - public ConfigBool enableRefinedRadianceRecipe = - b(true, "enableRefinedRadianceRecipe", Comments.refinedRadianceRecipe); + public ConfigInt zapperUndoLogLength = i(10, 0, "zapperUndoLogLength", Comments.zapperUndoLogLength); + public ConfigInt lightSourceCountForRefinedRadiance = i(10, 1, "lightSourceCountForRefinedRadiance", + Comments.refinedRadiance); + public ConfigBool allowGlassPanesInPartialBlocks = b(true, "allowGlassPanesInPartialBlocks", + Comments.windowsInBlocks); + public ConfigBool enableRefinedRadianceRecipe = b(true, "enableRefinedRadianceRecipe", + Comments.refinedRadianceRecipe); public ConfigBool enableShadowSteelRecipe = b(true, "enableShadowSteelRecipe", Comments.shadowSteelRecipe); public ConfigBool enableSandPaperToolPolishing = b(true, "enableSandPaperToolPolishing", Comments.sandPaperOnTools); public ConfigFloat cocoaLogGrowthSpeed = f(20, 0, 100, "cocoaLogGrowthSpeed", Comments.cocoa); @@ -20,13 +21,13 @@ public class CCuriosities extends ConfigBase { private static class Comments { static String symmetryRange = "The Maximum Distance to an active mirror for the symmetry wand to trigger."; - static String refinedRadiance = - "The amount of Light sources destroyed before Chromatic Compound turns into Refined Radiance."; + static String refinedRadiance = "The amount of Light sources destroyed before Chromatic Compound turns into Refined Radiance."; static String refinedRadianceRecipe = "Allow the standard Refined Radiance recipes."; static String shadowSteelRecipe = "Allow the standard Shadow Steel recipe."; static String sandPaperOnTools = "Enable the tool repairing mechanic involving sand paper."; static String windowsInBlocks = "Allow Glass Panes to be put inside Blocks like Stairs, Slabs, Fences etc."; static String cocoa = "% of random Ticks causing a Cocoa log to grow."; + static String zapperUndoLogLength = "The maximum amount of operations, a blockzapper can remember for undoing. (0 to disable undo)"; } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/AllShapes.java b/src/main/java/com/simibubi/create/foundation/utility/AllShapes.java index 6ec5d6b4a..c0ac78e51 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/AllShapes.java +++ b/src/main/java/com/simibubi/create/foundation/utility/AllShapes.java @@ -1,6 +1,5 @@ package com.simibubi.create.foundation.utility; -import static net.minecraft.block.Block.makeCuboidShape; import static net.minecraft.util.Direction.EAST; import static net.minecraft.util.Direction.SOUTH; import static net.minecraft.util.Direction.UP; @@ -22,9 +21,9 @@ public class AllShapes { // Independent Shapers public static final VoxelShaper - SHORT_CASING_14_VOXEL = shape(0, 0, 0, 16, 14, 16).forDirectional(), - SHORT_CASING_12_VOXEL = shape(0, 0, 0, 16, 12, 16).forDirectional(), - SHORT_CASING_11_VOXEL = shape(0, 0, 0, 16, 11, 16).forDirectional(), + CASING_14PX = shape(0, 0, 0, 16, 14, 16).forDirectional(), + CASING_12PX = shape(0, 0, 0, 16, 12, 16).forDirectional(), + CASING_11PX = shape(0, 0, 0, 16, 11, 16).forDirectional(), MOTOR_BLOCK = shape(0, 3, 3, 16, 13, 13).forHorizontal(EAST), FOUR_VOXEL_POLE = shape(6, 0, 6, 10, 16, 10).forAxis(), SIX_VOXEL_POLE = shape(5, 0, 5, 11, 16, 11).forAxis(), @@ -39,30 +38,10 @@ public class AllShapes { PULLEY = shape(0, 0, 0, 16, 16, 2).add(1, 1, 2, 15, 15, 14).add(0, 0, 14, 16, 16, 16).forHorizontalAxis(), SPEED_CONTROLLER = shape(0, 0, 0, 16, 2, 16).add(1, 1, 1, 15, 15, 15).erase(0, 8, 5, 16, 16, 11) .add(2, 9, 2, 14, 14, 14).erase(6, 11, 0, 10, 16, 16).forHorizontalAxis(), - HARVESTER_BASE = shape(0, 2, 0, 16, 14, 3).forDirectional(SOUTH) - - ; - - // Internally Shared Shapes (TODO: Use builder pattern) - private static final VoxelShape - - CART_ASSEMBLER_SHAPE = VoxelShapes.or(VoxelShapes.fullCube(), makeCuboidShape(-2, 0, 1, 18, 13, 15)), - MECHANICAL_PISTON_HEAD_SHAPE_UP = Blocks.PISTON_HEAD.getStateContainer().getBaseState() - .with(DirectionalBlock.FACING, UP).with(PistonHeadBlock.SHORT, true).getShape(null, null), - MECHANICAL_PISTON_EXTENDED_SHAPE_UP = VoxelShapes.or(SHORT_CASING_12_VOXEL.get(UP), - FOUR_VOXEL_POLE.get(Direction.Axis.Y)), - SMALL_GEAR_SHAPE = makeCuboidShape(2, 6, 2, 14, 10, 14), - LARGE_GEAR_SHAPE = makeCuboidShape(0, 6, 0, 16, 10, 16), - VERTICAL_TABLET_SHAPE_SOUTH = makeCuboidShape(3, 1, -1, 13, 15, 3), - SQUARE_TABLET_SHAPE_SOUTH = makeCuboidShape(2, 2, -1, 14, 14, 3), - LOGISTICS_TABLE_SLOPE_SOUTH = VoxelShapes.or(makeCuboidShape(0, 10D, 15, 16, 14, 10.667), - makeCuboidShape(0, 12, 10.667, 16, 16, 6.333), makeCuboidShape(0, 14, 6.333, 16, 18, 2)), - SCHEMATICS_TABLE_SLOPE_SOUTH = VoxelShapes.or(makeCuboidShape(0, 10, 16, 16, 14, 11), - makeCuboidShape(0, 12, 11, 16, 16, 6), makeCuboidShape(0, 14, 6, 16, 18, 1)), - NOZZLE_SHAPE_UP = VoxelShapes.or(makeCuboidShape(2, 0, 2, 14, 14, 14), - VoxelShapes.combine(makeCuboidShape(1, 13, 1, 15, 15, 15), makeCuboidShape(3, 13, 3, 13, 15, 13), - IBooleanFunction.ONLY_FIRST)), - CRANK_SHAPE_UP = VoxelShapes.or(makeCuboidShape(5, 0, 5, 11, 6, 11), makeCuboidShape(1, 3, 1, 15, 8, 15)) + HARVESTER_BASE = shape(0, 2, 0, 16, 14, 3).forDirectional(SOUTH), + NOZZLE = shape(2, 0, 2, 14, 14, 14).add(1, 13, 1, 15, 15, 15).erase(3, 13, 3, 13, 15, 13).forDirectional(), + CRANK = shape(5, 0, 5, 11, 6, 11).add(1, 3, 1, 15, 8, 15).forDirectional(), + CART_ASSEMBLER = shape(VoxelShapes.fullCube()).add(-2, 0, 1, 18, 13, 15).forHorizontalAxis() ; @@ -82,25 +61,33 @@ public class AllShapes { ; - // Advanced Shapers (TODO: Use builder pattern) + // Internally Shared Shapes + private static final VoxelShape + + PISTON_HEAD = Blocks.PISTON_HEAD.getDefaultState().with(DirectionalBlock.FACING, UP) + .with(PistonHeadBlock.SHORT, true).getShape(null, null), + PISTON_EXTENDED = shape(CASING_12PX.get(UP)).add(FOUR_VOXEL_POLE.get(Axis.Y)).build(), + SMALL_GEAR_SHAPE = cuboid(2, 6, 2, 14, 10, 14), LARGE_GEAR_SHAPE = cuboid(0, 6, 0, 16, 10, 16), + VERTICAL_TABLET_SHAPE = cuboid(3, 1, -1, 13, 15, 3), SQUARE_TABLET_SHAPE = cuboid(2, 2, -1, 14, 14, 3), + LOGISTICS_TABLE_SLOPE = shape(0, 10, 15, 16, 14, 10.667).add(0, 12, 10.667, 16, 16, 6.333) + .add(0, 14, 6.333, 16, 18, 2).build(), + SCHEMATICS_TABLE_SLOPE = shape(0, 10, 16, 16, 14, 11).add(0, 12, 11, 16, 16, 6).add(0, 14, 6, 16, 18, 1) + .build() + + ; + + // More Shapers public static final VoxelShaper - NOZZLE = VoxelShaper.forDirectional(NOZZLE_SHAPE_UP, UP), CRANK = VoxelShaper.forDirectional(CRANK_SHAPE_UP, UP), - CART_ASSEMBLER = VoxelShaper.forHorizontalAxis(CART_ASSEMBLER_SHAPE, Axis.Z), - MECHANICAL_PISTON_HEAD = VoxelShaper.forDirectional(MECHANICAL_PISTON_HEAD_SHAPE_UP, UP), - MECHANICAL_PISTON = SHORT_CASING_12_VOXEL, - MECHANICAL_PISTON_EXTENDED = VoxelShaper.forDirectional(MECHANICAL_PISTON_EXTENDED_SHAPE_UP, UP), - SMALL_GEAR = VoxelShaper.forAxis(VoxelShapes.or(SMALL_GEAR_SHAPE, SIX_VOXEL_POLE.get(Direction.Axis.Y)), - Direction.Axis.Y), - LARGE_GEAR = VoxelShaper.forAxis(VoxelShapes.or(LARGE_GEAR_SHAPE, SIX_VOXEL_POLE.get(Direction.Axis.Y)), - Direction.Axis.Y), - LOGISTICAL_CONTROLLER = VoxelShaper.forDirectional(SQUARE_TABLET_SHAPE_SOUTH, SOUTH), - REDSTONE_BRIDGE = VoxelShaper.forHorizontal(VERTICAL_TABLET_SHAPE_SOUTH, SOUTH) + MECHANICAL_PISTON_HEAD = shape(PISTON_HEAD).forDirectional(), MECHANICAL_PISTON = CASING_12PX, + MECHANICAL_PISTON_EXTENDED = shape(PISTON_EXTENDED).forDirectional(), + SMALL_GEAR = shape(SMALL_GEAR_SHAPE).add(SIX_VOXEL_POLE.get(Axis.Y)).forAxis(), + LARGE_GEAR = shape(LARGE_GEAR_SHAPE).add(SIX_VOXEL_POLE.get(Axis.Y)).forAxis(), + LOGISTICAL_CONTROLLER = shape(SQUARE_TABLET_SHAPE).forDirectional(SOUTH), + REDSTONE_BRIDGE = shape(VERTICAL_TABLET_SHAPE).forDirectional(SOUTH) .withVerticalShapes(LOGISTICAL_CONTROLLER.get(UP)), - LOGISTICS_TABLE = VoxelShaper.forHorizontal(VoxelShapes.or(TABLE_POLE_SHAPE, LOGISTICS_TABLE_SLOPE_SOUTH), - SOUTH), - SCHEMATICS_TABLE = VoxelShaper - .forDirectional(VoxelShapes.or(TABLE_POLE_SHAPE, SCHEMATICS_TABLE_SLOPE_SOUTH), SOUTH) + LOGISTICS_TABLE = shape(TABLE_POLE_SHAPE).add(LOGISTICS_TABLE_SLOPE).forHorizontal(SOUTH), + SCHEMATICS_TABLE = shape(TABLE_POLE_SHAPE).add(SCHEMATICS_TABLE_SLOPE).forDirectional(SOUTH) ; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/actors/DrillBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/actors/DrillBlock.java index 43d4e918f..ac683e60b 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/actors/DrillBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/actors/DrillBlock.java @@ -40,7 +40,7 @@ public class DrillBlock extends DirectionalKineticBlock implements IPortableBloc @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return AllShapes.SHORT_CASING_12_VOXEL.get(state.get(FACING)); + return AllShapes.CASING_12PX.get(state.get(FACING)); } @Override diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerBlock.java index 26627a54f..ef2617b3e 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerBlock.java @@ -49,7 +49,7 @@ public class DeployerBlock extends DirectionalAxisKineticBlock @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return AllShapes.SHORT_CASING_12_VOXEL.get(state.get(FACING)); + return AllShapes.CASING_12PX.get(state.get(FACING)); } @Override diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/MechanicalMixerBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/MechanicalMixerBlock.java index d4c979e7a..cd1985525 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/MechanicalMixerBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/MechanicalMixerBlock.java @@ -23,7 +23,6 @@ import net.minecraft.world.IWorldReader; public class MechanicalMixerBlock extends KineticBlock implements IWithTileEntity, IHaveCustomBlockItem { - public MechanicalMixerBlock() { super(Properties.from(Blocks.ANDESITE)); } @@ -46,7 +45,7 @@ public class MechanicalMixerBlock extends KineticBlock @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { if (context.getEntity() instanceof PlayerEntity) - return AllShapes.SHORT_CASING_14_VOXEL.get(Direction.DOWN); + return AllShapes.CASING_14PX.get(Direction.DOWN); return AllShapes.MECHANICAL_PROCESSOR_SHAPE; } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/press/MechanicalPressBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/press/MechanicalPressBlock.java index d4e399bad..8106e87b2 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/press/MechanicalPressBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/press/MechanicalPressBlock.java @@ -48,7 +48,7 @@ public class MechanicalPressBlock extends HorizontalKineticBlock @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { if (context.getEntity() instanceof PlayerEntity) - return AllShapes.SHORT_CASING_14_VOXEL.get(Direction.DOWN); + return AllShapes.CASING_14PX.get(Direction.DOWN); return AllShapes.MECHANICAL_PROCESSOR_SHAPE; } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawBlock.java index 72b272d81..e92e2a19a 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawBlock.java @@ -74,7 +74,7 @@ public class SawBlock extends DirectionalAxisKineticBlock implements IWithTileEn @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return AllShapes.SHORT_CASING_12_VOXEL.get(state.get(FACING)); + return AllShapes.CASING_12PX.get(state.get(FACING)); } @Override diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltShapes.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltShapes.java index bf5de5242..a0a72bbc4 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltShapes.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltShapes.java @@ -181,16 +181,16 @@ public class BeltShapes { return VoxelShapes.empty(); if (slope == Slope.HORIZONTAL) { - return AllShapes.SHORT_CASING_11_VOXEL.get(Direction.UP); + return AllShapes.CASING_11PX.get(Direction.UP); } if (part == Part.MIDDLE || part == Part.PULLEY) return PARTIAL_CASING.get(slope == Slope.UPWARD ? facing : facing.getOpposite()); if (part == Part.START) - return slope == Slope.UPWARD ? AllShapes.SHORT_CASING_11_VOXEL.get(Direction.UP) : PARTIAL_CASING.get(facing.getOpposite()); + return slope == Slope.UPWARD ? AllShapes.CASING_11PX.get(Direction.UP) : PARTIAL_CASING.get(facing.getOpposite()); if (part == Part.END) - return slope == Slope.DOWNWARD ? AllShapes.SHORT_CASING_11_VOXEL.get(Direction.UP) : PARTIAL_CASING.get(facing); + return slope == Slope.DOWNWARD ? AllShapes.CASING_11PX.get(Direction.UP) : PARTIAL_CASING.get(facing); //something went wrong return VoxelShapes.fullCube(); diff --git a/src/main/java/com/simibubi/create/modules/curiosities/zapper/ZapLog.java b/src/main/java/com/simibubi/create/modules/curiosities/zapper/ZapLog.java new file mode 100644 index 000000000..08b4e1969 --- /dev/null +++ b/src/main/java/com/simibubi/create/modules/curiosities/zapper/ZapLog.java @@ -0,0 +1,63 @@ +package com.simibubi.create.modules.curiosities.zapper; + +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Collectors; + +import com.simibubi.create.config.AllConfigs; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.template.Template.BlockInfo; + +public class ZapLog { + + private World activeWorld; + private List> log = new LinkedList<>(); + private int redoIndex; + + /* + * Undo and redo operations applied by tools what information is necessary? + * + * For survival mode: does undo have the required blocks + * + * For creative mode: what data did removed TEs have + * + * When undo: remove added blocks (added -> air) replace replaced blocks (added + * -> before) add removed blocks (air -> before) + * + */ + + public void record(World world, List positions) { + if (maxLogLength() == 0) + return; + if (world != activeWorld) + log.clear(); + activeWorld = world; + + List blocks = positions.stream().map(pos -> { + TileEntity tileEntity = world.getTileEntity(pos); + return new BlockInfo(pos, world.getBlockState(pos), tileEntity == null ? null : tileEntity.serializeNBT()); + }).collect(Collectors.toList()); + + log.add(0, blocks); + redoIndex = 0; + + if (maxLogLength() < log.size()) + log.remove(log.size() - 1); + } + + protected Integer maxLogLength() { + return AllConfigs.SERVER.curiosities.zapperUndoLogLength.get(); + } + + public void undo() { + + } + + public void redo() { + + } + +} diff --git a/src/main/java/com/simibubi/create/modules/curiosities/zapper/ZapperItem.java b/src/main/java/com/simibubi/create/modules/curiosities/zapper/ZapperItem.java new file mode 100644 index 000000000..62421b5ef --- /dev/null +++ b/src/main/java/com/simibubi/create/modules/curiosities/zapper/ZapperItem.java @@ -0,0 +1,80 @@ +package com.simibubi.create.modules.curiosities.zapper; + +import java.util.List; + +import com.simibubi.create.foundation.item.ItemDescription; +import com.simibubi.create.foundation.utility.Lang; + +import net.minecraft.block.BlockState; +import net.minecraft.client.util.ITooltipFlag; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemUseContext; +import net.minecraft.item.Rarity; +import net.minecraft.item.UseAction; +import net.minecraft.nbt.NBTUtil; +import net.minecraft.util.ActionResultType; +import net.minecraft.util.Hand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.World; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.fml.DistExecutor; + +public abstract class ZapperItem extends Item { + + public ZapperItem(Properties properties) { + super(properties.maxStackSize(1).rarity(Rarity.UNCOMMON)); + } + + @Override + @OnlyIn(Dist.CLIENT) + public void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { + if (stack.hasTag() && stack.getTag().contains("BlockUsed")) { + String usedblock = NBTUtil.readBlockState(stack.getTag().getCompound("BlockUsed")).getBlock() + .getTranslationKey(); + ItemDescription.add(tooltip, TextFormatting.DARK_GRAY + Lang.translate("blockzapper.usingBlock", + TextFormatting.GRAY + new TranslationTextComponent(usedblock).getFormattedText())); + } + } + + @Override + public ActionResultType onItemUse(ItemUseContext context) { + // Shift -> open GUI + if (context.isPlacerSneaking()) { + if (context.getWorld().isRemote) { + DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> { + openHandgunGUI(context.getItem(), context.getHand() == Hand.OFF_HAND); + }); + applyCooldown(context.getPlayer(), context.getItem(), false); + } + return ActionResultType.SUCCESS; + } + return super.onItemUse(context); + } + + @OnlyIn(Dist.CLIENT) + protected abstract void openHandgunGUI(ItemStack item, boolean b); + + protected abstract int getCooldownDelay(ItemStack item); + + protected void applyCooldown(PlayerEntity playerIn, ItemStack item, boolean dual) { + int delay = getCooldownDelay(item); + playerIn.getCooldownTracker().setCooldown(item.getItem(), dual ? delay * 2 / 3 : delay); + } + + @Override + public boolean canPlayerBreakBlockWhileHolding(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) { + return false; + } + + @Override + public UseAction getUseAction(ItemStack stack) { + return UseAction.NONE; + } + +} diff --git a/src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperBeamPacket.java b/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperBeamPacket.java similarity index 92% rename from src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperBeamPacket.java rename to src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperBeamPacket.java index cf6e6d26e..e92594d05 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperBeamPacket.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperBeamPacket.java @@ -1,9 +1,9 @@ -package com.simibubi.create.modules.curiosities.blockzapper; +package com.simibubi.create.modules.curiosities.zapper.blockzapper; import java.util.function.Supplier; import com.simibubi.create.foundation.packet.SimplePacketBase; -import com.simibubi.create.modules.curiosities.blockzapper.BlockzapperHandler.LaserBeam; +import com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperHandler.LaserBeam; import net.minecraft.client.Minecraft; import net.minecraft.network.PacketBuffer; diff --git a/src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperHandler.java b/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperHandler.java similarity index 99% rename from src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperHandler.java rename to src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperHandler.java index 8b314931b..d070fe535 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperHandler.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperHandler.java @@ -1,4 +1,4 @@ -package com.simibubi.create.modules.curiosities.blockzapper; +package com.simibubi.create.modules.curiosities.zapper.blockzapper; import java.util.LinkedList; import java.util.List; diff --git a/src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperItem.java b/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperItem.java similarity index 91% rename from src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperItem.java rename to src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperItem.java index 187953b75..7a2e0ea26 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperItem.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperItem.java @@ -1,4 +1,4 @@ -package com.simibubi.create.modules.curiosities.blockzapper; +package com.simibubi.create.modules.curiosities.zapper.blockzapper; import java.util.HashSet; import java.util.LinkedList; @@ -20,6 +20,7 @@ import com.simibubi.create.foundation.item.ItemDescription.Palette; import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.NBTHelper; +import com.simibubi.create.modules.curiosities.zapper.ZapperItem; import net.minecraft.advancements.CriteriaTriggers; import net.minecraft.block.Block; @@ -33,12 +34,8 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.fluid.IFluidState; -import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.item.Rarity; -import net.minecraft.item.UseAction; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.NBTUtil; import net.minecraft.state.properties.BlockStateProperties; @@ -60,7 +57,6 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TextFormatting; -import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; @@ -70,7 +66,11 @@ import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.network.PacketDistributor; -public class BlockzapperItem extends Item implements IHaveCustomItemModel { +public class BlockzapperItem extends ZapperItem implements IHaveCustomItemModel { + + public BlockzapperItem(Properties properties) { + super(properties); + } public static enum ComponentTier { None(TextFormatting.DARK_GRAY), Brass(TextFormatting.GOLD), Chromatic(TextFormatting.LIGHT_PURPLE), @@ -89,29 +89,10 @@ public class BlockzapperItem extends Item implements IHaveCustomItemModel { Body, Amplifier, Accelerator, Retriever, Scope } - public BlockzapperItem(Properties properties) { - super(properties.maxStackSize(1).rarity(Rarity.UNCOMMON)); - } - - @Override - public boolean canPlayerBreakBlockWhileHolding(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) { - return false; - } - - @Override - public UseAction getUseAction(ItemStack stack) { - return UseAction.NONE; - } - @Override @OnlyIn(Dist.CLIENT) public void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) { - if (stack.hasTag() && stack.getTag().contains("BlockUsed")) { - String usedblock = NBTUtil.readBlockState(stack.getTag().getCompound("BlockUsed")).getBlock() - .getTranslationKey(); - ItemDescription.add(tooltip, TextFormatting.DARK_GRAY + Lang.translate("blockzapper.usingBlock", - TextFormatting.GRAY + new TranslationTextComponent(usedblock).getFormattedText())); - } + super.addInformation(stack, worldIn, tooltip, flagIn); Palette palette = Palette.Purple; if (Screen.hasShiftDown()) { ItemDescription.add(tooltip, palette.color + Lang.translate("blockzapper.componentUpgrades")); @@ -144,21 +125,6 @@ public class BlockzapperItem extends Item implements IHaveCustomItemModel { } } - @Override - public ActionResultType onItemUse(ItemUseContext context) { - // Shift -> open GUI - if (context.isPlacerSneaking()) { - if (context.getWorld().isRemote) { - DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> { - openHandgunGUI(context.getItem(), context.getHand() == Hand.OFF_HAND); - }); - applyCooldown(context.getPlayer(), context.getItem(), false); - } - return ActionResultType.SUCCESS; - } - return super.onItemUse(context); - } - @Override public ActionResult onItemRightClick(World world, PlayerEntity player, Hand hand) { ItemStack item = player.getHeldItem(hand); @@ -381,8 +347,9 @@ public class BlockzapperItem extends Item implements IHaveCustomItemModel { return slotChanged || !AllItems.PLACEMENT_HANDGUN.typeOf(newStack) || differentBlock; } + @Override @OnlyIn(Dist.CLIENT) - private void openHandgunGUI(ItemStack handgun, boolean offhand) { + protected void openHandgunGUI(ItemStack handgun, boolean offhand) { ScreenOpener.open(new BlockzapperScreen(handgun, offhand)); } @@ -503,7 +470,8 @@ public class BlockzapperItem extends Item implements IHaveCustomItemModel { return 0; } - public static int getCooldownDelay(ItemStack stack) { + @Override + protected int getCooldownDelay(ItemStack stack) { ComponentTier tier = getTier(Components.Accelerator, stack); if (tier == ComponentTier.None) return 10; @@ -511,10 +479,10 @@ public class BlockzapperItem extends Item implements IHaveCustomItemModel { return 6; if (tier == ComponentTier.Chromatic) return 2; - + return 20; } - + public static int getReachDistance(ItemStack stack) { ComponentTier tier = getTier(Components.Scope, stack); if (tier == ComponentTier.None) @@ -576,11 +544,6 @@ public class BlockzapperItem extends Item implements IHaveCustomItemModel { Block.spawnAsEntity(worldIn, placed, stack); } - protected static void applyCooldown(PlayerEntity playerIn, ItemStack item, boolean dual) { - playerIn.getCooldownTracker().setCooldown(item.getItem(), - dual ? getCooldownDelay(item) * 2 / 3 : getCooldownDelay(item)); - } - public static ComponentTier getTier(Components component, ItemStack stack) { if (!stack.hasTag() || !stack.getTag().contains(component.name())) stack.getOrCreateTag().putString(component.name(), ComponentTier.None.name()); diff --git a/src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperItemRenderer.java b/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperItemRenderer.java similarity index 84% rename from src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperItemRenderer.java rename to src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperItemRenderer.java index 50b7bf488..6501607a3 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperItemRenderer.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperItemRenderer.java @@ -1,16 +1,16 @@ -package com.simibubi.create.modules.curiosities.blockzapper; +package com.simibubi.create.modules.curiosities.zapper.blockzapper; -import static com.simibubi.create.modules.curiosities.blockzapper.BlockzapperItem.Components.Accelerator; -import static com.simibubi.create.modules.curiosities.blockzapper.BlockzapperItem.Components.Amplifier; -import static com.simibubi.create.modules.curiosities.blockzapper.BlockzapperItem.Components.Body; -import static com.simibubi.create.modules.curiosities.blockzapper.BlockzapperItem.Components.Retriever; -import static com.simibubi.create.modules.curiosities.blockzapper.BlockzapperItem.Components.Scope; +import static com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperItem.Components.Accelerator; +import static com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperItem.Components.Amplifier; +import static com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperItem.Components.Body; +import static com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperItem.Components.Retriever; +import static com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperItem.Components.Scope; import com.mojang.blaze3d.platform.GLX; import com.mojang.blaze3d.platform.GlStateManager; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import com.simibubi.create.modules.curiosities.blockzapper.BlockzapperItem.ComponentTier; -import com.simibubi.create.modules.curiosities.blockzapper.BlockzapperItem.Components; +import com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperItem.ComponentTier; +import com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperItem.Components; import net.minecraft.block.BlockState; import net.minecraft.block.FourWayBlock; diff --git a/src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperModel.java b/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperModel.java similarity index 86% rename from src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperModel.java rename to src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperModel.java index a6a724140..30be590ec 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperModel.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperModel.java @@ -1,10 +1,10 @@ -package com.simibubi.create.modules.curiosities.blockzapper; +package com.simibubi.create.modules.curiosities.zapper.blockzapper; import javax.annotation.Nullable; import com.simibubi.create.foundation.block.render.CustomRenderedItemModel; import com.simibubi.create.foundation.utility.Lang; -import com.simibubi.create.modules.curiosities.blockzapper.BlockzapperItem.ComponentTier; +import com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperItem.ComponentTier; import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer; diff --git a/src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperScreen.java b/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperScreen.java similarity index 99% rename from src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperScreen.java rename to src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperScreen.java index 28c78617d..1eeeb3a49 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperScreen.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperScreen.java @@ -1,4 +1,4 @@ -package com.simibubi.create.modules.curiosities.blockzapper; +package com.simibubi.create.modules.curiosities.zapper.blockzapper; import java.util.Collections; import java.util.Vector; diff --git a/src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperUpgradeRecipe.java b/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperUpgradeRecipe.java similarity index 93% rename from src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperUpgradeRecipe.java rename to src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperUpgradeRecipe.java index 4c6c36f0c..4131c5656 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/blockzapper/BlockzapperUpgradeRecipe.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/BlockzapperUpgradeRecipe.java @@ -1,10 +1,10 @@ -package com.simibubi.create.modules.curiosities.blockzapper; +package com.simibubi.create.modules.curiosities.zapper.blockzapper; import com.google.gson.JsonObject; import com.simibubi.create.AllItems; import com.simibubi.create.AllRecipes; -import com.simibubi.create.modules.curiosities.blockzapper.BlockzapperItem.ComponentTier; -import com.simibubi.create.modules.curiosities.blockzapper.BlockzapperItem.Components; +import com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperItem.ComponentTier; +import com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperItem.Components; import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.ItemStack; diff --git a/src/main/java/com/simibubi/create/modules/curiosities/blockzapper/PlacementPatterns.java b/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/PlacementPatterns.java similarity index 90% rename from src/main/java/com/simibubi/create/modules/curiosities/blockzapper/PlacementPatterns.java rename to src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/PlacementPatterns.java index cdf1f0926..8065dd692 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/blockzapper/PlacementPatterns.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/zapper/blockzapper/PlacementPatterns.java @@ -1,4 +1,4 @@ -package com.simibubi.create.modules.curiosities.blockzapper; +package com.simibubi.create.modules.curiosities.zapper.blockzapper; import com.simibubi.create.ScreenResources; import com.simibubi.create.foundation.utility.Lang; diff --git a/src/main/java/com/simibubi/create/modules/curiosities/zapper/terrainzapper/CylinderBrush.java b/src/main/java/com/simibubi/create/modules/curiosities/zapper/terrainzapper/CylinderBrush.java new file mode 100644 index 000000000..12834c87b --- /dev/null +++ b/src/main/java/com/simibubi/create/modules/curiosities/zapper/terrainzapper/CylinderBrush.java @@ -0,0 +1,51 @@ +package com.simibubi.create.modules.curiosities.zapper.terrainzapper; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import org.apache.commons.lang3.tuple.Pair; + +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.math.shapes.VoxelShapes; + +public class CylinderBrush { + + public static final int MAX_RADIUS = 6; + public static final int MAX_HEIGHT = 6; + private Map, Pair, VoxelShape>> cachedBrushes; + + public CylinderBrush() { + cachedBrushes = new HashMap<>(); + VoxelShape fullCube = VoxelShapes.fullCube(); + + for (int i = 0; i <= MAX_RADIUS; i++) { + int radius = i; + VoxelShape shape = VoxelShapes.empty(); + List positions = BlockPos.getAllInBox(BlockPos.ZERO.add(-i, 0, -i), BlockPos.ZERO.add(i, 0, i)) + .filter(p -> p.withinDistance(BlockPos.ZERO, radius)).collect(Collectors.toList()); + for (BlockPos p : positions) + shape = VoxelShapes.or(shape, fullCube.withOffset(p.getX(), p.getY(), p.getZ())); + for (int h = 0; h <= MAX_HEIGHT; h++) { + VoxelShape stackedShape = shape.simplify(); + for (int layer = 0; layer <= layer; i++) + stackedShape = VoxelShapes.or(stackedShape, shape.withOffset(0, layer - h / 2, 0)); + cachedBrushes.put(Pair.of(i, h), Pair.of(positions, stackedShape.simplify())); + } + } + } + + public VoxelShape getSelectionBox(int radius, int height) { + return get(radius, height).getRight(); + } + + public List getIncludedPositions(int radius, int height) { + return get(radius, height).getLeft(); + } + + protected Pair, VoxelShape> get(int radius, int height) { + return cachedBrushes.get(Pair.of(Integer.valueOf(radius), Integer.valueOf(height))); + } +} diff --git a/src/main/java/com/simibubi/create/modules/curiosities/zapper/terrainzapper/SphereBrush.java b/src/main/java/com/simibubi/create/modules/curiosities/zapper/terrainzapper/SphereBrush.java new file mode 100644 index 000000000..d12ee8f88 --- /dev/null +++ b/src/main/java/com/simibubi/create/modules/curiosities/zapper/terrainzapper/SphereBrush.java @@ -0,0 +1,46 @@ +package com.simibubi.create.modules.curiosities.zapper.terrainzapper; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import org.apache.commons.lang3.tuple.Pair; + +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.math.shapes.VoxelShapes; + +public class SphereBrush { + + public static final int MAX_RADIUS = 6; + private Map, VoxelShape>> cachedBrushes; + + public SphereBrush() { + cachedBrushes = new HashMap<>(); + for (int i = 0; i <= MAX_RADIUS; i++) { + int radius = i; + VoxelShape shape = VoxelShapes.empty(); + List positions = BlockPos.getAllInBox(BlockPos.ZERO.add(-i, -i, -i), BlockPos.ZERO.add(i, i, i)) + .filter(p -> p.withinDistance(BlockPos.ZERO, radius)).collect(Collectors.toList()); + VoxelShape fullCube = VoxelShapes.fullCube(); + for (BlockPos p : positions) + shape = VoxelShapes.or(shape, fullCube.withOffset(p.getX(), p.getY(), p.getZ())); + shape = shape.simplify(); + cachedBrushes.put(i, Pair.of(positions, shape)); + } + } + + public VoxelShape getSelectionBox(int size) { + return get(size).getRight(); + } + + public List getIncludedPositions(int size) { + return get(size).getLeft(); + } + + protected Pair, VoxelShape> get(int size) { + return cachedBrushes.get(Integer.valueOf(size)); + } + +} diff --git a/src/main/java/com/simibubi/create/modules/curiosities/zapper/terrainzapper/TerrainZapperItem.java b/src/main/java/com/simibubi/create/modules/curiosities/zapper/terrainzapper/TerrainZapperItem.java new file mode 100644 index 000000000..9002a3999 --- /dev/null +++ b/src/main/java/com/simibubi/create/modules/curiosities/zapper/terrainzapper/TerrainZapperItem.java @@ -0,0 +1,24 @@ +package com.simibubi.create.modules.curiosities.zapper.terrainzapper; + +import com.simibubi.create.modules.curiosities.zapper.ZapperItem; + +import net.minecraft.item.ItemStack; + +public class TerrainZapperItem extends ZapperItem { + + public TerrainZapperItem(Properties properties) { + super(properties); + } + + @Override + protected void openHandgunGUI(ItemStack item, boolean b) { + // TODO Auto-generated method stub + + } + + @Override + protected int getCooldownDelay(ItemStack item) { + return 2; + } + +} diff --git a/src/main/resources/assets/create/lang/en_us.json b/src/main/resources/assets/create/lang/en_us.json index eb043011c..c7cc3a4fc 100644 --- a/src/main/resources/assets/create/lang/en_us.json +++ b/src/main/resources/assets/create/lang/en_us.json @@ -741,7 +741,7 @@ "block.create.encased_shaft.tooltip.summary": "_Relays_ _Rotation_ in a straight line. Suitable for propagating Rotation through Walls.", "block.create.gearbox.tooltip": "GEARBOX", - "block.create.gearbox.tooltip.summary": "_Relays_ _Rotation_ to _Four_ _directions._ Reverses straight connections.", + "block.create.gearbox.tooltip.summary": "_Relays_ _Rotation_ in _four_ _directions._ Reverses straight connections.", "block.create.gearshift.tooltip": "GEARSHIFT", "block.create.gearshift.tooltip.summary": "A controllable _rotation_ _switch_ for connected shafts.", @@ -784,7 +784,7 @@ "item.create.wrench.tooltip.control2": "R-Click while Sneaking", "item.create.wrench.tooltip.action2": "_Disassembles_ _Kinetic_ _components_ and places them back in _your_ _inventory._", - "block.create.creative_motor.tooltip": "MOTOR", + "block.create.creative_motor.tooltip": "CREATIVE MOTOR", "block.create.creative_motor.tooltip.summary": "A configurable source of _Rotational_ _Force_", "block.create.water_wheel.tooltip": "WATER WHEEL", @@ -859,12 +859,12 @@ "block.create.flywheel.tooltip.behaviour1": "Provides _Rotational_ _Force_ to a connected contraption based on the generators strength and speed.", "block.create.mechanical_piston.tooltip": "MECHANICAL PISTON", - "block.create.mechanical_piston.tooltip.summary": "A more advanced version of the _Piston,_ using _Rotational_ _Force_ to precisely move attached structures. _Piston_ _Extension_ _Poles_ at the rear define the _Range_ of this Device. Without extensions, the piston will not move. Use _Translation_ _Chassis_ to move more than a single line of blocks.", + "block.create.mechanical_piston.tooltip.summary": "A more advanced version of the _Piston,_ using _Rotational_ _Force_ to precisely move attached structures. _Piston_ _Extension_ _Poles_ at the rear define the _Range_ of this Device. Without extensions, the piston will not move. Use _Chassis_ to move more than a single line of blocks.", "block.create.mechanical_piston.tooltip.condition1": "When Rotated", "block.create.mechanical_piston.tooltip.behaviour1": "Starts moving the attached structure. Speed and direction correlate to the incoming Rotation Speed.", "block.create.sticky_mechanical_piston.tooltip": "STICKY MECHANICAL PISTON", - "block.create.sticky_mechanical_piston.tooltip.summary": "A more advanced version of the _Sticky_ _Piston,_ using _Rotational_ _Force_ to precisely move attached structures. _Piston_ _Extension_ _Poles_ at the rear define the _Range_ of this Device. Without extensions, the piston will not move. Use _Translation_ _Chassis_ to move more than a single line of blocks.", + "block.create.sticky_mechanical_piston.tooltip.summary": "A more advanced version of the _Sticky_ _Piston,_ using _Rotational_ _Force_ to precisely move attached structures. _Piston_ _Extension_ _Poles_ at the rear define the _Range_ of this Device. Without extensions, the piston will not move. Use _Chassis_ to move more than a single line of blocks.", "block.create.sticky_mechanical_piston.tooltip.condition1": "When Rotated", "block.create.sticky_mechanical_piston.tooltip.behaviour1": "Starts moving the attached structure. Speed and direction correlate to the incoming Rotation Speed.", @@ -881,18 +881,22 @@ "block.create.mechanical_bearing.tooltip.behaviour2": "Starts providing _Rotational_ _Force_ from rotating its attached structure. The Structure has to include suitable _Sail_ _Blocks_ (Currently any Wool Block).", "block.create.translation_chassis.tooltip": "TRANSLATION CHASSIS", - "block.create.translation_chassis.tooltip.summary": "A configurable base for Structures moved by a _Mechanical_ _Piston._ These Blocks have to form the first Layer of blocks in front of the Piston.", - "block.create.translation_chassis.tooltip.condition1": "When Moved by Mechanical Piston", - "block.create.translation_chassis.tooltip.behaviour1": "_Moves_ all _attached_ _Chassis_ with the same orientation, and attached Blocks in front of it. When the Piston retracts, blocks will only be pulled if the chassis' face is _Sticky_ (See [Ctrl]).", + "block.create.translation_chassis.tooltip.summary": "A configurable base block connecting structures for movement.", + "block.create.translation_chassis.tooltip.condition1": "When Moved", + "block.create.translation_chassis.tooltip.behaviour1": "_Moves_ all _attached_ _Chassis_ with the same orientation, and a column of Blocks within its range. Blocks will only be pulled if the chassis' face is _Sticky_ (See [Ctrl]).", + "block.create.translation_chassis.tooltip.condition2": "With Wrench", + "block.create.translation_chassis.tooltip.behaviour2": "Configure the _range_ for this chassis block. Hold CTRL to modify the range of all attached chassis blocks as well.", "block.create.translation_chassis.tooltip.control1": "When R-Clicked with Slime Ball", - "block.create.translation_chassis.tooltip.action1": "Makes the clicked face _Sticky._ When the piston retracts, the chassis will _pull_ _back_ all attached Blocks in its column and within the configured Range.", + "block.create.translation_chassis.tooltip.action1": "Makes the clicked face _Sticky._ When moved, the chassis will _pull_ attached Blocks, regardless of the direcion of its movement.", "block.create.rotation_chassis.tooltip": "ROTATION CHASSIS", - "block.create.rotation_chassis.tooltip.summary": "Required for rotating structures with the _Mechanical_ _Bearing._ ", - "block.create.rotation_chassis.tooltip.condition1": "When Rotated by Bearing", - "block.create.rotation_chassis.tooltip.behaviour1": "_Rotates_ all blocks attached to _Sticky_ sides (See [Ctrl]) within the configured range around itself. _Transmits_ the rotation to further attached Rotation Chassis.", + "block.create.rotation_chassis.tooltip.summary": "A configurable base block connecting structures for movement.", + "block.create.rotation_chassis.tooltip.condition1": "When Moved", + "block.create.rotation_chassis.tooltip.behaviour1": "_Moves_ all _attached_ _Chassis_ in a column, and a cylinder of blocks around itself. Blocks around it are only moved when they are within range and attached to a sticky side (See [Ctrl]).", + "block.create.rotation_chassis.tooltip.condition2": "With Wrench", + "block.create.rotation_chassis.tooltip.behaviour2": "Configure the _range_ for this chassis block. Hold CTRL to modify the range of all attached chassis blocks as well.", "block.create.rotation_chassis.tooltip.control1": "When R-Clicked with Slime Ball", - "block.create.rotation_chassis.tooltip.action1": "Makes the clicked face _Sticky._ When the Chassis rotates, all blocks attached to this side will be rotated with it.", + "block.create.rotation_chassis.tooltip.action1": "Makes the clicked face _Sticky._ When the Chassis gets moved, all blocks attached to this side will be moved with it.", "block.create.drill.tooltip": "MECHANICAL DRILL", "block.create.drill.tooltip.summary": "A mechanical device suitable for _breaking_ _blocks._",