mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-29 13:05:41 +01:00
Fix rotation of road schematics
This commit is contained in:
parent
2846363a2c
commit
660754511b
@ -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<Property<?>, Object> stateMap = id.getStates();
|
||||
|
||||
if (stateMap != null) {
|
||||
for (Map.Entry<Property<?>, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user