Permalink
Browse files

Fix setting blocks that used multiple TileEntities on one block id.

Since forge added support for this feature, we need to double-pass
on setting block data values to preserve both TileEntity type and
block orientations.
Users using MCPC may need to remove their old MCPC nmsblock class
before the new one is used correctly. (Although it was only added
in a dev build)
  • Loading branch information...
1 parent 2846119 commit e7ae3b4ddfdf0fe46e89bc0696cb8663f64561e3 @wizjany wizjany committed Mar 30, 2013
@@ -253,7 +253,7 @@ public static boolean setSafely(BukkitWorld world, Vector position,
// TileEntity te = craftWorld.getHandle().getTileEntity(x, y, z);
// craftWorld.getHandle().tileEntityList.remove(te);
- boolean changed = craftWorld.getHandle().setTypeIdAndData(x, y, z, block.getId(), 0, 0);
+ boolean changed = craftWorld.getHandle().setTypeIdAndData(x, y, z, block.getId(), block.getData(), 0);
if (block instanceof BaseBlock) {
world.copyToWorld(position, (BaseBlock) block);
@@ -50,7 +50,7 @@
/**
* Remapping tools are broken atm.
*/
-public class MCPCPlusXNmsBlock_151 extends NmsBlock {
+public class MCPCPlusXNmsBlock_151dv extends NmsBlock {
private static final Logger logger = WorldEdit.logger;
private static Field compoundMapField;
@@ -86,7 +86,7 @@ public static boolean verify() {
* @param data data value
* @param tileEntityBlock tile entity block
*/
- public MCPCPlusXNmsBlock_151(int type, int data, TileEntityBlock tileEntityBlock) {
+ public MCPCPlusXNmsBlock_151dv(int type, int data, TileEntityBlock tileEntityBlock) {
super(type, data);
nbtData = (NBTTagCompound) fromNative(tileEntityBlock.getNbtData());
@@ -100,7 +100,7 @@ public MCPCPlusXNmsBlock_151(int type, int data, TileEntityBlock tileEntityBlock
* @param data data value
* @param nbtData raw NBT data
*/
- public MCPCPlusXNmsBlock_151(int type, int data, NBTTagCompound nbtData) {
+ public MCPCPlusXNmsBlock_151dv(int type, int data, NBTTagCompound nbtData) {
super(type, data);
this.nbtData = nbtData;
@@ -164,7 +164,7 @@ public void setNbtData(CompoundTag tag) throws DataException {
* @param data data value of block
* @return the block, or null
*/
- public static MCPCPlusXNmsBlock_151 get(World world, Vector position, int type, int data) {
+ public static MCPCPlusXNmsBlock_151dv get(World world, Vector position, int type, int data) {
if (!hasTileEntity(type)) {
return null;
}
@@ -175,7 +175,7 @@ public static MCPCPlusXNmsBlock_151 get(World world, Vector position, int type,
if (te != null) {
NBTTagCompound tag = new NBTTagCompound();
te.func_70310_b(tag); // Load data
- return new MCPCPlusXNmsBlock_151(type, data, tag);
+ return new MCPCPlusXNmsBlock_151dv(type, data, tag);
}
return null;
@@ -195,11 +195,11 @@ public static boolean set(World world, Vector position, BaseBlock block) {
return false;
}
- if (block instanceof MCPCPlusXNmsBlock_151) {
- MCPCPlusXNmsBlock_151 nmsProxyBlock = (MCPCPlusXNmsBlock_151) block;
+ if (block instanceof MCPCPlusXNmsBlock_151dv) {
+ MCPCPlusXNmsBlock_151dv nmsProxyBlock = (MCPCPlusXNmsBlock_151dv) block;
data = nmsProxyBlock.getNmsData(position);
} else if (block instanceof TileEntityBlock) {
- MCPCPlusXNmsBlock_151 nmsProxyBlock = new MCPCPlusXNmsBlock_151(
+ MCPCPlusXNmsBlock_151dv nmsProxyBlock = new MCPCPlusXNmsBlock_151dv(
block.getId(), block.getData(), block);
data = nmsProxyBlock.getNmsData(position);
}
@@ -237,7 +237,7 @@ public static boolean setSafely(BukkitWorld world, Vector position,
// TileEntity te = craftWorld.getHandle().getTileEntity(x, y, z);
// craftWorld.getHandle().tileEntityList.remove(te);
- boolean changed = craftWorld.getHandle().func_72832_d(x, y, z, block.getId(), 0, 0);
+ boolean changed = craftWorld.getHandle().func_72832_d(x, y, z, block.getId(), block.getData(), 0);
if (block instanceof BaseBlock) {
world.copyToWorld(position, (BaseBlock) block);

0 comments on commit e7ae3b4

Please sign in to comment.