fix SchematicRedstoneFixer

add all redstone torch types to SchematicConverter
This commit is contained in:
CreepyCre 2021-01-31 20:33:52 +01:00
parent f39f68734e
commit 77427de11b
3 changed files with 53 additions and 9 deletions

View file

@ -455,9 +455,6 @@ public class Schematic implements BlockView {
if (setAir || !state.getBlock().equals(Blocks.AIR)) {
section.setBlockState(lx, ly, lz, state);
// BlockPos pos = new BlockPos(originX + x, originY + y, originZ + z);
// serverWorld.getChunkManager().markForUpdate(pos);
// serverWorld.getLightingProvider().checkBlock(pos);
if (y > 255) {
System.out.println();
}

View file

@ -231,6 +231,13 @@ public class SchematicConverter {
CONVERSIONS.put("minecraft:stonebrick", "minecraft:stone_bricks");
CONVERSIONS.put("minecraft:log[axis=z,variant=jungle]", "minecraft:jungle_log[axis=z]");
CONVERSIONS.put("minecraft:unlit_redstone_torch", "minecraft:redstone_torch[lit=false]");
//CONVERSIONS.put("minecraft:unlit_redstone_torch", "minecraft:redstone_torch[lit=false]");
for (boolean lit : new boolean[]{false, true}) {
CONVERSIONS.put("minecraft:" + (lit ? "" : "unlit_") + "redstone_torch", "minecraft:redstone_torch[lit=" + (lit ? "true" : "false") + "]");
for (String facing : new String[] {"north", "south", "east", "west"}) {
CONVERSIONS.put("minecraft:" + (lit ? "" : "unlit_") + "redstone_torch[facing=" + facing + "]", "minecraft:redstone_wall_torch[facing=" + facing + ",lit=" + (lit ? "true" : "false") + "]");
}
}
}
}

View file

@ -27,11 +27,51 @@ public class SchematicRedstoneFixer {
public static BlockState getPlacementState(BlockView world, BlockPos pos) {
return Blocks.REDSTONE_WIRE.getDefaultState()
.with(RedstoneWireBlock.WIRE_CONNECTION_WEST, getRenderConnectionType(world, pos, Direction.WEST))
.with(RedstoneWireBlock.WIRE_CONNECTION_EAST, getRenderConnectionType(world, pos, Direction.EAST))
.with(RedstoneWireBlock.WIRE_CONNECTION_NORTH, getRenderConnectionType(world, pos, Direction.NORTH))
.with(RedstoneWireBlock.WIRE_CONNECTION_SOUTH, getRenderConnectionType(world, pos, Direction.SOUTH));
WireConnection west = getRenderConnectionType(world, pos, Direction.WEST);
WireConnection east = getRenderConnectionType(world, pos, Direction.EAST);
WireConnection north = getRenderConnectionType(world, pos, Direction.NORTH);
WireConnection south = getRenderConnectionType(world, pos, Direction.SOUTH);
int connectionCount = 0;
if (west.isConnected()) connectionCount++;
if (east.isConnected()) connectionCount++;
if (north.isConnected()) connectionCount++;
if (south.isConnected()) connectionCount++;
switch (connectionCount) {
case 0: // should actually connect to all sides, forming a cross
return Blocks.REDSTONE_WIRE.getDefaultState()
.with(RedstoneWireBlock.WIRE_CONNECTION_WEST, WireConnection.SIDE)
.with(RedstoneWireBlock.WIRE_CONNECTION_EAST, WireConnection.SIDE)
.with(RedstoneWireBlock.WIRE_CONNECTION_NORTH, WireConnection.SIDE)
.with(RedstoneWireBlock.WIRE_CONNECTION_SOUTH, WireConnection.SIDE);
case 1: // should actually connect to the other side as well, forming a line
if (west.isConnected()) return Blocks.REDSTONE_WIRE.getDefaultState()
.with(RedstoneWireBlock.WIRE_CONNECTION_WEST, west)
.with(RedstoneWireBlock.WIRE_CONNECTION_EAST, WireConnection.SIDE)
.with(RedstoneWireBlock.WIRE_CONNECTION_NORTH, WireConnection.NONE)
.with(RedstoneWireBlock.WIRE_CONNECTION_SOUTH, WireConnection.NONE);
if (east.isConnected()) return Blocks.REDSTONE_WIRE.getDefaultState()
.with(RedstoneWireBlock.WIRE_CONNECTION_WEST, WireConnection.SIDE)
.with(RedstoneWireBlock.WIRE_CONNECTION_EAST, east)
.with(RedstoneWireBlock.WIRE_CONNECTION_NORTH, WireConnection.NONE)
.with(RedstoneWireBlock.WIRE_CONNECTION_SOUTH, WireConnection.NONE);
if (north.isConnected()) return Blocks.REDSTONE_WIRE.getDefaultState()
.with(RedstoneWireBlock.WIRE_CONNECTION_WEST, WireConnection.NONE)
.with(RedstoneWireBlock.WIRE_CONNECTION_EAST, WireConnection.NONE)
.with(RedstoneWireBlock.WIRE_CONNECTION_NORTH, north)
.with(RedstoneWireBlock.WIRE_CONNECTION_SOUTH, WireConnection.SIDE);
return Blocks.REDSTONE_WIRE.getDefaultState()
.with(RedstoneWireBlock.WIRE_CONNECTION_WEST, WireConnection.NONE)
.with(RedstoneWireBlock.WIRE_CONNECTION_EAST, WireConnection.NONE)
.with(RedstoneWireBlock.WIRE_CONNECTION_NORTH, WireConnection.SIDE)
.with(RedstoneWireBlock.WIRE_CONNECTION_SOUTH, south);
default:
return Blocks.REDSTONE_WIRE.getDefaultState()
.with(RedstoneWireBlock.WIRE_CONNECTION_WEST, getRenderConnectionType(world, pos, Direction.WEST))
.with(RedstoneWireBlock.WIRE_CONNECTION_EAST, getRenderConnectionType(world, pos, Direction.EAST))
.with(RedstoneWireBlock.WIRE_CONNECTION_NORTH, getRenderConnectionType(world, pos, Direction.NORTH))
.with(RedstoneWireBlock.WIRE_CONNECTION_SOUTH, getRenderConnectionType(world, pos, Direction.SOUTH));
}
}
private static WireConnection getRenderConnectionType(BlockView world, BlockPos pos, Direction direction) {