Fix some undo/redo tile entity issues

This commit is contained in:
Jesse Boyd 2016-12-01 13:51:59 +11:00
parent 9f8a0456e3
commit 84fa07eec9
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
13 changed files with 22 additions and 9 deletions

View File

@ -162,7 +162,7 @@ public abstract class FaweChangeSet implements ChangeSet {
if (to.hasNbtData()) {
CompoundTag nbt = to.getNbtData();
MainUtil.setPosition(nbt, x, y, z);
addTileRemove(nbt);
addTileCreate(nbt);
}
int combinedFrom = (from.getId() << 4) + from.getData();
int combinedTo = (to.getId() << 4) + to.getData();
@ -182,7 +182,7 @@ public abstract class FaweChangeSet implements ChangeSet {
if (to.hasNbtData()) {
CompoundTag nbt = to.getNbtData();
MainUtil.setPosition(nbt, x, y, z);
addTileRemove(nbt);
addTileCreate(nbt);
}
int combinedTo = (to.getId() << 4) + to.getData();
add(x, y, z, combinedFrom, combinedTo);

View File

@ -352,6 +352,9 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
TileEntity tileEntity = nmsWorld.getTileEntity(pos);
if (tileEntity != null) {
NBTTagCompound tag = (NBTTagCompound) ForgeQueue_All.methodFromNative.invoke(null, nativeTag);
tag.setInteger("x", pos.getX());
tag.setInteger("y", pos.getY());
tag.setInteger("z", pos.getZ());
tileEntity.readFromNBT(tag); // ReadTagIntoTile
}
}

View File

@ -274,7 +274,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
for (Map.Entry<BlockPos, TileEntity> entry : tiles.entrySet()) {
TileEntity tile = entry.getValue();
NBTTagCompound tag = new NBTTagCompound();
tile.readFromNBT(tag); // readTileEntityIntoTag
tile.writeToNBT(tag); // readTileEntityIntoTag
BlockPos pos = entry.getKey();
CompoundTag nativeTag = (CompoundTag) methodToNative.invoke(null, tag);
previous.setTile(pos.getX(), pos.getY(), pos.getZ(), nativeTag);

View File

@ -49,7 +49,6 @@ public class ForgePlayer extends AbstractPlayerActor {
private final EntityPlayerMP player;
protected ForgePlayer(ForgePlatform platform, EntityPlayerMP player) {
System.out.println("New forge player!!!!");
this.platform = platform;
this.player = player;
ThreadSafeCache.getInstance().getOnlineIds().add(getUniqueId());

View File

@ -366,6 +366,9 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
TileEntity tileEntity = nmsWorld.getTileEntity(pos);
if (tileEntity != null) {
NBTTagCompound tag = (NBTTagCompound) ForgeQueue_All.methodFromNative.invoke(null, nativeTag);
tag.setInteger("x", pos.getX());
tag.setInteger("y", pos.getY());
tag.setInteger("z", pos.getZ());
tileEntity.readFromNBT(tag); // ReadTagIntoTile
}
}

View File

@ -274,7 +274,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
for (Map.Entry<BlockPos, TileEntity> entry : tiles.entrySet()) {
TileEntity tile = entry.getValue();
NBTTagCompound tag = new NBTTagCompound();
tile.readFromNBT(tag); // readTileEntityIntoTag
tile.writeToNBT(tag); // readTileEntityIntoTag
BlockPos pos = entry.getKey();
CompoundTag nativeTag = (CompoundTag) methodToNative.invoke(null, tag);
previous.setTile(pos.getX(), pos.getY(), pos.getZ(), nativeTag);

View File

@ -323,6 +323,9 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
TileEntity tileEntity = nmsWorld.getTileEntity(x, y, z);
if (tileEntity != null) {
NBTTagCompound tag = (NBTTagCompound) ForgeQueue_All.methodFromNative.invoke(null, nativeTag);
tag.setInteger("x", x);
tag.setInteger("y", x);
tag.setInteger("z", x);
tileEntity.readFromNBT(tag); // ReadTagIntoTile
}
}

View File

@ -320,7 +320,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
for (Map.Entry<ChunkPosition, TileEntity> entry : tiles.entrySet()) {
TileEntity tile = entry.getValue();
NBTTagCompound tag = new NBTTagCompound();
tile.readFromNBT(tag); // readTileEntityIntoTag
tile.writeToNBT(tag); // readTileEntityIntoTag
ChunkPosition pos = entry.getKey();
CompoundTag nativeTag = (CompoundTag) methodToNative.invoke(null, tag);
previous.setTile(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ, nativeTag);

View File

@ -266,6 +266,9 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
TileEntity tileEntity = nmsWorld.getTileEntity(pos);
if (tileEntity != null) {
NBTTagCompound tag = (NBTTagCompound) ForgeQueue_All.methodFromNative.invoke(null, nativeTag);
tag.setInteger("x", pos.getX());
tag.setInteger("y", pos.getY());
tag.setInteger("z", pos.getZ());
tileEntity.readFromNBT(tag); // ReadTagIntoTile
}
}

View File

@ -223,7 +223,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
for (Map.Entry<BlockPos, TileEntity> entry : tiles.entrySet()) {
TileEntity tile = entry.getValue();
NBTTagCompound tag = new NBTTagCompound();
tile.readFromNBT(tag); // readTileEntityIntoTag
tile.writeToNBT(tag); // readTileEntityIntoTag
BlockPos pos = entry.getKey();
CompoundTag nativeTag = (CompoundTag) methodToNative.invoke(null, tag);
previous.setTile(pos.getX(), pos.getY(), pos.getZ(), nativeTag);

View File

@ -350,6 +350,9 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
TileEntity tileEntity = nmsWorld.getTileEntity(pos);
if (tileEntity != null) {
NBTTagCompound tag = (NBTTagCompound) ForgeQueue_All.methodFromNative.invoke(null, nativeTag);
tag.setInteger("x", pos.getX());
tag.setInteger("y", pos.getY());
tag.setInteger("z", pos.getZ());
tileEntity.readFromNBT(tag); // ReadTagIntoTile
}
}

View File

@ -274,7 +274,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
for (Map.Entry<BlockPos, TileEntity> entry : tiles.entrySet()) {
TileEntity tile = entry.getValue();
NBTTagCompound tag = new NBTTagCompound();
tile.readFromNBT(tag); // readTileEntityIntoTag
tile.writeToNBT(tag); // readTileEntityIntoTag
BlockPos pos = entry.getKey();
CompoundTag nativeTag = (CompoundTag) methodToNative.invoke(null, tag);
previous.setTile(pos.getX(), pos.getY(), pos.getZ(), nativeTag);

View File

@ -49,7 +49,6 @@ public class ForgePlayer extends AbstractPlayerActor {
private final EntityPlayerMP player;
protected ForgePlayer(ForgePlatform platform, EntityPlayerMP player) {
System.out.println("New forge player!!!!");
this.platform = platform;
this.player = player;
ThreadSafeCache.getInstance().getOnlineIds().add(getUniqueId());