mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Save the get blocks to the set chunk after history is written when post-processing
This commit is contained in:
parent
f347e0f5f5
commit
b57c472b86
@ -357,13 +357,18 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
||||
if (!set.hasSection(layer)) {
|
||||
continue;
|
||||
}
|
||||
if (createCopy) {
|
||||
copy.storeSection(layer);
|
||||
}
|
||||
|
||||
bitMask |= 1 << layer;
|
||||
|
||||
char[] setArr = set.load(layer);
|
||||
// If we're creating a copy, it's because we're delaying history so we do not want to write to
|
||||
// the chunkSet yet.
|
||||
if (createCopy) {
|
||||
setArr = setArr.clone();
|
||||
copy.storeSection(layer);
|
||||
copy.storeSetBlocks(layer, setArr);
|
||||
}
|
||||
|
||||
ChunkSection newSection;
|
||||
ChunkSection existingSection = sections[layer];
|
||||
if (existingSection == null) {
|
||||
|
@ -2,6 +2,7 @@ package com.boydti.fawe.bukkit.adapter.mc1_15_2;
|
||||
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.beta.IChunkGetCopy;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_15_2.nbt.LazyCompoundTag_1_15_2;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
@ -28,12 +29,13 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitGetBlocks_1_15_2_Copy extends BukkitGetBlocks_1_15_2 {
|
||||
public class BukkitGetBlocks_1_15_2_Copy extends BukkitGetBlocks_1_15_2 implements IChunkGetCopy {
|
||||
|
||||
private final Map<BlockVector3, CompoundTag> tiles = new HashMap<>();
|
||||
private final Set<CompoundTag> entities = new HashSet<>();
|
||||
private BiomeStorage biomeStorage;
|
||||
private final char[][] blocks = new char[16][4096];
|
||||
private final char[][] newSetBlocks = new char[16][];
|
||||
|
||||
protected BukkitGetBlocks_1_15_2_Copy(WorldServer world, int X, int Z) {
|
||||
super(world, X, Z);
|
||||
@ -126,4 +128,13 @@ public class BukkitGetBlocks_1_15_2_Copy extends BukkitGetBlocks_1_15_2 {
|
||||
final int index = (y & 15) << 8 | z << 4 | x;
|
||||
return blocks[layer][index];
|
||||
}
|
||||
|
||||
protected void storeSetBlocks(int layer, char[] blocks) {
|
||||
newSetBlocks[layer] = blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getNewSetArr(int layer) {
|
||||
return newSetBlocks[layer];
|
||||
}
|
||||
}
|
||||
|
@ -357,13 +357,18 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
||||
if (!set.hasSection(layer)) {
|
||||
continue;
|
||||
}
|
||||
if (createCopy) {
|
||||
copy.storeSection(layer);
|
||||
}
|
||||
|
||||
bitMask |= 1 << layer;
|
||||
|
||||
char[] setArr = set.load(layer);
|
||||
// If we're creating a copy, it's because we're delaying history so we do not want to write to
|
||||
// the chunkSet yet.
|
||||
if (createCopy) {
|
||||
setArr = setArr.clone();
|
||||
copy.storeSection(layer);
|
||||
copy.storeSetBlocks(layer, setArr);
|
||||
}
|
||||
|
||||
ChunkSection newSection;
|
||||
ChunkSection existingSection = sections[layer];
|
||||
if (existingSection == null) {
|
||||
|
@ -2,6 +2,7 @@ package com.boydti.fawe.bukkit.adapter.mc1_16_1;
|
||||
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.beta.IChunkGetCopy;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_1.nbt.LazyCompoundTag_1_16_1;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
@ -29,12 +30,13 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitGetBlocks_1_16_1_Copy extends BukkitGetBlocks_1_16_1 {
|
||||
public class BukkitGetBlocks_1_16_1_Copy extends BukkitGetBlocks_1_16_1 implements IChunkGetCopy {
|
||||
|
||||
private final Map<BlockVector3, CompoundTag> tiles = new HashMap<>();
|
||||
private final Set<CompoundTag> entities = new HashSet<>();
|
||||
private BiomeStorage biomeStorage;
|
||||
private final char[][] blocks = new char[16][4096];
|
||||
private final char[][] newSetBlocks = new char[16][];
|
||||
|
||||
protected BukkitGetBlocks_1_16_1_Copy(WorldServer world, int X, int Z) {
|
||||
super(world, X, Z);
|
||||
@ -127,4 +129,13 @@ public class BukkitGetBlocks_1_16_1_Copy extends BukkitGetBlocks_1_16_1 {
|
||||
final int index = (y & 15) << 8 | z << 4 | x;
|
||||
return blocks[layer][index];
|
||||
}
|
||||
|
||||
protected void storeSetBlocks(int layer, char[] blocks) {
|
||||
newSetBlocks[layer] = blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getNewSetArr(int layer) {
|
||||
return newSetBlocks[layer];
|
||||
}
|
||||
}
|
||||
|
@ -360,13 +360,18 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
|
||||
if (!set.hasSection(layer)) {
|
||||
continue;
|
||||
}
|
||||
if (createCopy) {
|
||||
copy.storeSection(layer);
|
||||
}
|
||||
|
||||
bitMask |= 1 << layer;
|
||||
|
||||
char[] setArr = set.load(layer);
|
||||
// If we're creating a copy, it's because we're delaying history so we do not want to write to
|
||||
// the chunkSet yet.
|
||||
if (createCopy) {
|
||||
setArr = setArr.clone();
|
||||
copy.storeSection(layer);
|
||||
copy.storeSetBlocks(layer, setArr);
|
||||
}
|
||||
|
||||
ChunkSection newSection;
|
||||
ChunkSection existingSection = sections[layer];
|
||||
if (existingSection == null) {
|
||||
|
@ -2,6 +2,7 @@ package com.boydti.fawe.bukkit.adapter.mc1_16_2;
|
||||
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.beta.IChunkGetCopy;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_2.nbt.LazyCompoundTag_1_16_2;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
@ -29,12 +30,13 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitGetBlocks_1_16_2_Copy extends BukkitGetBlocks_1_16_2 {
|
||||
public class BukkitGetBlocks_1_16_2_Copy extends BukkitGetBlocks_1_16_2 implements IChunkGetCopy {
|
||||
|
||||
private final Map<BlockVector3, CompoundTag> tiles = new HashMap<>();
|
||||
private final Set<CompoundTag> entities = new HashSet<>();
|
||||
private BiomeStorage biomeStorage;
|
||||
private final char[][] blocks = new char[16][4096];
|
||||
private final char[][] newSetBlocks = new char[16][];
|
||||
|
||||
protected BukkitGetBlocks_1_16_2_Copy(WorldServer world, int X, int Z) {
|
||||
super(world, X, Z);
|
||||
@ -127,4 +129,13 @@ public class BukkitGetBlocks_1_16_2_Copy extends BukkitGetBlocks_1_16_2 {
|
||||
final int index = (y & 15) << 8 | z << 4 | x;
|
||||
return blocks[layer][index];
|
||||
}
|
||||
|
||||
protected void storeSetBlocks(int layer, char[] blocks) {
|
||||
newSetBlocks[layer] = blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getNewSetArr(int layer) {
|
||||
return newSetBlocks[layer];
|
||||
}
|
||||
}
|
||||
|
@ -360,13 +360,18 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks {
|
||||
if (!set.hasSection(layer)) {
|
||||
continue;
|
||||
}
|
||||
if (createCopy) {
|
||||
copy.storeSection(layer);
|
||||
}
|
||||
|
||||
bitMask |= 1 << layer;
|
||||
|
||||
char[] setArr = set.load(layer);
|
||||
// If we're creating a copy, it's because we're delaying history so we do not want to write to
|
||||
// the chunkSet yet.
|
||||
if (createCopy) {
|
||||
setArr = setArr.clone();
|
||||
copy.storeSection(layer);
|
||||
copy.storeSetBlocks(layer, setArr);
|
||||
}
|
||||
|
||||
ChunkSection newSection;
|
||||
ChunkSection existingSection = sections[layer];
|
||||
if (existingSection == null) {
|
||||
|
@ -2,6 +2,7 @@ package com.boydti.fawe.bukkit.adapter.mc1_16_4;
|
||||
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.beta.IChunkGetCopy;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_4.nbt.LazyCompoundTag_1_16_4;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
@ -29,12 +30,13 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitGetBlocks_1_16_4_Copy extends BukkitGetBlocks_1_16_4 {
|
||||
public class BukkitGetBlocks_1_16_4_Copy extends BukkitGetBlocks_1_16_4 implements IChunkGetCopy {
|
||||
|
||||
private final Map<BlockVector3, CompoundTag> tiles = new HashMap<>();
|
||||
private final Set<CompoundTag> entities = new HashSet<>();
|
||||
private BiomeStorage biomeStorage;
|
||||
private final char[][] blocks = new char[16][4096];
|
||||
private final char[][] newSetBlocks = new char[16][];
|
||||
|
||||
protected BukkitGetBlocks_1_16_4_Copy(WorldServer world, int X, int Z) {
|
||||
super(world, X, Z);
|
||||
@ -127,4 +129,13 @@ public class BukkitGetBlocks_1_16_4_Copy extends BukkitGetBlocks_1_16_4 {
|
||||
final int index = (y & 15) << 8 | z << 4 | x;
|
||||
return blocks[layer][index];
|
||||
}
|
||||
|
||||
protected void storeSetBlocks(int layer, char[] blocks) {
|
||||
newSetBlocks[layer] = blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getNewSetArr(int layer) {
|
||||
return newSetBlocks[layer];
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,6 @@
|
||||
package com.boydti.fawe.beta;
|
||||
|
||||
public interface IChunkGetCopy {
|
||||
|
||||
char[] getNewSetArr(int layer);
|
||||
}
|
@ -5,6 +5,7 @@ import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.beta.IBatchProcessor;
|
||||
import com.boydti.fawe.beta.IChunk;
|
||||
import com.boydti.fawe.beta.IChunkGet;
|
||||
import com.boydti.fawe.beta.IChunkGetCopy;
|
||||
import com.boydti.fawe.beta.IChunkSet;
|
||||
import com.boydti.fawe.object.HistoryExtent;
|
||||
import com.boydti.fawe.util.EditSessionBuilder;
|
||||
@ -158,6 +159,7 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
||||
addEntityCreate(tag);
|
||||
}
|
||||
}
|
||||
boolean updateSet = get instanceof IChunkGetCopy;
|
||||
for (int layer = 0; layer < 16; layer++) {
|
||||
if (!set.hasSection(layer)) {
|
||||
continue;
|
||||
@ -168,7 +170,11 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
||||
blocksGet = FaweCache.IMP.EMPTY_CHAR_4096;
|
||||
}
|
||||
char[] blocksSet = set.load(layer);
|
||||
|
||||
char[] newBlocksSet = null;
|
||||
if (updateSet) {
|
||||
newBlocksSet = ((IChunkGetCopy) get).getNewSetArr(layer);
|
||||
}
|
||||
;
|
||||
int by = layer << 4;
|
||||
for (int y = 0, index = 0; y < 16; y++) {
|
||||
int yy = y + by;
|
||||
@ -176,14 +182,18 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
||||
int zz = z + bz;
|
||||
for (int x = 0; x < 16; x++, index++) {
|
||||
int xx = bx + x;
|
||||
int combinedFrom = blocksGet[index];
|
||||
if (combinedFrom == 0) {
|
||||
combinedFrom = BlockID.AIR;
|
||||
int from = blocksGet[index];
|
||||
if (from == 0) {
|
||||
from = BlockID.AIR;
|
||||
}
|
||||
int combinedTo = blocksSet[index];
|
||||
final int combinedFrom = from;
|
||||
final int combinedTo = blocksSet[index];
|
||||
if (combinedTo != 0) {
|
||||
add(xx, yy, zz, combinedFrom, combinedTo);
|
||||
}
|
||||
if (updateSet) {
|
||||
blocksSet[index] = newBlocksSet[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user