Skip to content

Commit

Permalink
Door Step
Browse files Browse the repository at this point in the history
  • Loading branch information
a0a7 committed Sep 25, 2023
1 parent 5ff5b59 commit 8debb26
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ public static <T extends Block, P> NonNullFunction<BlockBuilder<T, P>, BlockBuil
() -> new MetalBogieStepsBlock(BlockBehaviour.Properties.copy(Blocks.LADDER).sound(SoundType.METAL).noOcclusion()));
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> ANDESITE_DOOR_STEP = registerBlock("andesite_door_step",
() -> new MetalBogieStepsBlock(BlockBehaviour.Properties.copy(Blocks.LADDER).sound(SoundType.METAL).noOcclusion()));
public static final RegistryObject<Block> BRASS_DOOR_STEP = registerBlock("brass_door_step",
() -> new MetalBogieStepsBlock(BlockBehaviour.Properties.copy(Blocks.LADDER).sound(SoundType.METAL).noOcclusion()));
public static final RegistryObject<Block> COPPER_DOOR_STEP = registerBlock("copper_door_step" +
"",
() -> 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)));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package systems.alexander.bellsandwhistles.block.custom;

import com.simibubi.create.content.decoration.MetalLadderBlock;
import com.simibubi.create.content.equipment.wrench.IWrenchable;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
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;

import java.util.stream.Stream;

public class MetalStepBlock extends MetalLadderBlock implements IWrenchable {
public MetalStepBlock(Properties pProperties) {
super(pProperties);
}
public float getShadeBrightness(BlockState pState, BlockGetter pLevel, BlockPos pPos) {
return 1.0F;
}

public boolean propagatesSkylightDown(BlockState pState, BlockGetter pReader, BlockPos pPos) {
return true;
}

@Override
public boolean isLadder(BlockState state, LevelReader level, BlockPos pos, LivingEntity entity) {
return super.isLadder(state, level, pos, entity);
}

private static final VoxelShape SHAPE = Block.box(1, -0.5, 12, 15, 0.5, 16);
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) {
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,34 @@
{
"variants": {
"facing=east,waterlogged=false": {
"model": "bellsandwhistles:block/andesite_step",
"y": 90
},
"facing=east,waterlogged=true": {
"model": "bellsandwhistles:block/andesite_step",
"y": 90
},
"facing=north,waterlogged=false": {
"model": "bellsandwhistles:block/andesite_step"
},
"facing=north,waterlogged=true": {
"model": "bellsandwhistles:block/andesite_step"
},
"facing=south,waterlogged=false": {
"model": "bellsandwhistles:block/andesite_step",
"y": 180
},
"facing=south,waterlogged=true": {
"model": "bellsandwhistles:block/andesite_step",
"y": 180
},
"facing=west,waterlogged=false": {
"model": "bellsandwhistles:block/andesite_step",
"y": 270
},
"facing=west,waterlogged=true": {
"model": "bellsandwhistles:block/andesite_step",
"y": 270
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"variants": {
"facing=east,waterlogged=false": {
"model": "bellsandwhistles:block/brass_step",
"y": 90
},
"facing=east,waterlogged=true": {
"model": "bellsandwhistles:block/brass_step",
"y": 90
},
"facing=north,waterlogged=false": {
"model": "bellsandwhistles:block/brass_step"
},
"facing=north,waterlogged=true": {
"model": "bellsandwhistles:block/brass_step"
},
"facing=south,waterlogged=false": {
"model": "bellsandwhistles:block/brass_step",
"y": 180
},
"facing=south,waterlogged=true": {
"model": "bellsandwhistles:block/brass_step",
"y": 180
},
"facing=west,waterlogged=false": {
"model": "bellsandwhistles:block/brass_step",
"y": 270
},
"facing=west,waterlogged=true": {
"model": "bellsandwhistles:block/brass_step",
"y": 270
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"variants": {
"facing=east,waterlogged=false": {
"model": "bellsandwhistles:block/copper_step",
"y": 90
},
"facing=east,waterlogged=true": {
"model": "bellsandwhistles:block/copper_step",
"y": 90
},
"facing=north,waterlogged=false": {
"model": "bellsandwhistles:block/copper_step"
},
"facing=north,waterlogged=true": {
"model": "bellsandwhistles:block/copper_step"
},
"facing=south,waterlogged=false": {
"model": "bellsandwhistles:block/copper_step",
"y": 180
},
"facing=south,waterlogged=true": {
"model": "bellsandwhistles:block/copper_step",
"y": 180
},
"facing=west,waterlogged=false": {
"model": "bellsandwhistles:block/copper_step",
"y": 270
},
"facing=west,waterlogged=true": {
"model": "bellsandwhistles:block/copper_step",
"y": 270
}
}
}

0 comments on commit 8debb26

Please sign in to comment.