From 8f81ee2743ffaf631404d75666d65315fd86ab99 Mon Sep 17 00:00:00 2001 From: levtus Date: Mon, 25 Sep 2023 13:26:13 -0500 Subject: [PATCH] Begin Headlight --- .../bellsandwhistles/block/ModBlocks.java | 29 +++--- .../block/custom/HeadlightBlock.java | 69 +++++++++++++ .../blockstates/headlight.json | 26 +++++ .../block/headlight/headlight_floor.json | 59 +++++++++++ .../block/headlight/headlight_wall.json | 97 ++++++++++++++++++ .../models/item/corrugated_metro_panel.json | 3 + .../models/item/headlight.json | 3 + .../models/item/metro_panel.json | 3 + .../textures/block/folding_metro_door_top.png | Bin 0 -> 486 bytes .../textures/block/headlight.png | Bin 0 -> 469 bytes 10 files changed, 275 insertions(+), 14 deletions(-) create mode 100644 src/main/java/systems/alexander/bellsandwhistles/block/custom/HeadlightBlock.java create mode 100644 src/main/resources/assets/bellsandwhistles/blockstates/headlight.json create mode 100644 src/main/resources/assets/bellsandwhistles/models/block/headlight/headlight_floor.json create mode 100644 src/main/resources/assets/bellsandwhistles/models/block/headlight/headlight_wall.json create mode 100644 src/main/resources/assets/bellsandwhistles/models/item/corrugated_metro_panel.json create mode 100644 src/main/resources/assets/bellsandwhistles/models/item/headlight.json create mode 100644 src/main/resources/assets/bellsandwhistles/models/item/metro_panel.json create mode 100644 src/main/resources/assets/bellsandwhistles/textures/block/folding_metro_door_top.png create mode 100644 src/main/resources/assets/bellsandwhistles/textures/block/headlight.png diff --git a/src/main/java/systems/alexander/bellsandwhistles/block/ModBlocks.java b/src/main/java/systems/alexander/bellsandwhistles/block/ModBlocks.java index 61976d6..8bca8ae 100644 --- a/src/main/java/systems/alexander/bellsandwhistles/block/ModBlocks.java +++ b/src/main/java/systems/alexander/bellsandwhistles/block/ModBlocks.java @@ -5,8 +5,9 @@ import com.simibubi.create.content.decoration.encasing.CasingBlock; import com.simibubi.create.content.decoration.slidingDoor.SlidingDoorBlock; import com.tterrag.registrate.builders.BlockBuilder; +import net.minecraft.sounds.SoundEvent; import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.level.block.TrapDoorBlock; +import net.minecraft.world.level.block.*; import systems.alexander.bellsandwhistles.BellsAndWhistles; import systems.alexander.bellsandwhistles.block.custom.*; import systems.alexander.bellsandwhistles.item.ModCreativeModeTab; @@ -14,9 +15,6 @@ import net.minecraft.tags.BlockTags; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraftforge.common.util.NonNullFunction; import net.minecraftforge.eventbus.api.IEventBus; @@ -47,27 +45,30 @@ public static NonNullFunction, BlockBuil public static final RegistryObject COPPER_BOGIE_STEPS = registerBlock("copper_bogie_steps", () -> new MetalBogieStepsBlock(BlockBehaviour.Properties.copy(Blocks.LADDER).sound(SoundType.METAL).noOcclusion())); + public static final RegistryObject HEADLIGHT = registerBlock("headlight", + () -> new HeadlightBlock(BlockBehaviour.Properties.copy(Blocks.LANTERN).sound(SoundType.LANTERN))); + public static final RegistryObject METRO_CASING = registerBlock("metro_casing", () -> new CasingBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL), true)); public static final RegistryObject CORRUGATED_METRO_CASING = registerBlock("corrugated_metro_casing", () -> new CasingBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL), true)); - public static final RegistryObject SLIDING_METRO_DOOR = registerBlock("sliding_metro_door", - () -> new SlidingDoorBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL).noOcclusion(), false)); - public static final RegistryObject FOLDING_METRO_DOOR = registerBlock("folding_metro_door", - () -> new SlidingDoorBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL).noOcclusion(), true)); - public static final RegistryObject METRO_TRAPDOOR = registerBlock("metro_trapdoor", - () -> new TrainTrapdoorBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL).noOcclusion())); - - public static final RegistryObject METRO_WINDOW = registerBlock("metro_window", - () -> new TrapDoorBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL).noOcclusion())); public static final RegistryObject METRO_PANEL = registerBlock("metro_panel", () -> new PanelBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL).noOcclusion())); - public static final RegistryObject CORRUGATED_METRO_PANEL = registerBlock("corrugated_metro_panel", () -> new PanelBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL).noOcclusion())); + public static final RegistryObject METRO_WINDOW = registerBlock("metro_window", + () -> new TrapDoorBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL).noOcclusion())); + + public static final RegistryObject METRO_TRAPDOOR = registerBlock("metro_trapdoor", + () -> new TrainTrapdoorBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL).noOcclusion())); + + public static final RegistryObject SLIDING_METRO_DOOR = registerBlock("sliding_metro_door", + () -> new SlidingDoorBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL).noOcclusion(), false)); + public static final RegistryObject FOLDING_METRO_DOOR = registerBlock("folding_metro_door", + () -> new SlidingDoorBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL).noOcclusion(), true)); public static final RegistryObject METAL_PILOT = registerBlock("metal_pilot", () -> new PilotBlock(BlockBehaviour.Properties.copy(Blocks.IRON_BLOCK).noOcclusion())); diff --git a/src/main/java/systems/alexander/bellsandwhistles/block/custom/HeadlightBlock.java b/src/main/java/systems/alexander/bellsandwhistles/block/custom/HeadlightBlock.java new file mode 100644 index 0000000..6c40834 --- /dev/null +++ b/src/main/java/systems/alexander/bellsandwhistles/block/custom/HeadlightBlock.java @@ -0,0 +1,69 @@ +package systems.alexander.bellsandwhistles.block.custom; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.AttachFace; +import net.minecraft.world.phys.shapes.BooleanOp; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; + +public class HeadlightBlock extends FaceAttachedHorizontalDirectionalBlock { + public HeadlightBlock(Properties pProperties) { + super(pProperties); + this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(FACE, AttachFace.WALL)); + } + + + + protected void createBlockStateDefinition(StateDefinition.Builder pBuilder) { + pBuilder.add(FACING, FACE); + } + + public float getShadeBrightness(BlockState pState, BlockGetter pLevel, BlockPos pPos) { + return 1.0F; + } + + public boolean propagatesSkylightDown(BlockState pState, BlockGetter pReader, BlockPos pPos) { + return true; + } + private static final VoxelShape SHAPE = Shapes.join(Block.box(4.5, 4.5, 13, 11.5, 11.5, 16), Block.box(4, 4, 14, 12, 12, 16), BooleanOp.OR); + + public static VoxelShape rotateShape(Direction from, Direction to, VoxelShape shape) { + VoxelShape[] buffer = new VoxelShape[]{shape, Shapes.empty()}; + + int times = (to.ordinal() - from.get2DDataValue() + 4) % 4; + for (int i = 0; i < times; i++) { + buffer[0].forAllBoxes((minX, minY, minZ, maxX, maxY, maxZ) -> buffer[1] = Shapes.or(buffer[1], Shapes.create(1 - maxZ, minY, minX, 1 - minZ, maxY, maxX))); + buffer[0] = buffer[1]; + buffer[1] = Shapes.empty(); + } + + return buffer[0]; + } + @Override + public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) { + if (pState.getValue(FACE) == AttachFace.FLOOR) { + return Shapes.join(Block.box(4.5, 0, 5, 11.5, 3, 12), Block.box(4, 0, 4.5, 12, 2, 12.5), BooleanOp.OR); + } else if (pState.getValue(FACE) == AttachFace.CEILING) { + return Shapes.join(Block.box(4.5, 13, 5, 11.5, 16, 12), Block.box(4, 14, 4.5, 12, 16, 12.5), BooleanOp.OR); + } else { + switch ((Direction) pState.getValue(FACING)) { + case NORTH: + return SHAPE; + case SOUTH: + return rotateShape(Direction.NORTH, Direction.WEST, SHAPE); + case WEST: + return rotateShape(Direction.NORTH, Direction.EAST, SHAPE); + case EAST: + default: + return rotateShape(Direction.NORTH, Direction.SOUTH, SHAPE); + } + } + } +} diff --git a/src/main/resources/assets/bellsandwhistles/blockstates/headlight.json b/src/main/resources/assets/bellsandwhistles/blockstates/headlight.json new file mode 100644 index 0000000..892925b --- /dev/null +++ b/src/main/resources/assets/bellsandwhistles/blockstates/headlight.json @@ -0,0 +1,26 @@ +{ + "variants": { + "face=ceiling": { + "model": "bellsandwhistles:block/headlight/headlight_floor", + "x": 180 + }, + "facing=east": { + "model": "bellsandwhistles:block/headlight/headlight_wall", + "y": 270 + }, + "facing=north": { + "model": "bellsandwhistles:block/headlight/headlight_wall", + "y": 180 + }, + "facing=south": { + "model": "bellsandwhistles:block/headlight/headlight_wall" + }, + "face=floor": { + "model": "bellsandwhistles:block/headlight/headlight_floor" + }, + "facing=west": { + "model": "bellsandwhistles:block/headlight/headlight_wall", + "y": 90 + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/bellsandwhistles/models/block/headlight/headlight_floor.json b/src/main/resources/assets/bellsandwhistles/models/block/headlight/headlight_floor.json new file mode 100644 index 0000000..d4dc293 --- /dev/null +++ b/src/main/resources/assets/bellsandwhistles/models/block/headlight/headlight_floor.json @@ -0,0 +1,59 @@ +{ + "credit": "Made with Blockbench", + "textures": { + "1": "bellsandwhistles:block/headlight", + "particle": "bellsandwhistles:block/headlight" + }, + "elements": [ + { + "name": "lampy-part", + "from": [4.5, 0, 5], + "to": [11.5, 3, 12], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 1.5, 8.5]}, + "faces": { + "north": {"uv": [0, 0, 7, 1], "rotation": 270, "texture": "#1"}, + "east": {"uv": [0, 0, 1, 7], "rotation": 270, "texture": "#1"}, + "south": {"uv": [0, 0, 7, 1], "rotation": 270, "texture": "#1"}, + "west": {"uv": [0, 0, 1, 7], "rotation": 90, "texture": "#1"}, + "up": {"uv": [0, 0, 7, 7], "rotation": 180, "texture": "#1"}, + "down": {"uv": [7, 0, 14, 7], "rotation": 90, "texture": "#1"} + } + }, + { + "name": "overlay", + "from": [4.25, -0.25, 4.75], + "to": [11.75, 3.25, 12.25], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 1.5, 8.5]}, + "faces": { + "north": {"uv": [7, 9, 14, 12], "texture": "#1"}, + "east": {"uv": [7, 9, 14, 12], "texture": "#1"}, + "south": {"uv": [7, 9, 14, 12], "rotation": 180, "texture": "#1"}, + "west": {"uv": [7, 9, 14, 12], "texture": "#1"}, + "up": {"uv": [0, 7, 7, 14], "rotation": 180, "texture": "#1"}, + "down": {"uv": [0, 7, 7, 14], "rotation": 90, "texture": "#1"} + } + }, + { + "name": "base", + "from": [4, 0, 4.5], + "to": [12, 2, 12.5], + "rotation": {"angle": -45, "axis": "y", "origin": [8, 1.5, 8.5]}, + "faces": { + "north": {"uv": [7, 0, 15, 2], "rotation": 90, "texture": "#1"}, + "east": {"uv": [7, 0, 9, 8], "rotation": 270, "texture": "#1"}, + "south": {"uv": [7, 0, 15, 2], "rotation": 90, "texture": "#1"}, + "west": {"uv": [13, 0, 15, 8], "rotation": 90, "texture": "#1"}, + "up": {"uv": [7, 0, 15, 8], "rotation": 180, "texture": "#1"}, + "down": {"uv": [7, 0, 15, 8], "rotation": 90, "texture": "#1"} + } + } + ], + "groups": [ + { + "name": "lamp", + "origin": [8, 8, 8], + "color": 0, + "children": [0, 1, 2] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/bellsandwhistles/models/block/headlight/headlight_wall.json b/src/main/resources/assets/bellsandwhistles/models/block/headlight/headlight_wall.json new file mode 100644 index 0000000..30d5aec --- /dev/null +++ b/src/main/resources/assets/bellsandwhistles/models/block/headlight/headlight_wall.json @@ -0,0 +1,97 @@ +{ + "credit": "Made with Blockbench", + "textures": { + "1": "bellsandwhistles:block/headlight", + "particle": "bellsandwhistles:block/headlight" + }, + "elements": [ + { + "name": "lampy-part", + "from": [4.5, 4.5, 13], + "to": [11.5, 11.5, 16], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 14.5]}, + "faces": { + "north": {"uv": [0, 0, 7, 7], "texture": "#1"}, + "east": {"uv": [0, 0, 1, 7], "texture": "#1"}, + "south": {"uv": [7, 0, 14, 7], "rotation": 90, "texture": "#1"}, + "west": {"uv": [0, 0, 1, 7], "texture": "#1"}, + "up": {"uv": [0, 0, 7, 1], "rotation": 270, "texture": "#1"}, + "down": {"uv": [0, 0, 7, 1], "rotation": 90, "texture": "#1"} + } + }, + { + "name": "overlay", + "from": [4.25, 4.25, 12.75], + "to": [11.75, 11.75, 16.25], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 14.5]}, + "faces": { + "north": {"uv": [0, 7, 7, 14], "texture": "#1"}, + "east": {"uv": [7, 9, 14, 12], "rotation": 90, "texture": "#1"}, + "south": {"uv": [0, 7, 7, 14], "rotation": 90, "texture": "#1"}, + "west": {"uv": [7, 9, 14, 12], "rotation": 270, "texture": "#1"}, + "up": {"uv": [7, 9, 14, 12], "rotation": 180, "texture": "#1"}, + "down": {"uv": [7, 9, 14, 12], "rotation": 180, "texture": "#1"} + } + }, + { + "name": "base", + "from": [4, 4, 14], + "to": [12, 12, 16], + "rotation": {"angle": 45, "axis": "z", "origin": [8, 8, 14.5]}, + "faces": { + "north": {"uv": [7, 0, 15, 8], "texture": "#1"}, + "east": {"uv": [7, 0, 9, 8], "texture": "#1"}, + "south": {"uv": [7, 0, 15, 8], "rotation": 90, "texture": "#1"}, + "west": {"uv": [13, 0, 15, 8], "texture": "#1"}, + "up": {"uv": [7, 0, 15, 2], "rotation": 90, "texture": "#1"}, + "down": {"uv": [7, 0, 15, 2], "rotation": 270, "texture": "#1"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 56, 0], + "translation": [0, 1.5, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 56, 0], + "translation": [-0.75, 1.5, -0.5], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, -4.5], + "scale": [0.5, 0.5, 0.5] + }, + "gui": { + "rotation": [30, 225, 0], + "translation": [6, -2.75, 0], + "scale": [1.25, 1.25, 1.25] + }, + "head": { + "translation": [0, 5, -14] + }, + "fixed": { + "translation": [0, 0, -14.75], + "scale": [2, 2, 2] + } + }, + "groups": [ + { + "name": "lamp", + "origin": [8, 8, 8], + "color": 0, + "children": [0, 1, 2] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/bellsandwhistles/models/item/corrugated_metro_panel.json b/src/main/resources/assets/bellsandwhistles/models/item/corrugated_metro_panel.json new file mode 100644 index 0000000..481304e --- /dev/null +++ b/src/main/resources/assets/bellsandwhistles/models/item/corrugated_metro_panel.json @@ -0,0 +1,3 @@ +{ + "parent": "bellsandwhistles:block/metro/corrugated_panel/block_side" +} \ No newline at end of file diff --git a/src/main/resources/assets/bellsandwhistles/models/item/headlight.json b/src/main/resources/assets/bellsandwhistles/models/item/headlight.json new file mode 100644 index 0000000..d24131c --- /dev/null +++ b/src/main/resources/assets/bellsandwhistles/models/item/headlight.json @@ -0,0 +1,3 @@ +{ + "parent": "bellsandwhistles:block/headlight/headlight_wall" +} \ No newline at end of file diff --git a/src/main/resources/assets/bellsandwhistles/models/item/metro_panel.json b/src/main/resources/assets/bellsandwhistles/models/item/metro_panel.json new file mode 100644 index 0000000..3918c21 --- /dev/null +++ b/src/main/resources/assets/bellsandwhistles/models/item/metro_panel.json @@ -0,0 +1,3 @@ +{ + "parent": "bellsandwhistles:block/metro/panel/block_side" +} \ No newline at end of file diff --git a/src/main/resources/assets/bellsandwhistles/textures/block/folding_metro_door_top.png b/src/main/resources/assets/bellsandwhistles/textures/block/folding_metro_door_top.png new file mode 100644 index 0000000000000000000000000000000000000000..45fd37b078129725ccbcb8d6d2829ffe236928d8 GIT binary patch literal 486 zcmV@P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!T3-A=Y01F!fufYQ#bxbD)BqS1UsoFHDav|qn zyKZD5@eQ$$fBV?yx1*hgVPjb)aCF^(x~`}#iUP{A0@t-EMo{CdRt0FIvr*%^9`tMn zOw*tRbyb3Hn2;?OkYyQoo(JAepBABplw}F?`5b6#Ts*v(kRUU=zoqtgaz(8S*L3{g z&dA;6SPOzcw75H-NTr$PZ`qW9Pr7-0YOc>ije?f_fe*evpng{q3CJ{7mplPk7dhm4 zPW`Ti9vFrJIyv4NrUJcj9EU~QV1lY@*J8ju=<=S#5XT9Nw%ICS-QKqfygu9Ru}ICI zCGcHTUgbZ@h`~8M^DqVHPWWOJdPgVOQi&s)uTV}zhDU>!QiN7!yA_IE_{7{z+qsqkqybS c-kuPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!2kdb!2!6DYwZ940cuG^K~y+T&5}(| z!axv)-&^h`pOK811trQIzo?QdgcuY%%gkr&e`!Z1W2Kj3>F zTl)9C0s3z5TR`MYnCr_xc4{})VC1u$wC!1Gi%{jVK;TJ?-W?7E-2sAuWS)NHG