fixed gate rotation in schematic, close #1930
This commit is contained in:
parent
72b1a3cfe6
commit
f60595c821
1 changed files with 40 additions and 4 deletions
|
@ -26,6 +26,7 @@ import buildcraft.api.blueprints.SchematicTile;
|
||||||
import buildcraft.api.gates.IStatement;
|
import buildcraft.api.gates.IStatement;
|
||||||
import buildcraft.api.gates.StatementManager;
|
import buildcraft.api.gates.StatementManager;
|
||||||
import buildcraft.transport.BlockGenericPipe;
|
import buildcraft.transport.BlockGenericPipe;
|
||||||
|
import buildcraft.transport.Gate;
|
||||||
import buildcraft.transport.Pipe;
|
import buildcraft.transport.Pipe;
|
||||||
import buildcraft.transport.TileGenericPipe.SideProperties;
|
import buildcraft.transport.TileGenericPipe.SideProperties;
|
||||||
|
|
||||||
|
@ -58,9 +59,38 @@ public class SchematicPipe extends SchematicTile {
|
||||||
BptPipeExtension.get(pipeItem).rotateLeft(this, context);
|
BptPipeExtension.get(pipeItem).rotateLeft(this, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
NBTTagCompound gateNBT = tileNBT.getCompoundTag("Gate");
|
if (tileNBT.hasKey("Gate")) {
|
||||||
|
// This code is handling specifically BuildCraft 6.0 gates. Sided
|
||||||
|
// gates starting BuildCraft 6.1 work differently.
|
||||||
|
|
||||||
for (int i = 0; i < 8; ++i) {
|
NBTTagCompound gateNBT = tileNBT.getCompoundTag("Gate");
|
||||||
|
rotateGateLeft(gateNBT);
|
||||||
|
} else {
|
||||||
|
// Post 6.1 treatment
|
||||||
|
|
||||||
|
NBTTagCompound gatesNBT[] = new NBTTagCompound[6];
|
||||||
|
|
||||||
|
for (int i = 0; i < 6; ++i) {
|
||||||
|
if (tileNBT.hasKey("Gate[" + i + "]")) {
|
||||||
|
gatesNBT[i] = tileNBT.getCompoundTag("Gate[" + i + "]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 6; ++i) {
|
||||||
|
int newI = ForgeDirection.values()[i].getRotation(ForgeDirection.UP).ordinal();
|
||||||
|
|
||||||
|
if (gatesNBT[i] != null) {
|
||||||
|
rotateGateLeft(gatesNBT[i]);
|
||||||
|
tileNBT.setTag("Gate[" + newI + "]", gatesNBT[i]);
|
||||||
|
} else {
|
||||||
|
tileNBT.removeTag("Gate[" + newI + "]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rotateGateLeft(NBTTagCompound gateNBT) {
|
||||||
|
for (int i = 0; i < Gate.MAX_STATEMENTS; ++i) {
|
||||||
if (gateNBT.hasKey("trigger[" + i + "]")) {
|
if (gateNBT.hasKey("trigger[" + i + "]")) {
|
||||||
IStatement t = StatementManager.statements.get(gateNBT.getString("trigger[" + i + "]"));
|
IStatement t = StatementManager.statements.get(gateNBT.getString("trigger[" + i + "]"));
|
||||||
t = t.rotateLeft();
|
t = t.rotateLeft();
|
||||||
|
@ -73,6 +103,12 @@ public class SchematicPipe extends SchematicTile {
|
||||||
gateNBT.setString("action[" + i + "]", a.getUniqueTag());
|
gateNBT.setString("action[" + i + "]", a.getUniqueTag());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gateNBT.hasKey("direction")) {
|
||||||
|
gateNBT.setInteger("direction",
|
||||||
|
ForgeDirection.values()[gateNBT.getInteger("direction")].
|
||||||
|
getRotation(ForgeDirection.UP).ordinal());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue