Compare commits

...

1 Commits

Author SHA1 Message Date
Shadowfacts 24b7896151
Add actual Redstone Controller model 2021-02-24 18:58:22 -05:00
9 changed files with 164 additions and 32 deletions

View File

@ -27,14 +27,14 @@ class RedstoneControllerBlock: FaceDeviceBlock<RedstoneControllerBlockEntity>(Se
} }
// todo: don't just copy this from the Interface block // todo: don't just copy this from the Interface block
override val faceThickness = 2.0 override val faceThickness = 3.0
override val faceShapes = mapOf( override val faceShapes = mapOf(
Direction.DOWN to createCuboidShape(0.0, 0.0, 0.0, 16.0, 2.0, 16.0), Direction.DOWN to createCuboidShape(0.0, 0.0, 0.0, 16.0, 3.0, 16.0),
Direction.UP to createCuboidShape(0.0, 14.0, 0.0, 16.0, 16.0, 16.0), Direction.UP to createCuboidShape(0.0, 13.0, 0.0, 16.0, 16.0, 16.0),
Direction.NORTH to createCuboidShape(0.0, 0.0, 0.0, 16.0, 16.0, 2.0), Direction.NORTH to createCuboidShape(0.0, 0.0, 0.0, 16.0, 16.0, 3.0),
Direction.SOUTH to createCuboidShape(0.0, 0.0, 14.0, 16.0, 16.0, 16.0), Direction.SOUTH to createCuboidShape(0.0, 0.0, 13.0, 16.0, 16.0, 16.0),
Direction.WEST to createCuboidShape(0.0, 0.0, 0.0, 2.0, 16.0, 16.0), Direction.WEST to createCuboidShape(0.0, 0.0, 0.0, 3.0, 16.0, 16.0),
Direction.EAST to createCuboidShape(14.0, 0.0, 0.0, 16.0, 16.0, 16.0) Direction.EAST to createCuboidShape(13.0, 0.0, 0.0, 16.0, 16.0, 16.0)
) )
override fun appendProperties(builder: StateManager.Builder<Block, BlockState>) { override fun appendProperties(builder: StateManager.Builder<Block, BlockState>) {
@ -55,21 +55,11 @@ class RedstoneControllerBlock: FaceDeviceBlock<RedstoneControllerBlockEntity>(Se
val wasLit = state[LIT] val wasLit = state[LIT]
val isLit = isPowered(world, pos, state[FACING]) val isLit = isPowered(world, pos, state[FACING])
if (wasLit != isLit) { if (wasLit != isLit) {
if (wasLit) { toggleLit(state, world, pos)
world.blockTickScheduler.schedule(pos, this, 4)
} else {
toggleLit(state, world, pos)
}
} }
} }
} }
override fun scheduledTick(state: BlockState, world: ServerWorld, pos: BlockPos, random: Random) {
if (state[LIT] && !isPowered(world, pos, state[FACING])) {
toggleLit(state, world, pos)
}
}
private fun isPowered(world: World, pos: BlockPos, facing: Direction): Boolean { private fun isPowered(world: World, pos: BlockPos, facing: Direction): Boolean {
val offset = pos.offset(facing) val offset = pos.offset(facing)
return world.getEmittedRedstonePower(offset, facing) > 0 return world.getEmittedRedstonePower(offset, facing) > 0

View File

@ -4,28 +4,52 @@
"apply": { "model": "phycon:block/cable_center" } "apply": { "model": "phycon:block/cable_center" }
}, },
{ {
"when": { "facing": "down", "lit": "true|false" }, "when": { "facing": "down", "lit": "false" },
"apply": { "model": "phycon:block/interface_side" } "apply": { "model": "phycon:block/redstone_controller_side_off" }
}, },
{ {
"when": { "facing": "up", "lit": "true|false" }, "when": { "facing": "up", "lit": "false" },
"apply": { "model": "phycon:block/interface_side", "x": 180 } "apply": { "model": "phycon:block/redstone_controller_side_off", "x": 180 }
}, },
{ {
"when": { "facing": "north", "lit": "true|false" }, "when": { "facing": "north", "lit": "false" },
"apply": { "model": "phycon:block/interface_side", "x": 270 } "apply": { "model": "phycon:block/redstone_controller_side_off", "x": 270 }
}, },
{ {
"when": { "facing": "south", "lit": "true|false" }, "when": { "facing": "south", "lit": "false" },
"apply": { "model": "phycon:block/interface_side", "x": 90 } "apply": { "model": "phycon:block/redstone_controller_side_off", "x": 90 }
}, },
{ {
"when": { "facing": "west", "lit": "true|false" }, "when": { "facing": "west", "lit": "false" },
"apply": { "model": "phycon:block/interface_side", "x": 90, "y": 90 } "apply": { "model": "phycon:block/redstone_controller_side_off", "x": 90, "y": 90 }
}, },
{ {
"when": { "facing": "east", "lit": "true|false" }, "when": { "facing": "east", "lit": "false" },
"apply": { "model": "phycon:block/interface_side", "x": 90, "y": 270 } "apply": { "model": "phycon:block/redstone_controller_side_off", "x": 90, "y": 270 }
},
{
"when": { "facing": "down", "lit": "true" },
"apply": { "model": "phycon:block/redstone_controller_side_on" }
},
{
"when": { "facing": "up", "lit": "true" },
"apply": { "model": "phycon:block/redstone_controller_side_on", "x": 180 }
},
{
"when": { "facing": "north", "lit": "true" },
"apply": { "model": "phycon:block/redstone_controller_side_on", "x": 270 }
},
{
"when": { "facing": "south", "lit": "true" },
"apply": { "model": "phycon:block/redstone_controller_side_on", "x": 90 }
},
{
"when": { "facing": "west", "lit": "true" },
"apply": { "model": "phycon:block/redstone_controller_side_on", "x": 90, "y": 90 }
},
{
"when": { "facing": "east", "lit": "true" },
"apply": { "model": "phycon:block/redstone_controller_side_on", "x": 90, "y": 270 }
}, },
{ {

View File

@ -1,6 +1,7 @@
{ {
"textures": { "textures": {
"center": "phycon:block/cable_cap_end" "center": "phycon:block/cable_cap_end",
"particle": "#center"
}, },
"elements": [ "elements": [
{ {

View File

@ -0,0 +1,33 @@
{
"parent": "block/block",
"textures": {
"cable": "phycon:block/cable_straight",
"front": "phycon:block/redstone_controller_front_off",
"back": "phycon:block/redstone_controller_back",
"side": "phycon:block/redstone_controller_back",
},
"elements": [
{
"from": [0, 0, 0],
"to": [16, 3, 16],
"faces": {
"down": { "texture": "#front" },
"up": { "texture": "#back" },
"north": { "texture": "#side" },
"south": { "texture": "#side" },
"west": { "texture": "#side" },
"east": { "texture": "#side" }
}
},
{
"from": [6, 3, 6],
"to": [10, 6, 10],
"faces": {
"north": { "texture": "#cable" },
"south": { "texture": "#cable" },
"west": { "texture": "#cable" },
"east": { "texture": "#cable" }
}
}
]
}

View File

@ -0,0 +1,33 @@
{
"parent": "block/block",
"textures": {
"cable": "phycon:block/cable_straight",
"front": "phycon:block/redstone_controller_front_on",
"back": "phycon:block/redstone_controller_back",
"side": "phycon:block/redstone_controller_back"
},
"elements": [
{
"from": [0, 0, 0],
"to": [16, 3, 16],
"faces": {
"down": { "texture": "#front" },
"up": { "texture": "#back" },
"north": { "texture": "#side" },
"south": { "texture": "#side" },
"west": { "texture": "#side" },
"east": { "texture": "#side" }
}
},
{
"from": [6, 3, 6],
"to": [10, 6, 10],
"faces": {
"north": { "texture": "#cable" },
"south": { "texture": "#cable" },
"west": { "texture": "#cable" },
"east": { "texture": "#cable" }
}
}
]
}

View File

@ -0,0 +1,51 @@
{
"parent": "block/block",
"textures": {
"front": "phycon:block/redstone_controller_front_off",
"back": "phycon:block/redstone_controller_back",
"side": "phycon:block/redstone_controller_back",
"cable_end": "phycon:block/cable_cap_end",
"cable_side": "phycon:block/cable_straight"
},
"elements": [
{
"_comment": "cable center",
"from": [6, 6, 3],
"to": [10, 10, 16],
"faces": {
"down": { "texture": "#cable_side" },
"up": { "texture": "#cable_side" },
"south": { "texture": "#cable_end" },
"west": { "texture": "#cable_side", "rotation": 90, "uv": [6, 0, 10, 16] },
"east": { "texture": "#cable_side", "rotation": 90, "uv": [6, 0, 10, 16] }
}
},
{
"_comment": "redstone controller side",
"from": [0, 0, 0],
"to": [16, 16, 3],
"faces": {
"down": { "texture": "#side" },
"up": { "texture": "#side" },
"north": { "texture": "#front" },
"south": { "texture": "#back" },
"west": { "texture": "#side" },
"east": { "texture": "#side" }
}
}
],
"_test": [
{
"_comment": "cable center",
"from": [6, 6, 3],
"to": [10, 10, 16],
"faces": {
"down": { "texture": "#cable_side", "rotation": 270, "uv": [4, 6, 10, 10] },
"up": { "texture": "#cable_side", "rotation": 90, "uv": [4, 6, 10, 10] },
"south": { "texture": "#cable_end" },
"west": { "texture": "#cable_side", "uv": [4, 6, 10, 10] },
"east": { "texture": "#cable_side", "rotation": 180, "uv": [4, 6, 10, 10] }
}
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 831 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 986 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB