Fixed #11072
This commit is contained in:
@@ -25,6 +25,14 @@ public class DrawOperation{
|
||||
return array.isEmpty();
|
||||
}
|
||||
|
||||
public int size(){
|
||||
return array.size;
|
||||
}
|
||||
|
||||
public void remove(int amount){
|
||||
array.setSize(Math.max(0, array.size - amount));
|
||||
}
|
||||
|
||||
public void addOperation(long op){
|
||||
array.add(op);
|
||||
}
|
||||
|
||||
@@ -157,11 +157,19 @@ public class MapEditor{
|
||||
if(!tester.get(tile)) return;
|
||||
boolean changed = false;
|
||||
|
||||
boolean didDataOp = false;
|
||||
int oldData1 = 0, oldData2 = 0;
|
||||
|
||||
if(drawBlock.saveData || tile.shouldSaveData()){
|
||||
addTileOp(TileOp.get(tile.x, tile.y, DrawOperation.opData, TileOpData.get(tile.data, tile.floorData, tile.overlayData)));
|
||||
addTileOp(TileOp.get(tile.x, tile.y, DrawOperation.opDataExtra, tile.extraData));
|
||||
oldData1 = TileOpData.get(tile.data, tile.floorData, tile.overlayData);
|
||||
oldData2 = tile.extraData;
|
||||
didDataOp = true;
|
||||
}
|
||||
|
||||
int preDataOps = ops();
|
||||
|
||||
if(isFloor){
|
||||
if(forceOverlay){
|
||||
tile.setOverlay(drawBlock.asFloor());
|
||||
@@ -189,6 +197,11 @@ public class MapEditor{
|
||||
drawBlock.placeEnded(tile, null, editor.rotation, drawBlock.lastConfig);
|
||||
renderer.updateStatic(tile.x, tile.y);
|
||||
}
|
||||
|
||||
//data and block did not change, undo the data ops
|
||||
if(didDataOp && ops() == preDataOps && oldData1 == TileOpData.get(tile.data, tile.floorData, tile.overlayData) && oldData2 == tile.extraData){
|
||||
removeLastOps(2);
|
||||
}
|
||||
};
|
||||
|
||||
if(square){
|
||||
@@ -397,6 +410,17 @@ public class MapEditor{
|
||||
renderer.updateStatic(TileOp.x(data), TileOp.y(data));
|
||||
}
|
||||
|
||||
public int ops(){
|
||||
if(currentOp == null) return 0;
|
||||
return currentOp.size();
|
||||
}
|
||||
|
||||
public void removeLastOps(int amount){
|
||||
if(currentOp == null || loading) return;
|
||||
|
||||
currentOp.remove(amount);
|
||||
}
|
||||
|
||||
class Context implements WorldContext{
|
||||
@Override
|
||||
public Tile tile(int index){
|
||||
|
||||
Reference in New Issue
Block a user