Fix identical states being recorded as a change

This commit is contained in:
Jesse Boyd 2016-10-04 01:37:23 +11:00
parent 47cbc2bc8c
commit c22063edb6
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
2 changed files with 32 additions and 32 deletions

View File

@ -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

View File

@ -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);