From 77427de11bdc7eaeba09c17314642219ed4a1c8f Mon Sep 17 00:00:00 2001 From: CreepyCre Date: Sun, 31 Jan 2021 20:33:52 +0100 Subject: [PATCH] fix SchematicRedstoneFixer add all redstone torch types to SchematicConverter --- .../dimdoors/util/schematic/Schematic.java | 3 -- .../util/schematic/SchematicConverter.java | 9 +++- .../schematic/SchematicRedstoneFixer.java | 50 +++++++++++++++++-- 3 files changed, 53 insertions(+), 9 deletions(-) diff --git a/src/main/schematics/org/dimdev/dimdoors/util/schematic/Schematic.java b/src/main/schematics/org/dimdev/dimdoors/util/schematic/Schematic.java index c42eecdd..e2478807 100644 --- a/src/main/schematics/org/dimdev/dimdoors/util/schematic/Schematic.java +++ b/src/main/schematics/org/dimdev/dimdoors/util/schematic/Schematic.java @@ -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(); } diff --git a/src/main/schematics/org/dimdev/dimdoors/util/schematic/SchematicConverter.java b/src/main/schematics/org/dimdev/dimdoors/util/schematic/SchematicConverter.java index 6ca5da72..461a8431 100644 --- a/src/main/schematics/org/dimdev/dimdoors/util/schematic/SchematicConverter.java +++ b/src/main/schematics/org/dimdev/dimdoors/util/schematic/SchematicConverter.java @@ -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") + "]"); + } + } } } diff --git a/src/main/schematics/org/dimdev/dimdoors/util/schematic/SchematicRedstoneFixer.java b/src/main/schematics/org/dimdev/dimdoors/util/schematic/SchematicRedstoneFixer.java index cc86af06..e56b5a43 100644 --- a/src/main/schematics/org/dimdev/dimdoors/util/schematic/SchematicRedstoneFixer.java +++ b/src/main/schematics/org/dimdev/dimdoors/util/schematic/SchematicRedstoneFixer.java @@ -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) {