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)
This commit is contained in:
wizjany 2013-03-30 15:48:06 -04:00
parent 2846119f08
commit e7ae3b4ddf
3 changed files with 10 additions and 10 deletions

View File

@ -253,7 +253,7 @@ public class DefaultNmsBlock extends NmsBlock {
// TileEntity te = craftWorld.getHandle().getTileEntity(x, y, z); // TileEntity te = craftWorld.getHandle().getTileEntity(x, y, z);
// craftWorld.getHandle().tileEntityList.remove(te); // 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) { if (block instanceof BaseBlock) {
world.copyToWorld(position, (BaseBlock) block); world.copyToWorld(position, (BaseBlock) block);

View File

@ -50,7 +50,7 @@ import com.sk89q.worldedit.foundation.Block;
/** /**
* Remapping tools are broken atm. * 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 final Logger logger = WorldEdit.logger;
private static Field compoundMapField; private static Field compoundMapField;
@ -86,7 +86,7 @@ public class MCPCPlusXNmsBlock_151 extends NmsBlock {
* @param data data value * @param data data value
* @param tileEntityBlock tile entity block * @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); super(type, data);
nbtData = (NBTTagCompound) fromNative(tileEntityBlock.getNbtData()); nbtData = (NBTTagCompound) fromNative(tileEntityBlock.getNbtData());
@ -100,7 +100,7 @@ public class MCPCPlusXNmsBlock_151 extends NmsBlock {
* @param data data value * @param data data value
* @param nbtData raw NBT data * @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); super(type, data);
this.nbtData = nbtData; this.nbtData = nbtData;
@ -164,7 +164,7 @@ public class MCPCPlusXNmsBlock_151 extends NmsBlock {
* @param data data value of block * @param data data value of block
* @return the block, or null * @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)) { if (!hasTileEntity(type)) {
return null; return null;
} }
@ -175,7 +175,7 @@ public class MCPCPlusXNmsBlock_151 extends NmsBlock {
if (te != null) { if (te != null) {
NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound tag = new NBTTagCompound();
te.func_70310_b(tag); // Load data te.func_70310_b(tag); // Load data
return new MCPCPlusXNmsBlock_151(type, data, tag); return new MCPCPlusXNmsBlock_151dv(type, data, tag);
} }
return null; return null;
@ -195,11 +195,11 @@ public class MCPCPlusXNmsBlock_151 extends NmsBlock {
return false; return false;
} }
if (block instanceof MCPCPlusXNmsBlock_151) { if (block instanceof MCPCPlusXNmsBlock_151dv) {
MCPCPlusXNmsBlock_151 nmsProxyBlock = (MCPCPlusXNmsBlock_151) block; MCPCPlusXNmsBlock_151dv nmsProxyBlock = (MCPCPlusXNmsBlock_151dv) block;
data = nmsProxyBlock.getNmsData(position); data = nmsProxyBlock.getNmsData(position);
} else if (block instanceof TileEntityBlock) { } else if (block instanceof TileEntityBlock) {
MCPCPlusXNmsBlock_151 nmsProxyBlock = new MCPCPlusXNmsBlock_151( MCPCPlusXNmsBlock_151dv nmsProxyBlock = new MCPCPlusXNmsBlock_151dv(
block.getId(), block.getData(), block); block.getId(), block.getData(), block);
data = nmsProxyBlock.getNmsData(position); data = nmsProxyBlock.getNmsData(position);
} }
@ -237,7 +237,7 @@ public class MCPCPlusXNmsBlock_151 extends NmsBlock {
// TileEntity te = craftWorld.getHandle().getTileEntity(x, y, z); // TileEntity te = craftWorld.getHandle().getTileEntity(x, y, z);
// craftWorld.getHandle().tileEntityList.remove(te); // 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) { if (block instanceof BaseBlock) {
world.copyToWorld(position, (BaseBlock) block); world.copyToWorld(position, (BaseBlock) block);