diff --git a/core/src/main/java/com/boydti/fawe/object/HistoryExtent.java b/core/src/main/java/com/boydti/fawe/object/HistoryExtent.java index 95da4fac..7f3b779d 100644 --- a/core/src/main/java/com/boydti/fawe/object/HistoryExtent.java +++ b/core/src/main/java/com/boydti/fawe/object/HistoryExtent.java @@ -56,36 +56,33 @@ public class HistoryExtent extends AbstractDelegateExtent { @Override public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException { - if (extent.setBlock(x, y, z, block)) { - int combined = queue.getCombinedId4DataDebug(x, y, z, 0, session); - int id = (combined >> 4); - if (id == block.getId()) { - if (!FaweCache.hasData(id)) { - return false; - } - int data = combined & 0xF; - if (data == block.getData()) { - return false; - } + int combined = queue.getCombinedId4DataDebug(x, y, z, 0, session); + int id = (combined >> 4); + if (id == block.getId()) { + if (!FaweCache.hasData(id)) { + return false; } - if (!FaweCache.hasNBT(id)) { - if (FaweCache.hasNBT(block.getId())) { - this.changeSet.add(x, y, z, combined, block); - } else { - this.changeSet.add(x, y, z, combined, (block.getId() << 4) + block.getData()); - } - } else { - try { - CompoundTag tag = queue.getTileEntity(x, y, z); - this.changeSet.add(x, y, z, new BaseBlock(id, combined & 0xF, tag), block); - } catch (Throwable e) { - e.printStackTrace(); - this.changeSet.add(x, y, z, combined, block); - } + int data = combined & 0xF; + if (data == block.getData()) { + return false; } - return true; } - return false; + if (!FaweCache.hasNBT(id)) { + if (FaweCache.hasNBT(block.getId())) { + this.changeSet.add(x, y, z, combined, block); + } else { + this.changeSet.add(x, y, z, combined, (block.getId() << 4) + block.getData()); + } + } else { + try { + CompoundTag tag = queue.getTileEntity(x, y, z); + this.changeSet.add(x, y, z, new BaseBlock(id, combined & 0xF, tag), block); + } catch (Throwable e) { + e.printStackTrace(); + this.changeSet.add(x, y, z, combined, block); + } + } + return extent.setBlock(x, y, z, block); } @Override diff --git a/core/src/main/java/com/sk89q/worldedit/LocalSession.java b/core/src/main/java/com/sk89q/worldedit/LocalSession.java index 66e638e5..c11ddddd 100644 --- a/core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -448,6 +448,10 @@ public class LocalSession { if (editSession.size() == 0 || editSession.hasFastMode()) { return; } + FaweChangeSet changeSet = (FaweChangeSet) editSession.getChangeSet(); + if (changeSet.size() == 0) { + return; + } FawePlayer fp = editSession.getPlayer(); if (fp != null) { loadSessionHistoryFromDisk(fp.getUUID(), editSession.getWorld()); @@ -461,18 +465,17 @@ public class LocalSession { while (iter.hasNext()) { Object item = iter.next(); if (++i > cutoffIndex) { - FaweChangeSet changeSet; + FaweChangeSet oldChangeSet; if (item instanceof FaweChangeSet) { - changeSet = (FaweChangeSet) item; + oldChangeSet = (FaweChangeSet) item; } else { - changeSet = getChangeSet(item); + oldChangeSet = getChangeSet(item); } - historySize -= MainUtil.getSize(changeSet); + historySize -= MainUtil.getSize(oldChangeSet); iter.remove(); } } } - FaweChangeSet changeSet = (FaweChangeSet) editSession.getChangeSet(); historySize += MainUtil.getSize(changeSet); if (append) { history.add(changeSet);