mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Atomic NBT List
This commit is contained in:
parent
617066340b
commit
6dc3e74607
@ -58,6 +58,7 @@ public class Section {
|
|||||||
putValueIndexedPalette(data, i);
|
putValueIndexedPalette(data, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
palette.makeAtomic();
|
||||||
ByteArrayTag blockLight = sectionRoot.getByteArrayTag("BlockLight");
|
ByteArrayTag blockLight = sectionRoot.getByteArrayTag("BlockLight");
|
||||||
LongArrayTag blockStates = sectionRoot.getLongArrayTag("BlockStates");
|
LongArrayTag blockStates = sectionRoot.getLongArrayTag("BlockStates");
|
||||||
ByteArrayTag skyLight = sectionRoot.getByteArrayTag("SkyLight");
|
ByteArrayTag skyLight = sectionRoot.getByteArrayTag("SkyLight");
|
||||||
@ -171,9 +172,9 @@ public class Section {
|
|||||||
* This option should only be used moderately to avoid unnecessary recalculation of the palette indices.
|
* This option should only be used moderately to avoid unnecessary recalculation of the palette indices.
|
||||||
* Recalculating the Palette should only be executed once right before saving the Section to file.
|
* Recalculating the Palette should only be executed once right before saving the Section to file.
|
||||||
*/
|
*/
|
||||||
public synchronized void setBlockStateAt(int blockX, int blockY, int blockZ, CompoundTag state, boolean cleanup) {
|
public void setBlockStateAt(int blockX, int blockY, int blockZ, CompoundTag state, boolean cleanup) {
|
||||||
int paletteSizeBefore = palette.size();
|
|
||||||
int paletteIndex = addToPalette(state);
|
int paletteIndex = addToPalette(state);
|
||||||
|
int paletteSizeBefore = palette.size();
|
||||||
//power of 2 --> bits must increase, but only if the palette size changed
|
//power of 2 --> bits must increase, but only if the palette size changed
|
||||||
//otherwise we would attempt to update all blockstates and the entire palette
|
//otherwise we would attempt to update all blockstates and the entire palette
|
||||||
//every time an existing blockstate was added while having 2^x blockstates in the palette
|
//every time an existing blockstate was added while having 2^x blockstates in the palette
|
||||||
@ -377,7 +378,7 @@ public class Section {
|
|||||||
* @throws NullPointerException If <code>blockStates</code> is <code>null</code>
|
* @throws NullPointerException If <code>blockStates</code> is <code>null</code>
|
||||||
* @throws IllegalArgumentException When <code>blockStates</code>' length is < 256 or > 4096 and is not a multiple of 64
|
* @throws IllegalArgumentException When <code>blockStates</code>' length is < 256 or > 4096 and is not a multiple of 64
|
||||||
*/
|
*/
|
||||||
public synchronized void setBlockStates(AtomicLongArray blockStates) {
|
public void setBlockStates(AtomicLongArray blockStates) {
|
||||||
if (blockStates == null) {
|
if (blockStates == null) {
|
||||||
throw new NullPointerException("BlockStates cannot be null");
|
throw new NullPointerException("BlockStates cannot be null");
|
||||||
} else if (blockStates.length() % 64 != 0 || blockStates.length() < 256 || blockStates.length() > 4096) {
|
} else if (blockStates.length() % 64 != 0 || blockStates.length() < 256 || blockStates.length() > 4096) {
|
||||||
|
@ -22,6 +22,7 @@ import com.volmit.iris.engine.data.io.MaxDepthIO;
|
|||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,6 +43,12 @@ public class ListTag<T extends Tag<?>> extends Tag<List<T>> implements Iterable<
|
|||||||
super(createEmptyValue(3));
|
super(createEmptyValue(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ListTag<T> makeAtomic()
|
||||||
|
{
|
||||||
|
setValue(new CopyOnWriteArrayList<>(getValue()));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte getID() {
|
public byte getID() {
|
||||||
return ID;
|
return ID;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user