mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-28 21:56:33 +01:00
Fixes #357
This commit is contained in:
parent
6b0c2b9ef9
commit
24d61c2ceb
@ -61,12 +61,13 @@ public class CPUOptimizedClipboard extends FaweClipboard {
|
||||
}
|
||||
|
||||
public int getId(int index) {
|
||||
if (add != null) {
|
||||
return ids[index] & 0xFF + add[index] & 0xFF;
|
||||
}
|
||||
return ids[index] & 0xFF;
|
||||
}
|
||||
|
||||
public int getAdd(int index) {
|
||||
return add[index] & 0xFF;
|
||||
}
|
||||
|
||||
public int getData(int index) {
|
||||
return datas[index];
|
||||
}
|
||||
@ -128,6 +129,9 @@ public class CPUOptimizedClipboard extends FaweClipboard {
|
||||
|
||||
public BaseBlock getBlock(int index) {
|
||||
int id = getId(index);
|
||||
if (add != null) {
|
||||
id += getAdd(index) << 8;
|
||||
}
|
||||
if (id == 0) {
|
||||
return FaweCache.CACHE_BLOCK[0];
|
||||
}
|
||||
@ -178,8 +182,12 @@ public class CPUOptimizedClipboard extends FaweClipboard {
|
||||
}
|
||||
|
||||
public boolean setBlock(int index, BaseBlock block) {
|
||||
setId(index, (byte) block.getId());
|
||||
setData(index, (byte) block.getData());
|
||||
int id = block.getId();
|
||||
setId(index, id);
|
||||
setData(index, block.getData());
|
||||
if (id >= 256) {
|
||||
setAdd(index, (id >> 8));
|
||||
}
|
||||
CompoundTag tile = block.getNbtData();
|
||||
if (tile != null) {
|
||||
nbtMapIndex.put(index, tile);
|
||||
|
@ -94,11 +94,7 @@ public class MemoryOptimizedClipboard extends FaweClipboard {
|
||||
if (lastIds == null) {
|
||||
return 0;
|
||||
}
|
||||
if (add == null) {
|
||||
return lastIds[index & BLOCK_MASK] & 0xFF;
|
||||
} else {
|
||||
return lastIds[index & BLOCK_MASK] & 0xFF + getAdd(index);
|
||||
}
|
||||
return lastIds[index & BLOCK_MASK] & 0xFF;
|
||||
}
|
||||
saveIds();
|
||||
byte[] compressed = ids[lastIdsI = i];
|
||||
@ -107,11 +103,7 @@ public class MemoryOptimizedClipboard extends FaweClipboard {
|
||||
return 0;
|
||||
}
|
||||
lastIds = MainUtil.decompress(compressed, lastIds, BLOCK_SIZE, compressionLevel);
|
||||
if (add == null) {
|
||||
return lastIds[index & BLOCK_MASK] & 0xFF;
|
||||
} else {
|
||||
return lastIds[index & BLOCK_MASK] & 0xFF + getAdd(index);
|
||||
}
|
||||
return lastIds[index & BLOCK_MASK] & 0xFF;
|
||||
}
|
||||
|
||||
int saves = 0;
|
||||
@ -301,6 +293,9 @@ public class MemoryOptimizedClipboard extends FaweClipboard {
|
||||
|
||||
public BaseBlock getBlock(int index) {
|
||||
int id = getId(index);
|
||||
if (add != null) {
|
||||
id += getAdd(index) << 8;
|
||||
}
|
||||
if (id == 0) {
|
||||
return FaweCache.CACHE_BLOCK[0];
|
||||
}
|
||||
@ -369,8 +364,12 @@ public class MemoryOptimizedClipboard extends FaweClipboard {
|
||||
}
|
||||
|
||||
public boolean setBlock(int index, BaseBlock block) {
|
||||
setId(index, (byte) block.getId());
|
||||
setData(index, (byte) block.getData());
|
||||
int id = block.getId();
|
||||
setId(index, id);
|
||||
if (id >= 256) {
|
||||
setAdd(index, (id >> 8));
|
||||
}
|
||||
setData(index, block.getData());
|
||||
CompoundTag tile = block.getNbtData();
|
||||
if (tile != null) {
|
||||
nbtMapIndex.put(index, tile);
|
||||
|
Loading…
Reference in New Issue
Block a user