generated from neoforged/MDK
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/main/java/systems/alexander/bellsandwhistles/block/custom/MetalStepBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/resources/assets/bellsandwhistles/blockstates/andesite_door_step.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/resources/assets/bellsandwhistles/blockstates/brass_door_step.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/resources/assets/bellsandwhistles/blockstates/copper_door_step.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |