Compare commits
1 Commits
d621e9e089
...
7365faeca8
Author | SHA1 | Date |
---|---|---|
Shadowfacts | 7365faeca8 |
|
@ -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<RedstoneControllerBlockEntity>(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<Block, BlockState>) {
|
||||
|
@ -49,27 +50,17 @@ class RedstoneControllerBlock: FaceDeviceBlock<RedstoneControllerBlockEntity>(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
|
||||
|
|
|
@ -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 }
|
||||
},
|
||||
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"textures": {
|
||||
"center": "phycon:block/cable_cap_end"
|
||||
"center": "phycon:block/cable_cap_end",
|
||||
"particle": "#center"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
|
|
|
@ -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" }
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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" }
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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 |
Loading…
Reference in New Issue