diff --git a/src/main/kotlin/net/shadowfacts/phycon/network/block/redstone/RedstoneControllerBlock.kt b/src/main/kotlin/net/shadowfacts/phycon/network/block/redstone/RedstoneControllerBlock.kt index 5a9cb6e..51d4773 100644 --- a/src/main/kotlin/net/shadowfacts/phycon/network/block/redstone/RedstoneControllerBlock.kt +++ b/src/main/kotlin/net/shadowfacts/phycon/network/block/redstone/RedstoneControllerBlock.kt @@ -12,6 +12,7 @@ import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction import net.minecraft.world.BlockView import net.minecraft.world.World +import net.minecraft.world.WorldAccess import net.shadowfacts.phycon.PhysicalConnectivity import net.shadowfacts.phycon.network.FaceDeviceBlock import java.util.* @@ -27,14 +28,14 @@ class RedstoneControllerBlock: FaceDeviceBlock(Se } // todo: don't just copy this from the Interface block - override val faceThickness = 2.0 + override val faceThickness = 3.0 override val faceShapes = mapOf( - Direction.DOWN to createCuboidShape(0.0, 0.0, 0.0, 16.0, 2.0, 16.0), - Direction.UP to createCuboidShape(0.0, 14.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.SOUTH to createCuboidShape(0.0, 0.0, 14.0, 16.0, 16.0, 16.0), - Direction.WEST to createCuboidShape(0.0, 0.0, 0.0, 2.0, 16.0, 16.0), - Direction.EAST to createCuboidShape(14.0, 0.0, 0.0, 16.0, 16.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, 13.0, 0.0, 16.0, 16.0, 16.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, 13.0, 16.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(13.0, 0.0, 0.0, 16.0, 16.0, 16.0) ) override fun appendProperties(builder: StateManager.Builder) { @@ -49,27 +50,17 @@ class RedstoneControllerBlock: FaceDeviceBlock(Se return state.with(LIT, isPowered(context.world, context.blockPos, state[FACING])) } - // todo: does this need to be separate from getStateForNeighborUpdate? override fun neighborUpdate(state: BlockState, world: World, pos: BlockPos, neighborBlock: Block, neighborPos: BlockPos, bl: Boolean) { + // this can't be done in getStateForNeighborUpdate because getEmittedRedstonePower is defined in World not WorldAccess if (!world.isClient) { val wasLit = state[LIT] val isLit = isPowered(world, pos, state[FACING]) if (wasLit != isLit) { - if (wasLit) { - world.blockTickScheduler.schedule(pos, this, 4) - } else { - toggleLit(state, world, pos) - } + 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 { val offset = pos.offset(facing) return world.getEmittedRedstonePower(offset, facing) > 0 diff --git a/src/main/resources/assets/phycon/blockstates/redstone_controller.json b/src/main/resources/assets/phycon/blockstates/redstone_controller.json index 32abdb2..196adf8 100644 --- a/src/main/resources/assets/phycon/blockstates/redstone_controller.json +++ b/src/main/resources/assets/phycon/blockstates/redstone_controller.json @@ -4,28 +4,52 @@ "apply": { "model": "phycon:block/cable_center" } }, { - "when": { "facing": "down", "lit": "true|false" }, - "apply": { "model": "phycon:block/interface_side" } + "when": { "facing": "down", "lit": "false" }, + "apply": { "model": "phycon:block/redstone_controller_side_off" } }, { - "when": { "facing": "up", "lit": "true|false" }, - "apply": { "model": "phycon:block/interface_side", "x": 180 } + "when": { "facing": "up", "lit": "false" }, + "apply": { "model": "phycon:block/redstone_controller_side_off", "x": 180 } }, { - "when": { "facing": "north", "lit": "true|false" }, - "apply": { "model": "phycon:block/interface_side", "x": 270 } + "when": { "facing": "north", "lit": "false" }, + "apply": { "model": "phycon:block/redstone_controller_side_off", "x": 270 } }, { - "when": { "facing": "south", "lit": "true|false" }, - "apply": { "model": "phycon:block/interface_side", "x": 90 } + "when": { "facing": "south", "lit": "false" }, + "apply": { "model": "phycon:block/redstone_controller_side_off", "x": 90 } }, { - "when": { "facing": "west", "lit": "true|false" }, - "apply": { "model": "phycon:block/interface_side", "x": 90, "y": 90 } + "when": { "facing": "west", "lit": "false" }, + "apply": { "model": "phycon:block/redstone_controller_side_off", "x": 90, "y": 90 } }, { - "when": { "facing": "east", "lit": "true|false" }, - "apply": { "model": "phycon:block/interface_side", "x": 90, "y": 270 } + "when": { "facing": "east", "lit": "false" }, + "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 } }, { diff --git a/src/main/resources/assets/phycon/models/block/cable_center.json b/src/main/resources/assets/phycon/models/block/cable_center.json index 05ecfd8..cfda031 100644 --- a/src/main/resources/assets/phycon/models/block/cable_center.json +++ b/src/main/resources/assets/phycon/models/block/cable_center.json @@ -1,6 +1,7 @@ { "textures": { - "center": "phycon:block/cable_cap_end" + "center": "phycon:block/cable_cap_end", + "particle": "#center" }, "elements": [ { @@ -39,4 +40,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/phycon/models/block/redstone_controller_side_off.json b/src/main/resources/assets/phycon/models/block/redstone_controller_side_off.json new file mode 100644 index 0000000..2c26a3b --- /dev/null +++ b/src/main/resources/assets/phycon/models/block/redstone_controller_side_off.json @@ -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" } + } + } + ] +} diff --git a/src/main/resources/assets/phycon/models/block/redstone_controller_side_on.json b/src/main/resources/assets/phycon/models/block/redstone_controller_side_on.json new file mode 100644 index 0000000..65b44a4 --- /dev/null +++ b/src/main/resources/assets/phycon/models/block/redstone_controller_side_on.json @@ -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" } + } + } + ] +} diff --git a/src/main/resources/assets/phycon/models/item/redstone_controller.json b/src/main/resources/assets/phycon/models/item/redstone_controller.json new file mode 100644 index 0000000..e4bd117 --- /dev/null +++ b/src/main/resources/assets/phycon/models/item/redstone_controller.json @@ -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] } + } + } + ] +} diff --git a/src/main/resources/assets/phycon/textures/block/redstone_controller_back.png b/src/main/resources/assets/phycon/textures/block/redstone_controller_back.png new file mode 100644 index 0000000..14643d1 Binary files /dev/null and b/src/main/resources/assets/phycon/textures/block/redstone_controller_back.png differ diff --git a/src/main/resources/assets/phycon/textures/block/redstone_controller_front_off.png b/src/main/resources/assets/phycon/textures/block/redstone_controller_front_off.png new file mode 100644 index 0000000..7099eb9 Binary files /dev/null and b/src/main/resources/assets/phycon/textures/block/redstone_controller_front_off.png differ diff --git a/src/main/resources/assets/phycon/textures/block/redstone_controller_front_on.png b/src/main/resources/assets/phycon/textures/block/redstone_controller_front_on.png new file mode 100644 index 0000000..227353c Binary files /dev/null and b/src/main/resources/assets/phycon/textures/block/redstone_controller_front_on.png differ