fixed handling of double doors, fix #1535
This commit is contained in:
parent
75ddd6fb01
commit
eb2f436f42
1 changed files with 39 additions and 10 deletions
|
@ -11,13 +11,17 @@ package buildcraft.builders.schematics;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import buildcraft.api.blueprints.IBuilderContext;
|
import buildcraft.api.blueprints.IBuilderContext;
|
||||||
|
import buildcraft.api.blueprints.MappingRegistry;
|
||||||
import buildcraft.api.blueprints.SchematicBlock;
|
import buildcraft.api.blueprints.SchematicBlock;
|
||||||
|
|
||||||
public class SchematicDoor extends SchematicBlock {
|
public class SchematicDoor extends SchematicBlock {
|
||||||
|
|
||||||
final ItemStack stack;
|
final ItemStack stack;
|
||||||
|
|
||||||
|
int upperMeta = 0;
|
||||||
|
|
||||||
public SchematicDoor(ItemStack stack) {
|
public SchematicDoor(ItemStack stack) {
|
||||||
this.stack = stack;
|
this.stack = stack;
|
||||||
}
|
}
|
||||||
|
@ -31,23 +35,26 @@ public class SchematicDoor extends SchematicBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void rotateLeft(IBuilderContext context) {
|
public void rotateLeft(IBuilderContext context) {
|
||||||
|
meta = rotateMeta(meta);
|
||||||
|
upperMeta = rotateMeta(upperMeta);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int rotateMeta (int meta) {
|
||||||
int orientation = (meta & 3);
|
int orientation = (meta & 3);
|
||||||
int others = meta - orientation;
|
int others = meta - orientation;
|
||||||
|
|
||||||
switch (orientation) {
|
switch (orientation) {
|
||||||
case 0:
|
case 0:
|
||||||
meta = 1 + others;
|
return 1 + others;
|
||||||
break;
|
|
||||||
case 1:
|
case 1:
|
||||||
meta = 2 + others;
|
return 2 + others;
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
meta = 3 + others;
|
return meta = 3 + others;
|
||||||
break;
|
|
||||||
case 3:
|
case 3:
|
||||||
meta = 0 + others;
|
return 0 + others;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,10 +65,32 @@ public class SchematicDoor extends SchematicBlock {
|
||||||
@Override
|
@Override
|
||||||
public void writeToWorld(IBuilderContext context, int x, int y, int z) {
|
public void writeToWorld(IBuilderContext context, int x, int y, int z) {
|
||||||
context.world().setBlock(x, y, z, block, meta, 3);
|
context.world().setBlock(x, y, z, block, meta, 3);
|
||||||
context.world().setBlock(x, y + 1, z, block, meta + 8, 3);
|
context.world().setBlock(x, y + 1, z, block, upperMeta, 3);
|
||||||
|
|
||||||
context.world().setBlockMetadataWithNotify(x, y + 1, z, meta + 8, 3);
|
context.world().setBlockMetadataWithNotify(x, y + 1, z, upperMeta, 3);
|
||||||
context.world().setBlockMetadataWithNotify(x, y, z, meta, 3);
|
context.world().setBlockMetadataWithNotify(x, y, z, meta, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readFromWorld(IBuilderContext context, int x, int y, int z) {
|
||||||
|
super.readFromWorld(context, x, y, z);
|
||||||
|
|
||||||
|
if ((meta & 8) == 0) {
|
||||||
|
upperMeta = context.world().getBlockMetadata(x, y + 1, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToNBT(NBTTagCompound nbt, MappingRegistry registry) {
|
||||||
|
super.writeToNBT(nbt, registry);
|
||||||
|
|
||||||
|
nbt.setByte("upperMeta", (byte) upperMeta);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readFromNBT(NBTTagCompound nbt, MappingRegistry registry) {
|
||||||
|
super.readFromNBT(nbt, registry);
|
||||||
|
|
||||||
|
upperMeta = nbt.getByte("upperMeta");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue