From 4fe6391e693321cc2e51f316fe88bf46929aa3e3 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 1 Mar 2021 21:30:36 -0500 Subject: [PATCH] Use powered property for Redstone Controller instead of lit --- .../RedstoneControllerBlock.kt | 11 ++++----- .../RedstoneControllerBlockEntity.kt | 2 +- .../blockstates/redstone_controller.json | 24 +++++++++---------- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/main/kotlin/net/shadowfacts/phycon/block/redstone_controller/RedstoneControllerBlock.kt b/src/main/kotlin/net/shadowfacts/phycon/block/redstone_controller/RedstoneControllerBlock.kt index eb95702..de8af3b 100644 --- a/src/main/kotlin/net/shadowfacts/phycon/block/redstone_controller/RedstoneControllerBlock.kt +++ b/src/main/kotlin/net/shadowfacts/phycon/block/redstone_controller/RedstoneControllerBlock.kt @@ -26,10 +26,9 @@ class RedstoneControllerBlock: FaceDeviceBlock( companion object { val ID = Identifier(PhysicalConnectivity.MODID, "redstone_controller") - val LIT = Properties.LIT + val POWERED = Properties.POWERED } - // todo: don't just copy this from the Interface block override val faceThickness = 3.0 override val faceShapes = mapOf( Direction.DOWN to createCuboidShape(0.0, 0.0, 0.0, 16.0, 3.0, 16.0), @@ -42,20 +41,20 @@ class RedstoneControllerBlock: FaceDeviceBlock( override fun appendProperties(builder: StateManager.Builder) { super.appendProperties(builder) - builder.add(LIT) + builder.add(POWERED) } override fun createBlockEntity(world: BlockView) = RedstoneControllerBlockEntity() override fun getPlacementState(context: ItemPlacementContext): BlockState { val state = super.getPlacementState(context) - return state.with(LIT, isPowered(context.world, context.blockPos, state[FACING])) + return state.with(POWERED, isPowered(context.world, context.blockPos, state[FACING])) } 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 wasLit = state[POWERED] val isLit = isPowered(world, pos, state[FACING]) if (wasLit != isLit) { toggleLit(state, world, pos) @@ -69,7 +68,7 @@ class RedstoneControllerBlock: FaceDeviceBlock( } private fun toggleLit(state: BlockState, world: World, pos: BlockPos) { - world.setBlockState(pos, state.cycle(LIT), 2) + world.setBlockState(pos, state.cycle(POWERED), 2) getBlockEntity(world, pos)!!.redstoneStateChanged() } diff --git a/src/main/kotlin/net/shadowfacts/phycon/block/redstone_controller/RedstoneControllerBlockEntity.kt b/src/main/kotlin/net/shadowfacts/phycon/block/redstone_controller/RedstoneControllerBlockEntity.kt index 899c957..5932ed5 100644 --- a/src/main/kotlin/net/shadowfacts/phycon/block/redstone_controller/RedstoneControllerBlockEntity.kt +++ b/src/main/kotlin/net/shadowfacts/phycon/block/redstone_controller/RedstoneControllerBlockEntity.kt @@ -24,7 +24,7 @@ class RedstoneControllerBlockEntity: DeviceBlockEntity(PhyBlockEntities.REDSTONE fun redstoneStateChanged() { val oldPowered = redstonePowered - redstonePowered = cachedState[RedstoneControllerBlock.LIT] + redstonePowered = cachedState[RedstoneControllerBlock.POWERED] val mode: RemoteActivationPacket.Mode? = when (redstoneMode) { RedstoneMode.TOGGLE -> if (oldPowered != redstonePowered) RemoteActivationPacket.Mode.SINGLE else null diff --git a/src/main/resources/assets/phycon/blockstates/redstone_controller.json b/src/main/resources/assets/phycon/blockstates/redstone_controller.json index 196adf8..4eedd42 100644 --- a/src/main/resources/assets/phycon/blockstates/redstone_controller.json +++ b/src/main/resources/assets/phycon/blockstates/redstone_controller.json @@ -4,51 +4,51 @@ "apply": { "model": "phycon:block/cable_center" } }, { - "when": { "facing": "down", "lit": "false" }, + "when": { "facing": "down", "powered": "false" }, "apply": { "model": "phycon:block/redstone_controller_side_off" } }, { - "when": { "facing": "up", "lit": "false" }, + "when": { "facing": "up", "powered": "false" }, "apply": { "model": "phycon:block/redstone_controller_side_off", "x": 180 } }, { - "when": { "facing": "north", "lit": "false" }, + "when": { "facing": "north", "powered": "false" }, "apply": { "model": "phycon:block/redstone_controller_side_off", "x": 270 } }, { - "when": { "facing": "south", "lit": "false" }, + "when": { "facing": "south", "powered": "false" }, "apply": { "model": "phycon:block/redstone_controller_side_off", "x": 90 } }, { - "when": { "facing": "west", "lit": "false" }, + "when": { "facing": "west", "powered": "false" }, "apply": { "model": "phycon:block/redstone_controller_side_off", "x": 90, "y": 90 } }, { - "when": { "facing": "east", "lit": "false" }, + "when": { "facing": "east", "powered": "false" }, "apply": { "model": "phycon:block/redstone_controller_side_off", "x": 90, "y": 270 } }, { - "when": { "facing": "down", "lit": "true" }, + "when": { "facing": "down", "powered": "true" }, "apply": { "model": "phycon:block/redstone_controller_side_on" } }, { - "when": { "facing": "up", "lit": "true" }, + "when": { "facing": "up", "powered": "true" }, "apply": { "model": "phycon:block/redstone_controller_side_on", "x": 180 } }, { - "when": { "facing": "north", "lit": "true" }, + "when": { "facing": "north", "powered": "true" }, "apply": { "model": "phycon:block/redstone_controller_side_on", "x": 270 } }, { - "when": { "facing": "south", "lit": "true" }, + "when": { "facing": "south", "powered": "true" }, "apply": { "model": "phycon:block/redstone_controller_side_on", "x": 90 } }, { - "when": { "facing": "west", "lit": "true" }, + "when": { "facing": "west", "powered": "true" }, "apply": { "model": "phycon:block/redstone_controller_side_on", "x": 90, "y": 90 } }, { - "when": { "facing": "east", "lit": "true" }, + "when": { "facing": "east", "powered": "true" }, "apply": { "model": "phycon:block/redstone_controller_side_on", "x": 90, "y": 270 } },