diff --git a/src/main/java/su/a71/new_soviet/blocks/HandrailBlock.java b/src/main/java/su/a71/new_soviet/blocks/HandrailBlock.java index cab1a87..190fbe3 100644 --- a/src/main/java/su/a71/new_soviet/blocks/HandrailBlock.java +++ b/src/main/java/su/a71/new_soviet/blocks/HandrailBlock.java @@ -32,9 +32,9 @@ import static net.minecraft.block.StairsBlock.SHAPE; // By the way, Blockstate not updating when removing stairs is a "creative decision" apparently // - Andrew71 public class HandrailBlock extends HorizontalFacingBlock implements BlockEntityProvider, Waterloggable { - protected static final Shapes.HorizontalShape2 SHAPE1; - protected static final Shapes.HorizontalShape2 SHAPE2; - protected static final Shapes.HorizontalShape2 SHAPE3; + protected static final Shapes.HorizontalShape SHAPE1; + protected static final Shapes.HorizontalShape SHAPE2; + protected static final Shapes.HorizontalShape SHAPE3; public static final BooleanProperty WATERLOGGED; public static final IntProperty ROTATION; @@ -128,9 +128,9 @@ public class HandrailBlock extends HorizontalFacingBlock implements BlockEntityP } static { - SHAPE2 = new Shapes.HorizontalShape2(List.of(List.of(0.0, 0.0, 15.0, 16.0, 17.0, 16.0), List.of(0.0, 17.0, 14.5, 16.0, 19.0, 16.5))); - SHAPE1 = new Shapes.HorizontalShape2(List.of(List.of(0.0, 0.0, 15.0, 8.0, 18.0, 16.0), List.of(8.0, -8.0, 15.0, 16.0, 10.0, 16.0))); - SHAPE3 = new Shapes.HorizontalShape2(List.of(List.of(0.0, -8.0, 15.0, 8.0, 10.0, 16.0), List.of(8.0, 0.0, 15.0, 16.0, 18.0, 16.0))); + SHAPE2 = new Shapes.HorizontalShape(List.of(List.of(0.0, 0.0, 15.0, 16.0, 17.0, 16.0), List.of(0.0, 17.0, 14.5, 16.0, 19.0, 16.5))); + SHAPE1 = new Shapes.HorizontalShape(List.of(List.of(0.0, 0.0, 15.0, 8.0, 18.0, 16.0), List.of(8.0, -8.0, 15.0, 16.0, 10.0, 16.0))); + SHAPE3 = new Shapes.HorizontalShape(List.of(List.of(0.0, -8.0, 15.0, 8.0, 10.0, 16.0), List.of(8.0, 0.0, 15.0, 16.0, 18.0, 16.0))); ROTATION = IntProperty.of("rotate", 1, 3);; WATERLOGGED = Properties.WATERLOGGED; } diff --git a/src/main/java/su/a71/new_soviet/blocks/TVBlock.java b/src/main/java/su/a71/new_soviet/blocks/TVBlock.java index 5afc350..156d974 100644 --- a/src/main/java/su/a71/new_soviet/blocks/TVBlock.java +++ b/src/main/java/su/a71/new_soviet/blocks/TVBlock.java @@ -19,7 +19,7 @@ import su.a71.new_soviet.util.Shapes; import java.util.List; public class TVBlock extends HorizontalFacingBlock implements BlockEntityProvider { - protected static final Shapes.HorizontalShape SHAPE; + protected static final Shapes.HorizontalShapeLegacy SHAPE; public TVBlock(AbstractBlock.Settings settings) { super(settings.sounds(BlockSoundGroup.METAL).pistonBehavior(PistonBehavior.BLOCK).strength(1f, 2f)); @@ -54,6 +54,6 @@ public class TVBlock extends HorizontalFacingBlock implements BlockEntityProvide } static { - SHAPE = new Shapes.HorizontalShape(List.of(List.of(0.0, 1.0, 3.0, 16.0, 13.0, 13.0), List.of(2.0, 0.0, 4.0, 14.0, 1.0, 12.0), List.of(6.0, 13.0, 7.0, 10.0, 14.0, 9.0))); + SHAPE = new Shapes.HorizontalShapeLegacy(List.of(List.of(0.0, 1.0, 3.0, 16.0, 13.0, 13.0), List.of(2.0, 0.0, 4.0, 14.0, 1.0, 12.0), List.of(6.0, 13.0, 7.0, 10.0, 14.0, 9.0))); } } \ No newline at end of file diff --git a/src/main/java/su/a71/new_soviet/blocks/lamps/DevTableLampBlock.java b/src/main/java/su/a71/new_soviet/blocks/lamps/DevTableLampBlock.java index cf47de9..d2892b2 100644 --- a/src/main/java/su/a71/new_soviet/blocks/lamps/DevTableLampBlock.java +++ b/src/main/java/su/a71/new_soviet/blocks/lamps/DevTableLampBlock.java @@ -1,14 +1,5 @@ package su.a71.new_soviet.blocks.lamps; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.ShapeContext; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; -import net.minecraft.world.BlockView; -import net.minecraft.world.WorldView; import su.a71.new_soviet.util.Shapes; import java.util.List; @@ -17,7 +8,7 @@ public class DevTableLampBlock extends GoldenTableLampBlock { public DevTableLampBlock(Settings settings) { super(settings); - SHAPE = new Shapes.HorizontalShape(List.of( + SHAPE = new Shapes.HorizontalShapeLegacy(List.of( List.of(5.0, 0.0, 5.0, 11.0, 2.0, 11.0), List.of(7.0, 2.0, 7.0, 9.0, 4.0, 9.0), List.of(6.0, 4.0, 6.0, 10.0, 5.0, 10.0), diff --git a/src/main/java/su/a71/new_soviet/blocks/lamps/GoldenTableLampBlock.java b/src/main/java/su/a71/new_soviet/blocks/lamps/GoldenTableLampBlock.java index f51f6f9..6584906 100644 --- a/src/main/java/su/a71/new_soviet/blocks/lamps/GoldenTableLampBlock.java +++ b/src/main/java/su/a71/new_soviet/blocks/lamps/GoldenTableLampBlock.java @@ -21,7 +21,7 @@ import java.util.List; public class GoldenTableLampBlock extends LampBlock { public static final DirectionProperty FACING; - public Shapes.HorizontalShape SHAPE = new Shapes.HorizontalShape(List.of( + public Shapes.HorizontalShapeLegacy SHAPE = new Shapes.HorizontalShapeLegacy(List.of( List.of(5.0, 0.0, 5.0, 11.0, 2.0, 11.0), List.of(7.0, 2.0, 7.0, 9.0, 4.0, 9.0), List.of(6.0, 4.0, 6.0, 10.0, 5.0, 10.0), diff --git a/src/main/java/su/a71/new_soviet/blocks/lamps/lamp_post/LampPostLampBlock.java b/src/main/java/su/a71/new_soviet/blocks/lamps/lamp_post/LampPostLampBlock.java index fda08f7..5849a76 100644 --- a/src/main/java/su/a71/new_soviet/blocks/lamps/lamp_post/LampPostLampBlock.java +++ b/src/main/java/su/a71/new_soviet/blocks/lamps/lamp_post/LampPostLampBlock.java @@ -23,14 +23,12 @@ import net.minecraft.world.WorldView; import org.jetbrains.annotations.Nullable; import su.a71.new_soviet.util.Shapes; -import java.util.List; - public class LampPostLampBlock extends Block implements Waterloggable { public static final DirectionProperty FACING; public static final BooleanProperty WATERLOGGED; - public Shapes.HorizontalShape SHAPE; + public Shapes.HorizontalShapeLegacy SHAPE; - public LampPostLampBlock(AbstractBlock.Settings settings, Shapes.HorizontalShape shape) { + public LampPostLampBlock(AbstractBlock.Settings settings, Shapes.HorizontalShapeLegacy shape) { super(settings.luminance((state) -> 14)); SHAPE = shape; this.setDefaultState(this.stateManager.getDefaultState() diff --git a/src/main/java/su/a71/new_soviet/items/DiceItem.java b/src/main/java/su/a71/new_soviet/items/DiceItem.java index 85d4760..9af68e2 100644 --- a/src/main/java/su/a71/new_soviet/items/DiceItem.java +++ b/src/main/java/su/a71/new_soviet/items/DiceItem.java @@ -20,12 +20,12 @@ import su.a71.new_soviet.registration.NSE_Sounds; public class DiceItem extends Item { private final int sides; - private final String loacl_tooltip; + private final String local_tooltip; public DiceItem(int sides, String localTooltip, Settings settings) { super(settings); this.sides = sides; - this.loacl_tooltip = localTooltip; + this.local_tooltip = localTooltip; } public TypedActionResult use(World world, PlayerEntity user, Hand hand) { @@ -56,7 +56,7 @@ public class DiceItem extends Item { @Override public void appendTooltip(ItemStack stack, @Nullable World world, List tooltip, TooltipContext context) { - tooltip.add(Text.translatable(loacl_tooltip)); + tooltip.add(Text.translatable(local_tooltip)); super.appendTooltip(stack, world, tooltip, context); } } diff --git a/src/main/java/su/a71/new_soviet/registration/NSE_Custom.java b/src/main/java/su/a71/new_soviet/registration/NSE_Custom.java index e0bc5e1..2f4ba3b 100644 --- a/src/main/java/su/a71/new_soviet/registration/NSE_Custom.java +++ b/src/main/java/su/a71/new_soviet/registration/NSE_Custom.java @@ -46,22 +46,22 @@ public class NSE_Custom extends NSE_BaseRegistration { public static final LampPostBaseBlock LAMP_POST_BASE = new LampPostBaseBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).strength(1f, 1.5f).mapColor(MapColor.IRON_GRAY)); public static final LampPostLampBlock CAGED_POST_LAMP = new LampPostLampBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).strength(1f, 1.5f).mapColor(MapColor.IRON_GRAY), - new Shapes.HorizontalShape(List.of(List.of(6.5, 0.0, 6.5, 9.5, 2.0, 9.5), + new Shapes.HorizontalShapeLegacy(List.of(List.of(6.5, 0.0, 6.5, 9.5, 2.0, 9.5), List.of(7.0, 2.0, 7.0, 9.0, 7.0, 9.0), List.of(6.5, 7.0, 6.5, 9.5, 9.0, 9.5), List.of(7.0, 9.0, 7.0, 9.0, 12.0, 9.0)))); public static final LampPostLampBlock MODERN_POST_LAMP = new LampPostLampBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).strength(1f, 1.5f).mapColor(MapColor.IRON_GRAY), - new Shapes.HorizontalShape(List.of(List.of(6.5, 0.0, 6.5, 9.5, 2.0, 9.5), + new Shapes.HorizontalShapeLegacy(List.of(List.of(6.5, 0.0, 6.5, 9.5, 2.0, 9.5), List.of(7.0, 2.0, 7.0, 9.0, 7.0, 9.0), List.of(6.5, 7.0, 6.5, 9.5, 9.0, 9.5), List.of(7.0, 9.0, 7.0, 9.0, 12.0, 9.0)))); public static final LampPostLampBlock BIG_POST_LAMP = new LampPostLampBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).strength(1f, 1.5f).mapColor(MapColor.IRON_GRAY), - new Shapes.HorizontalShape(List.of(List.of(6.5, 0.0, 6.5, 9.5, 2.0, 9.5), + new Shapes.HorizontalShapeLegacy(List.of(List.of(6.5, 0.0, 6.5, 9.5, 2.0, 9.5), List.of(7.0, 2.0, 7.0, 9.0, 7.0, 9.0), List.of(6.5, 7.0, 6.5, 9.5, 9.0, 9.5), List.of(7.0, 9.0, 7.0, 9.0, 12.0, 9.0)))); public static final LampPostLampBlock VINTAGE_POST_LAMP = new LampPostLampBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.METAL).strength(1f, 1.5f).mapColor(MapColor.IRON_GRAY), - new Shapes.HorizontalShape(List.of(List.of(6.5, 0.0, 6.5, 9.5, 2.0, 9.5), + new Shapes.HorizontalShapeLegacy(List.of(List.of(6.5, 0.0, 6.5, 9.5, 2.0, 9.5), List.of(7.0, 2.0, 7.0, 9.0, 7.0, 9.0), List.of(6.5, 7.0, 6.5, 9.5, 9.0, 9.5), List.of(7.0, 9.0, 7.0, 9.0, 12.0, 9.0)))); diff --git a/src/main/java/su/a71/new_soviet/util/Shapes.java b/src/main/java/su/a71/new_soviet/util/Shapes.java index f589d62..b7a7aae 100644 --- a/src/main/java/su/a71/new_soviet/util/Shapes.java +++ b/src/main/java/su/a71/new_soviet/util/Shapes.java @@ -8,25 +8,13 @@ import java.util.ArrayList; import java.util.List; public class Shapes { - public static class NHShape{ - private VoxelShape NORTH; - private VoxelShape WEST; - private VoxelShape SOUTH; - private VoxelShape EAST; - private double minX; - private double minY; - private double minZ; - private double maxX; - private double maxY; - private double maxZ; + public static class NHShapeLegacy { + private final VoxelShape NORTH; + private final VoxelShape WEST; + private final VoxelShape SOUTH; + private final VoxelShape EAST; - public NHShape(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) { - this.minX = minX; - this.minY = minY; - this.minZ = minZ; - this.maxX = maxX; - this.maxY = maxY; - this.maxZ = maxZ; + public NHShapeLegacy(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) { this.NORTH = Block.createCuboidShape(minX, minY, minZ, maxX, maxY, maxZ); this.WEST = Block.createCuboidShape(minZ, minY, minX, maxZ, maxY, maxX); this.SOUTH = Block.createCuboidShape(minX, minY, (16 - maxZ), maxX, maxY, (16 - minZ)); @@ -50,25 +38,13 @@ public class Shapes { } } - public static class NHShape2{ - private VoxelShape NORTH; - private VoxelShape WEST; - private VoxelShape SOUTH; - private VoxelShape EAST; - private double minX; - private double minY; - private double minZ; - private double maxX; - private double maxY; - private double maxZ; + public static class NHShape { + private final VoxelShape NORTH; + private final VoxelShape WEST; + private final VoxelShape SOUTH; + private final VoxelShape EAST; - public NHShape2(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) { - this.minX = minX; - this.minY = minY; - this.minZ = minZ; - this.maxX = maxX; - this.maxY = maxY; - this.maxZ = maxZ; + public NHShape(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) { this.NORTH = Block.createCuboidShape((16 - maxX), minY, minZ, (16 - minX), maxY, maxZ); this.WEST = Block.createCuboidShape(minZ, minY, minX, maxZ, maxY, maxX); this.SOUTH = Block.createCuboidShape(minX, minY, (16 - maxZ), maxX, maxY, (16 - minZ)); @@ -92,11 +68,63 @@ public class Shapes { } } - public static class HorizontalShape{ - private List ShapesListN; - private List ShapesListS; - private List ShapesListW; - private List ShapesListE; + public static class HorizontalShapeLegacy { + private final List ShapesListN; + private final List ShapesListS; + private final List ShapesListW; + private final List ShapesListE; + public HorizontalShapeLegacy(List> list) { + this.ShapesListN = new ArrayList<>(); + this.ShapesListS = new ArrayList<>(); + this.ShapesListW = new ArrayList<>(); + this.ShapesListE = new ArrayList<>(); + for (List i : list) { + NHShapeLegacy shape = new NHShapeLegacy(i.get(0), i.get(1), i.get(2), i.get(3), i.get(4), i.get(5)); + ShapesListN.add(shape.north()); + ShapesListS.add(shape.south()); + ShapesListW.add(shape.west()); + ShapesListE.add(shape.east()); + } + } + + public VoxelShape north() { + VoxelShape shape = Block.createCuboidShape(0, 0,0,0,0,0); + for (VoxelShape o : ShapesListN) { + shape = VoxelShapes.union(shape, o); + } + return shape; + } + + public VoxelShape west() { + VoxelShape shape = Block.createCuboidShape(0, 0,0,0,0,0);; + for (VoxelShape o : ShapesListW) { + shape = VoxelShapes.union(shape, o); + } + return shape; + } + + public VoxelShape south() { + VoxelShape shape = Block.createCuboidShape(0, 0,0,0,0,0);; + for (VoxelShape shapesList : ShapesListS) { + shape = VoxelShapes.union(shape, shapesList); + } + return shape; + } + + public VoxelShape east() { + VoxelShape shape = Block.createCuboidShape(0, 0,0,0,0,0);; + for (VoxelShape o : ShapesListE) { + shape = VoxelShapes.union(shape, o); + } + return shape; + } + } + + public static class HorizontalShape { + private final List ShapesListN; + private final List ShapesListS; + private final List ShapesListW; + private final List ShapesListE; public HorizontalShape(List> list) { this.ShapesListN = new ArrayList<>(); this.ShapesListS = new ArrayList<>(); @@ -113,84 +141,32 @@ public class Shapes { public VoxelShape north() { VoxelShape shape = Block.createCuboidShape(0, 0,0,0,0,0); - for (int i=0;i> list) { - this.ShapesListN = new ArrayList<>(); - this.ShapesListS = new ArrayList<>(); - this.ShapesListW = new ArrayList<>(); - this.ShapesListE = new ArrayList<>(); - for (List i : list) { - NHShape2 shape = new NHShape2(i.get(0), i.get(1), i.get(2), i.get(3), i.get(4), i.get(5)); - ShapesListN.add(shape.north()); - ShapesListS.add(shape.south()); - ShapesListW.add(shape.west()); - ShapesListE.add(shape.east()); - } - } - - public VoxelShape north() { - VoxelShape shape = Block.createCuboidShape(0, 0,0,0,0,0); - for (int i=0;i