Skip to content

Commit

Permalink
Begin Headlight
Browse files Browse the repository at this point in the history
  • Loading branch information
a0a7 committed Sep 25, 2023
1 parent d3ca0c3 commit 8f81ee2
Show file tree
Hide file tree
Showing 10 changed files with 275 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@
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;
import systems.alexander.bellsandwhistles.item.ModItems;
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;
Expand Down Expand Up @@ -47,27 +45,30 @@ public static <T extends Block, P> NonNullFunction<BlockBuilder<T, P>, BlockBuil
public static final RegistryObject<Block> COPPER_BOGIE_STEPS = registerBlock("copper_bogie_steps",
() -> new MetalBogieStepsBlock(BlockBehaviour.Properties.copy(Blocks.LADDER).sound(SoundType.METAL).noOcclusion()));

public static final RegistryObject<Block> HEADLIGHT = registerBlock("headlight",
() -> new HeadlightBlock(BlockBehaviour.Properties.copy(Blocks.LANTERN).sound(SoundType.LANTERN)));

public static final RegistryObject<Block> METRO_CASING = registerBlock("metro_casing",
() -> new CasingBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL), true));

public static final RegistryObject<Block> CORRUGATED_METRO_CASING = registerBlock("corrugated_metro_casing",
() -> new CasingBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL), true));
public static final RegistryObject<Block> SLIDING_METRO_DOOR = registerBlock("sliding_metro_door",
() -> new SlidingDoorBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL).noOcclusion(), false));
public static final RegistryObject<Block> FOLDING_METRO_DOOR = registerBlock("folding_metro_door",
() -> new SlidingDoorBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL).noOcclusion(), true));
public static final RegistryObject<Block> METRO_TRAPDOOR = registerBlock("metro_trapdoor",
() -> new TrainTrapdoorBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL).noOcclusion()));

public static final RegistryObject<Block> METRO_WINDOW = registerBlock("metro_window",
() -> new TrapDoorBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL).noOcclusion()));

public static final RegistryObject<Block> METRO_PANEL = registerBlock("metro_panel",
() -> new PanelBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL).noOcclusion()));

public static final RegistryObject<Block> CORRUGATED_METRO_PANEL = registerBlock("corrugated_metro_panel",
() -> new PanelBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL).noOcclusion()));

public static final RegistryObject<Block> METRO_WINDOW = registerBlock("metro_window",
() -> new TrapDoorBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL).noOcclusion()));

public static final RegistryObject<Block> METRO_TRAPDOOR = registerBlock("metro_trapdoor",
() -> new TrainTrapdoorBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL).noOcclusion()));

public static final RegistryObject<Block> SLIDING_METRO_DOOR = registerBlock("sliding_metro_door",
() -> new SlidingDoorBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL).noOcclusion(), false));
public static final RegistryObject<Block> FOLDING_METRO_DOOR = registerBlock("folding_metro_door",
() -> new SlidingDoorBlock(BlockBehaviour.Properties.copy(Blocks.MOSSY_COBBLESTONE).sound(SoundType.METAL).noOcclusion(), true));

public static final RegistryObject<Block> METAL_PILOT = registerBlock("metal_pilot",
() -> new PilotBlock(BlockBehaviour.Properties.copy(Blocks.IRON_BLOCK).noOcclusion()));
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Block, BlockState> 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);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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
}
}
}
Original file line number Diff line number Diff line change
@@ -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]
}
]
}
Original file line number Diff line number Diff line change
@@ -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]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "bellsandwhistles:block/metro/corrugated_panel/block_side"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "bellsandwhistles:block/headlight/headlight_wall"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "bellsandwhistles:block/metro/panel/block_side"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8f81ee2

Please sign in to comment.