joekaiser / practicalities

1 stars 3 forks source link

[1.8.8] Matter Transporter doesn't transport TileEntites correctly #38

Closed joekaiser closed 8 years ago

joekaiser commented 8 years ago

The Matter Trasnporter is working great for blocks, but if you move something with a TileEntity attached, it doesn't move the TileEntity right...or so it seems

  1. Put down a chest, and put a few blocks in it
  2. Pick up the chest with the matter trasnporter
  3. Place down the chest somewhere else.
  4. Open the chest, and see the items you put inside are gone

I have done a trace, and the contents of the inventory are being save in the transporter. I also saw the the call to TileEntity.createAndLoadEntity(tileEntityNbtData) is creating the TE with the correct inventory (the items are in the chest). Stepping through the code, worldIn.setTileEntity(targetPos, te); ends up doing a call into the Chunk and the reference to the chest from the chunk still has the inventory. Somewhere along the ling after the TileEntity is placed the inventory is removed.

It almost seems like the chest isn't being associated to the TileEntity and doesn't see it.

joekaiser commented 8 years ago

Here is a picture of the trace. The screenshot shows the the call the chunkTileEntityMap.put is being given an entity with an inventory. That inventory has a single item in it (In this case a grass block) but when the code finishes, the chest does not have that grass block

image

thecodewarrior commented 8 years ago

I fixed it but it'll be simpler not to have a whole pull request for it. replace the if(hasTE){} block with

TileEntity te = world.getTileEntity(targetPos);
if(te != null) {
    tileEntityNbtData.setInteger("x", targetPos.getX());
    tileEntityNbtData.setInteger("y", targetPos.getY());
    tileEntityNbtData.setInteger("z", targetPos.getZ());
    te.readFromNBT(tileEntityNbtData);
    te.markDirty();
    world.markBlockForUpdate(targetPos);
}
joekaiser commented 8 years ago

fixed by 9e9ba87