From 660754511bc42f751e405d05cf3fae61151932e5 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Fri, 28 Dec 2018 00:47:48 +0000 Subject: [PATCH] Fix rotation of road schematics --- .../plot/generator/HybridPlotWorld.java | 42 +++---------------- 1 file changed, 6 insertions(+), 36 deletions(-) diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotWorld.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotWorld.java index a4d3317e5..1104e5c7e 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotWorld.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotWorld.java @@ -14,18 +14,16 @@ import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTagBuilder; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; +import com.sk89q.worldedit.extent.transform.BlockTransformExtent; import com.sk89q.worldedit.internal.helper.MCDirections; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.AffineTransform; -import com.sk89q.worldedit.registry.state.DirectionalProperty; -import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.world.block.BaseBlock; import java.io.File; import java.util.HashMap; -import java.util.Map; public class HybridPlotWorld extends ClassicPlotWorld { @@ -59,37 +57,11 @@ public class HybridPlotWorld extends ClassicPlotWorld { // FIXME depends on block ids // Possibly make abstract? public static BaseBlock rotate(BaseBlock id) { - Map, Object> stateMap = id.getStates(); - - if (stateMap != null) { - for (Map.Entry, Object> entry : stateMap.entrySet()) { - if (entry.getKey() instanceof DirectionalProperty) { - Direction dir = (Direction) entry.getValue(); - Property property = entry.getKey(); - switch (dir) { - case NORTH: - id = id.with(property, Direction.EAST); - break; - case EAST: - id = id.with(property, Direction.SOUTH); - break; - case SOUTH: - id = id.with(property, Direction.WEST); - break; - case WEST: - id = id.with(property, Direction.NORTH); - break; - } - } - } - return id; - } CompoundTag tag = id.getNbtData(); if (tag != null) { // Handle blocks which store their rotation in NBT - PlotSquared.log(tag.getValue().toString()); if (tag.containsKey("Rot")) { int rot = tag.asInt("Rot"); @@ -107,12 +79,12 @@ public class HybridPlotWorld extends ClassicPlotWorld { builder.putByte("Rot", (byte) MCDirections.toRotation(newDirection)); - return id.toBaseBlock(builder.build()); + id.setNbtData(builder.build()); } } } } - return id; + return BlockTransformExtent.transform(id, transform); } public Location getSignLocation(Plot plot) { @@ -202,8 +174,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { for (short x = 0; x < w3; x++) { for (short z = 0; z < l3; z++) { for (short y = 0; y < h3; y++) { - BaseBlock id = blockArrayClipboard3.getFullBlock(BlockVector3.at(x, y, z)) - .toBaseBlock(); + BaseBlock id = blockArrayClipboard3.getFullBlock(BlockVector3.at(x, y, z)); if (!id.getBlockType().getMaterial().isAir()) { addOverlayBlock((short) (x + shift + oddshift + centerShiftX), (short) (y + startY), (short) (z + shift + oddshift + centerShiftZ), @@ -267,13 +238,12 @@ public class HybridPlotWorld extends ClassicPlotWorld { for (short x = 0; x < w1; x++) { for (short z = 0; z < l1; z++) { for (short y = 0; y < h1; y++) { - BaseBlock id = - blockArrayClipboard1.getFullBlock(BlockVector3.at(x, y, z)).toBaseBlock(); + BaseBlock id = blockArrayClipboard1.getFullBlock(BlockVector3.at(x, y, z)); if (!id.getBlockType().getMaterial().isAir()) { addOverlayBlock((short) (x - shift), (short) (y + startY), (short) (z + shift + oddshift), id, false, h1); addOverlayBlock((short) (z + shift + oddshift), (short) (y + startY), - (short) (x - shift), id, true, h1); + (short) (shift - x), id, true, h1); } } }