Simple directional cable model
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
package dev.kleo.redstonerewired;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.block.WireOrientation;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
|
||||
public class CableBlock extends Block {
|
||||
|
||||
public static final BooleanProperty NORTH = BooleanProperty.of("north");
|
||||
public static final BooleanProperty SOUTH = BooleanProperty.of("south");
|
||||
public static final BooleanProperty EAST = BooleanProperty.of("east");
|
||||
public static final BooleanProperty WEST = BooleanProperty.of("west");
|
||||
|
||||
public CableBlock(AbstractBlock.Settings settings) {
|
||||
super(settings);
|
||||
this.setDefaultState(this.stateManager.getDefaultState()
|
||||
.with(NORTH, false)
|
||||
.with(SOUTH, false)
|
||||
.with(EAST, false)
|
||||
.with(WEST, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
builder.add(NORTH, SOUTH, EAST, WEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void neighborUpdate(BlockState state, World world, BlockPos pos, Block sourceBlock,
|
||||
WireOrientation wireOrientation, boolean notify) {
|
||||
boolean north = world.getBlockState(pos.north()).getBlock() instanceof CableBlock;
|
||||
boolean south = world.getBlockState(pos.south()).getBlock() instanceof CableBlock;
|
||||
boolean east = world.getBlockState(pos.east()).getBlock() instanceof CableBlock;
|
||||
boolean west = world.getBlockState(pos.west()).getBlock() instanceof CableBlock;
|
||||
|
||||
world.setBlockState(pos, state.with(NORTH, north)
|
||||
.with(SOUTH, south)
|
||||
.with(EAST, east)
|
||||
.with(WEST, west), 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
VoxelShape shape = Block.createCuboidShape(6, 0, 6, 10, 1, 10); // center post
|
||||
|
||||
if (state.get(NORTH))
|
||||
shape = VoxelShapes.union(shape, Block.createCuboidShape(6, 0, 0, 10, 1, 6));
|
||||
if (state.get(SOUTH))
|
||||
shape = VoxelShapes.union(shape, Block.createCuboidShape(6, 0, 10, 10, 1, 16));
|
||||
if (state.get(EAST))
|
||||
shape = VoxelShapes.union(shape, Block.createCuboidShape(10, 0, 6, 16, 1, 10));
|
||||
if (state.get(WEST))
|
||||
shape = VoxelShapes.union(shape, Block.createCuboidShape(0, 0, 6, 6, 1, 10));
|
||||
|
||||
return shape;
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ public class ModBlocks {
|
||||
|
||||
public static final Block CABLE = register(
|
||||
"cable",
|
||||
Block::new,
|
||||
CableBlock::new,
|
||||
AbstractBlock.Settings.create().sounds(BlockSoundGroup.COPPER),
|
||||
true);
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
{
|
||||
"variants": {
|
||||
"": { "model": "redstone-rewired:block/cable" }
|
||||
}
|
||||
"multipart": [
|
||||
{ "apply": { "model": "redstone-rewired:block/cable_core" } },
|
||||
|
||||
{ "when": { "north": "true" }, "apply": { "model": "redstone-rewired:block/cable_north" } },
|
||||
{ "when": { "south": "true" }, "apply": { "model": "redstone-rewired:block/cable_south" } },
|
||||
{ "when": { "east": "true" }, "apply": { "model": "redstone-rewired:block/cable_east" } },
|
||||
{ "when": { "west": "true" }, "apply": { "model": "redstone-rewired:block/cable_west" } }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"format_version": "1.21.6",
|
||||
"credit": "Made with Blockbench",
|
||||
"texture_size": [32, 32],
|
||||
"textures": {
|
||||
"0": "redstone-rewired:block/cable",
|
||||
"particle": "redstone-rewired:block/cable"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [6.75, 6.75, 6.75],
|
||||
"to": [9.25, 9.25, 9.25],
|
||||
"faces": {
|
||||
"north": {"uv": [3, 1.5, 4.5, 3], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 8, 1.5], "texture": "#0"},
|
||||
"south": {"uv": [3, 0, 4.5, 1.5], "texture": "#0"},
|
||||
"west": {"uv": [0, 1.5, 8, 3], "texture": "#0"},
|
||||
"up": {"uv": [1.5, 11, 0, 3], "texture": "#0"},
|
||||
"down": {"uv": [3, 3, 1.5, 11], "texture": "#0"}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"format_version": "1.21.6",
|
||||
"credit": "Made with Blockbench",
|
||||
"texture_size": [32, 32],
|
||||
"textures": {
|
||||
"0": "redstone-rewired:block/cable",
|
||||
"particle": "redstone-rewired:block/cable"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [9.25, 6.75, 6.75],
|
||||
"to": [16, 9.25, 9.25],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [6.75, 6.75, 6.75]},
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 8, 1.5], "texture": "#0"},
|
||||
"east": {"uv": [3, 4.5, 4.5, 6], "texture": "#0"},
|
||||
"south": {"uv": [0, 1.5, 8, 3], "texture": "#0"},
|
||||
"west": {"uv": [3, 3, 4.5, 4.5], "texture": "#0"},
|
||||
"up": {"uv": [1.5, 11, 0, 3], "rotation": 270, "texture": "#0"},
|
||||
"down": {"uv": [3, 3, 1.5, 11], "rotation": 90, "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [6.75, 6.75, 6.75],
|
||||
"to": [9.25, 9.25, 9.25],
|
||||
"faces": {
|
||||
"north": {"uv": [3, 1.5, 4.5, 3], "texture": "#missing"},
|
||||
"east": {"uv": [0, 0, 8, 1.5], "texture": "#missing"},
|
||||
"south": {"uv": [3, 0, 4.5, 1.5], "texture": "#missing"},
|
||||
"west": {"uv": [0, 1.5, 8, 3], "texture": "#missing"},
|
||||
"up": {"uv": [1.5, 11, 0, 3], "texture": "#missing"},
|
||||
"down": {"uv": [3, 3, 1.5, 11], "texture": "#missing"}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"format_version": "1.21.6",
|
||||
"credit": "Made with Blockbench",
|
||||
"texture_size": [32, 32],
|
||||
"textures": {
|
||||
"0": "redstone-rewired:block/cable",
|
||||
"particle": "redstone-rewired:block/cable"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [6.75, 6.75, 0],
|
||||
"to": [9.25, 9.25, 6.75],
|
||||
"faces": {
|
||||
"north": {"uv": [3, 3, 4.5, 4.5], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 8, 1.5], "texture": "#0"},
|
||||
"south": {"uv": [3, 4.5, 4.5, 6], "texture": "#0"},
|
||||
"west": {"uv": [0, 1.5, 8, 3], "texture": "#0"},
|
||||
"up": {"uv": [1.5, 11, 0, 3], "texture": "#0"},
|
||||
"down": {"uv": [3, 3, 1.5, 11], "texture": "#0"}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"format_version": "1.21.6",
|
||||
"credit": "Made with Blockbench",
|
||||
"texture_size": [32, 32],
|
||||
"textures": {
|
||||
"0": "redstone-rewired:block/cable",
|
||||
"particle": "redstone-rewired:block/cable"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [6.75, 6.75, 9.25],
|
||||
"to": [9.25, 9.25, 16],
|
||||
"faces": {
|
||||
"north": {"uv": [3, 3, 4.5, 4.5], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 8, 1.5], "texture": "#0"},
|
||||
"south": {"uv": [3, 4.5, 4.5, 6], "texture": "#0"},
|
||||
"west": {"uv": [0, 1.5, 8, 3], "texture": "#0"},
|
||||
"up": {"uv": [1.5, 11, 0, 3], "texture": "#0"},
|
||||
"down": {"uv": [3, 3, 1.5, 11], "texture": "#0"}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"format_version": "1.21.6",
|
||||
"credit": "Made with Blockbench",
|
||||
"texture_size": [32, 32],
|
||||
"textures": {
|
||||
"0": "redstone-rewired:block/cable",
|
||||
"particle": "redstone-rewired:block/cable"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [0, 6.75, 6.75],
|
||||
"to": [6.75, 9.25, 9.25],
|
||||
"rotation": {"angle": 0, "axis": "y", "origin": [6.75, 6.75, 6.75]},
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 8, 1.5], "texture": "#0"},
|
||||
"east": {"uv": [3, 4.5, 4.5, 6], "texture": "#0"},
|
||||
"south": {"uv": [0, 1.5, 8, 3], "texture": "#0"},
|
||||
"west": {"uv": [3, 3, 4.5, 4.5], "texture": "#0"},
|
||||
"up": {"uv": [1.5, 11, 0, 3], "rotation": 270, "texture": "#0"},
|
||||
"down": {"uv": [3, 3, 1.5, 11], "rotation": 90, "texture": "#0"}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user