3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-09 13:00:05 +01:00

Large memory use reduction when PostProcessing history

Dieser Commit ist enthalten in:
dordsor21 2021-01-05 15:03:47 +00:00
Ursprung 7c174ee6b3
Commit 89cc2f9d9f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
10 geänderte Dateien mit 269 neuen und 97 gelöschten Zeilen

Datei anzeigen

@ -4,7 +4,6 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.implementation.blocks.CharBlocks;
import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks; import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks;
import com.boydti.fawe.beta.implementation.lighting.HeightMapType; import com.boydti.fawe.beta.implementation.lighting.HeightMapType;
import com.boydti.fawe.beta.implementation.queue.QueueHandler; import com.boydti.fawe.beta.implementation.queue.QueueHandler;
@ -318,7 +317,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
@Override @Override
public <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) { public <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) {
forceLoadSections = false; forceLoadSections = false;
copy = createCopy ? new BukkitGetBlocks_1_15_2_Copy(world, getChunkX(), getChunkZ()) : null; copy = createCopy ? new BukkitGetBlocks_1_15_2_Copy(world) : null;
try { try {
WorldServer nmsWorld = world; WorldServer nmsWorld = world;
Chunk nmsChunk = ensureLoaded(nmsWorld, chunkX, chunkZ); Chunk nmsChunk = ensureLoaded(nmsWorld, chunkX, chunkZ);
@ -362,12 +361,9 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
bitMask |= 1 << layer; bitMask |= 1 << layer;
char[] setArr = set.load(layer); char[] setArr = set.load(layer).clone();
// 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) { if (createCopy) {
copy.storeSection(layer); copy.storeSection(layer, load(layer).clone());
copy.storeSetBlocks(layer, setArr);
} }
ChunkSection newSection; ChunkSection newSection;

Datei anzeigen

@ -2,7 +2,10 @@ package com.boydti.fawe.bukkit.adapter.mc1_15_2;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunkGetCopy; import com.boydti.fawe.beta.IBlocks;
import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.implementation.lighting.HeightMapType;
import com.boydti.fawe.bukkit.adapter.mc1_15_2.nbt.LazyCompoundTag_1_15_2; import com.boydti.fawe.bukkit.adapter.mc1_15_2.nbt.LazyCompoundTag_1_15_2;
import com.google.common.base.Suppliers; import com.google.common.base.Suppliers;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
@ -22,23 +25,25 @@ import net.minecraft.server.v1_15_R1.TileEntity;
import net.minecraft.server.v1_15_R1.WorldServer; import net.minecraft.server.v1_15_R1.WorldServer;
import org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock; import org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Range;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.Future;
public class BukkitGetBlocks_1_15_2_Copy extends BukkitGetBlocks_1_15_2 implements IChunkGetCopy { public class BukkitGetBlocks_1_15_2_Copy implements IChunkGet {
private final Map<BlockVector3, CompoundTag> tiles = new HashMap<>(); private final Map<BlockVector3, CompoundTag> tiles = new HashMap<>();
private final Set<CompoundTag> entities = new HashSet<>(); private final Set<CompoundTag> entities = new HashSet<>();
private BiomeStorage biomeStorage; private BiomeStorage biomeStorage;
private final char[][] blocks = new char[16][4096]; private final char[][] blocks = new char[16][];
private final char[][] newSetBlocks = new char[16][]; private final WorldServer world;
protected BukkitGetBlocks_1_15_2_Copy(WorldServer world, int X, int Z) { protected BukkitGetBlocks_1_15_2_Copy(WorldServer world) {
super(world, X, Z); this.world = world;
} }
protected void storeTile(TileEntity tile) { protected void storeTile(TileEntity tile) {
@ -89,6 +94,16 @@ public class BukkitGetBlocks_1_15_2_Copy extends BukkitGetBlocks_1_15_2 implemen
return null; return null;
} }
@Override
public void setCreateCopy(boolean createCopy) {
}
@Override
public boolean isCreateCopy() {
return false;
}
protected void storeBiomes(BiomeStorage biomeStorage) { protected void storeBiomes(BiomeStorage biomeStorage) {
this.biomeStorage = new BiomeStorage(BukkitAdapter_1_15_2.getBiomeArray(biomeStorage).clone()); this.biomeStorage = new BiomeStorage(BukkitAdapter_1_15_2.getBiomeArray(biomeStorage).clone());
} }
@ -107,8 +122,18 @@ public class BukkitGetBlocks_1_15_2_Copy extends BukkitGetBlocks_1_15_2 implemen
return base != null ? BukkitAdapter.adapt(CraftBlock.biomeBaseToBiome(base)) : null; return base != null ? BukkitAdapter.adapt(CraftBlock.biomeBaseToBiome(base)) : null;
} }
protected void storeSection(int layer) { @Override
blocks[layer] = load(layer).clone(); public boolean trim(boolean aggressive, int layer) {
return false;
}
@Override
public IBlocks reset() {
return null;
}
protected void storeSection(int layer, char[] data) {
blocks[layer] = data;
} }
@Override @Override
@ -117,24 +142,50 @@ public class BukkitGetBlocks_1_15_2_Copy extends BukkitGetBlocks_1_15_2 implemen
return state.toBaseBlock(this, x, y, z); return state.toBaseBlock(this, x, y, z);
} }
@Override
public boolean hasSection(@Range(from = 0, to = 15) int layer) {
return blocks[layer] != null;
}
@Override
public char[] load(int layer) {
return blocks[layer];
}
@Override @Override
public BlockState getBlock(int x, int y, int z) { public BlockState getBlock(int x, int y, int z) {
return BlockTypesCache.states[get(x, y, z)]; return BlockTypesCache.states[get(x, y, z)];
} }
@Override @Override
public int getSkyLight(int x, int y, int z) {
return 0;
}
@Override
public int getEmmittedLight(int x, int y, int z) {
return 0;
}
@Override
public int[] getHeightMap(HeightMapType type) {
return new int[0];
}
@Override
public <T extends Future<T>> T call(IChunkSet set, Runnable finalize) {
return null;
}
public char get(int x, int y, int z) { public char get(int x, int y, int z) {
final int layer = y >> 4; final int layer = y >> 4;
final int index = (y & 15) << 8 | z << 4 | x; final int index = (y & 15) << 8 | z << 4 | x;
return blocks[layer][index]; return blocks[layer][index];
} }
protected void storeSetBlocks(int layer, char[] blocks) {
newSetBlocks[layer] = blocks.clone();
}
@Override @Override
public char[] getNewSetArr(int layer) { public boolean trim(boolean aggressive) {
return newSetBlocks[layer]; return false;
} }
} }

Datei anzeigen

@ -4,7 +4,6 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.implementation.blocks.CharBlocks;
import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks; import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks;
import com.boydti.fawe.beta.implementation.lighting.HeightMapType; import com.boydti.fawe.beta.implementation.lighting.HeightMapType;
import com.boydti.fawe.beta.implementation.queue.QueueHandler; import com.boydti.fawe.beta.implementation.queue.QueueHandler;
@ -318,7 +317,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
@Override @Override
public <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) { public <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) {
forceLoadSections = false; forceLoadSections = false;
copy = createCopy ? new BukkitGetBlocks_1_16_1_Copy(world, getChunkX(), getChunkZ()) : null; copy = createCopy ? new BukkitGetBlocks_1_16_1_Copy(world) : null;
try { try {
WorldServer nmsWorld = world; WorldServer nmsWorld = world;
Chunk nmsChunk = ensureLoaded(nmsWorld, chunkX, chunkZ); Chunk nmsChunk = ensureLoaded(nmsWorld, chunkX, chunkZ);
@ -362,12 +361,9 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
bitMask |= 1 << layer; bitMask |= 1 << layer;
char[] setArr = set.load(layer); char[] setArr = set.load(layer).clone();
// 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) { if (createCopy) {
copy.storeSection(layer); copy.storeSection(layer, load(layer).clone());
copy.storeSetBlocks(layer, setArr);
} }
ChunkSection newSection; ChunkSection newSection;

Datei anzeigen

@ -2,7 +2,10 @@ package com.boydti.fawe.bukkit.adapter.mc1_16_1;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunkGetCopy; import com.boydti.fawe.beta.IBlocks;
import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.implementation.lighting.HeightMapType;
import com.boydti.fawe.bukkit.adapter.mc1_16_1.nbt.LazyCompoundTag_1_16_1; import com.boydti.fawe.bukkit.adapter.mc1_16_1.nbt.LazyCompoundTag_1_16_1;
import com.google.common.base.Suppliers; import com.google.common.base.Suppliers;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
@ -17,29 +20,30 @@ import com.sk89q.worldedit.world.block.BlockTypesCache;
import net.minecraft.server.v1_16_R1.BiomeBase; import net.minecraft.server.v1_16_R1.BiomeBase;
import net.minecraft.server.v1_16_R1.BiomeStorage; import net.minecraft.server.v1_16_R1.BiomeStorage;
import net.minecraft.server.v1_16_R1.Entity; import net.minecraft.server.v1_16_R1.Entity;
import net.minecraft.server.v1_16_R1.IRegistry;
import net.minecraft.server.v1_16_R1.NBTTagCompound; import net.minecraft.server.v1_16_R1.NBTTagCompound;
import net.minecraft.server.v1_16_R1.TileEntity; import net.minecraft.server.v1_16_R1.TileEntity;
import net.minecraft.server.v1_16_R1.WorldServer; import net.minecraft.server.v1_16_R1.WorldServer;
import org.bukkit.craftbukkit.v1_16_R1.block.CraftBlock; import org.bukkit.craftbukkit.v1_16_R1.block.CraftBlock;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Range;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.Future;
public class BukkitGetBlocks_1_16_1_Copy extends BukkitGetBlocks_1_16_1 implements IChunkGetCopy { public class BukkitGetBlocks_1_16_1_Copy implements IChunkGet {
private final Map<BlockVector3, CompoundTag> tiles = new HashMap<>(); private final Map<BlockVector3, CompoundTag> tiles = new HashMap<>();
private final Set<CompoundTag> entities = new HashSet<>(); private final Set<CompoundTag> entities = new HashSet<>();
private BiomeStorage biomeStorage; private BiomeStorage biomeStorage;
private final char[][] blocks = new char[16][4096]; private final char[][] blocks = new char[16][];
private final char[][] newSetBlocks = new char[16][]; private final WorldServer world;
protected BukkitGetBlocks_1_16_1_Copy(WorldServer world, int X, int Z) { protected BukkitGetBlocks_1_16_1_Copy(WorldServer world) {
super(world, X, Z); this.world = world;
} }
protected void storeTile(TileEntity tile) { protected void storeTile(TileEntity tile) {
@ -90,6 +94,16 @@ public class BukkitGetBlocks_1_16_1_Copy extends BukkitGetBlocks_1_16_1 implemen
return null; return null;
} }
@Override
public void setCreateCopy(boolean createCopy) {
}
@Override
public boolean isCreateCopy() {
return false;
}
protected void storeBiomes(BiomeStorage biomeStorage) { protected void storeBiomes(BiomeStorage biomeStorage) {
this.biomeStorage = new BiomeStorage(BukkitAdapter_1_16_1.getBiomeArray(biomeStorage).clone()); this.biomeStorage = new BiomeStorage(BukkitAdapter_1_16_1.getBiomeArray(biomeStorage).clone());
} }
@ -108,8 +122,18 @@ public class BukkitGetBlocks_1_16_1_Copy extends BukkitGetBlocks_1_16_1 implemen
return base != null ? BukkitAdapter.adapt(CraftBlock.biomeBaseToBiome(base)) : null; return base != null ? BukkitAdapter.adapt(CraftBlock.biomeBaseToBiome(base)) : null;
} }
protected void storeSection(int layer) { @Override
blocks[layer] = load(layer).clone(); public boolean trim(boolean aggressive, int layer) {
return false;
}
@Override
public IBlocks reset() {
return null;
}
protected void storeSection(int layer, char[] data) {
blocks[layer] = data;
} }
@Override @Override
@ -118,24 +142,50 @@ public class BukkitGetBlocks_1_16_1_Copy extends BukkitGetBlocks_1_16_1 implemen
return state.toBaseBlock(this, x, y, z); return state.toBaseBlock(this, x, y, z);
} }
@Override
public boolean hasSection(@Range(from = 0, to = 15) int layer) {
return blocks[layer] != null;
}
@Override
public char[] load(int layer) {
return blocks[layer];
}
@Override @Override
public BlockState getBlock(int x, int y, int z) { public BlockState getBlock(int x, int y, int z) {
return BlockTypesCache.states[get(x, y, z)]; return BlockTypesCache.states[get(x, y, z)];
} }
@Override @Override
public int getSkyLight(int x, int y, int z) {
return 0;
}
@Override
public int getEmmittedLight(int x, int y, int z) {
return 0;
}
@Override
public int[] getHeightMap(HeightMapType type) {
return new int[0];
}
@Override
public <T extends Future<T>> T call(IChunkSet set, Runnable finalize) {
return null;
}
public char get(int x, int y, int z) { public char get(int x, int y, int z) {
final int layer = y >> 4; final int layer = y >> 4;
final int index = (y & 15) << 8 | z << 4 | x; final int index = (y & 15) << 8 | z << 4 | x;
return blocks[layer][index]; return blocks[layer][index];
} }
protected void storeSetBlocks(int layer, char[] blocks) {
newSetBlocks[layer] = blocks.clone();
}
@Override @Override
public char[] getNewSetArr(int layer) { public boolean trim(boolean aggressive) {
return newSetBlocks[layer]; return false;
} }
} }

Datei anzeigen

@ -4,7 +4,6 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.implementation.blocks.CharBlocks;
import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks; import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks;
import com.boydti.fawe.beta.implementation.lighting.HeightMapType; import com.boydti.fawe.beta.implementation.lighting.HeightMapType;
import com.boydti.fawe.beta.implementation.queue.QueueHandler; import com.boydti.fawe.beta.implementation.queue.QueueHandler;
@ -321,7 +320,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
@Override @Override
public <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) { public <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) {
forceLoadSections = false; forceLoadSections = false;
copy = createCopy ? new BukkitGetBlocks_1_16_2_Copy(world, getChunkX(), getChunkZ()) : null; copy = createCopy ? new BukkitGetBlocks_1_16_2_Copy(world) : null;
try { try {
WorldServer nmsWorld = world; WorldServer nmsWorld = world;
Chunk nmsChunk = ensureLoaded(nmsWorld, chunkX, chunkZ); Chunk nmsChunk = ensureLoaded(nmsWorld, chunkX, chunkZ);
@ -365,12 +364,9 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
bitMask |= 1 << layer; bitMask |= 1 << layer;
char[] setArr = set.load(layer); char[] setArr = set.load(layer).clone();
// 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) { if (createCopy) {
copy.storeSection(layer); copy.storeSection(layer, load(layer).clone());
copy.storeSetBlocks(layer, setArr);
} }
ChunkSection newSection; ChunkSection newSection;

Datei anzeigen

@ -2,7 +2,10 @@ package com.boydti.fawe.bukkit.adapter.mc1_16_2;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunkGetCopy; import com.boydti.fawe.beta.IBlocks;
import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.implementation.lighting.HeightMapType;
import com.boydti.fawe.bukkit.adapter.mc1_16_2.nbt.LazyCompoundTag_1_16_2; import com.boydti.fawe.bukkit.adapter.mc1_16_2.nbt.LazyCompoundTag_1_16_2;
import com.google.common.base.Suppliers; import com.google.common.base.Suppliers;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
@ -23,23 +26,25 @@ import net.minecraft.server.v1_16_R2.TileEntity;
import net.minecraft.server.v1_16_R2.WorldServer; import net.minecraft.server.v1_16_R2.WorldServer;
import org.bukkit.craftbukkit.v1_16_R2.block.CraftBlock; import org.bukkit.craftbukkit.v1_16_R2.block.CraftBlock;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Range;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.Future;
public class BukkitGetBlocks_1_16_2_Copy extends BukkitGetBlocks_1_16_2 implements IChunkGetCopy { public class BukkitGetBlocks_1_16_2_Copy implements IChunkGet {
private final Map<BlockVector3, CompoundTag> tiles = new HashMap<>(); private final Map<BlockVector3, CompoundTag> tiles = new HashMap<>();
private final Set<CompoundTag> entities = new HashSet<>(); private final Set<CompoundTag> entities = new HashSet<>();
private BiomeStorage biomeStorage; private BiomeStorage biomeStorage;
private final char[][] blocks = new char[16][4096]; private final char[][] blocks = new char[16][];
private final char[][] newSetBlocks = new char[16][]; private final WorldServer world;
protected BukkitGetBlocks_1_16_2_Copy(WorldServer world, int X, int Z) { protected BukkitGetBlocks_1_16_2_Copy(WorldServer world) {
super(world, X, Z); this.world = world;
} }
protected void storeTile(TileEntity tile) { protected void storeTile(TileEntity tile) {
@ -90,6 +95,16 @@ public class BukkitGetBlocks_1_16_2_Copy extends BukkitGetBlocks_1_16_2 implemen
return null; return null;
} }
@Override
public void setCreateCopy(boolean createCopy) {
}
@Override
public boolean isCreateCopy() {
return false;
}
protected void storeBiomes(BiomeStorage biomeStorage) { protected void storeBiomes(BiomeStorage biomeStorage) {
this.biomeStorage = new BiomeStorage(biomeStorage.g, BukkitAdapter_1_16_2.getBiomeArray(biomeStorage).clone()); this.biomeStorage = new BiomeStorage(biomeStorage.g, BukkitAdapter_1_16_2.getBiomeArray(biomeStorage).clone());
} }
@ -108,8 +123,18 @@ public class BukkitGetBlocks_1_16_2_Copy extends BukkitGetBlocks_1_16_2 implemen
return base != null ? BukkitAdapter.adapt(CraftBlock.biomeBaseToBiome(world.r().b(IRegistry.ay), base)) : null; return base != null ? BukkitAdapter.adapt(CraftBlock.biomeBaseToBiome(world.r().b(IRegistry.ay), base)) : null;
} }
protected void storeSection(int layer) { @Override
blocks[layer] = load(layer).clone(); public boolean trim(boolean aggressive, int layer) {
return false;
}
@Override
public IBlocks reset() {
return null;
}
protected void storeSection(int layer, char[] data) {
blocks[layer] = data;
} }
@Override @Override
@ -118,24 +143,50 @@ public class BukkitGetBlocks_1_16_2_Copy extends BukkitGetBlocks_1_16_2 implemen
return state.toBaseBlock(this, x, y, z); return state.toBaseBlock(this, x, y, z);
} }
@Override
public boolean hasSection(@Range(from = 0, to = 15) int layer) {
return blocks[layer] != null;
}
@Override
public char[] load(int layer) {
return blocks[layer];
}
@Override @Override
public BlockState getBlock(int x, int y, int z) { public BlockState getBlock(int x, int y, int z) {
return BlockTypesCache.states[get(x, y, z)]; return BlockTypesCache.states[get(x, y, z)];
} }
@Override @Override
public int getSkyLight(int x, int y, int z) {
return 0;
}
@Override
public int getEmmittedLight(int x, int y, int z) {
return 0;
}
@Override
public int[] getHeightMap(HeightMapType type) {
return new int[0];
}
@Override
public <T extends Future<T>> T call(IChunkSet set, Runnable finalize) {
return null;
}
public char get(int x, int y, int z) { public char get(int x, int y, int z) {
final int layer = y >> 4; final int layer = y >> 4;
final int index = (y & 15) << 8 | z << 4 | x; final int index = (y & 15) << 8 | z << 4 | x;
return blocks[layer][index]; return blocks[layer][index];
} }
protected void storeSetBlocks(int layer, char[] blocks) {
newSetBlocks[layer] = blocks.clone();
}
@Override @Override
public char[] getNewSetArr(int layer) { public boolean trim(boolean aggressive) {
return newSetBlocks[layer]; return false;
} }
} }

Datei anzeigen

@ -4,7 +4,6 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.implementation.blocks.CharBlocks;
import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks; import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks;
import com.boydti.fawe.beta.implementation.lighting.HeightMapType; import com.boydti.fawe.beta.implementation.lighting.HeightMapType;
import com.boydti.fawe.beta.implementation.queue.QueueHandler; import com.boydti.fawe.beta.implementation.queue.QueueHandler;
@ -321,7 +320,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks {
@Override @Override
public <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) { public <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) {
forceLoadSections = false; forceLoadSections = false;
copy = createCopy ? new BukkitGetBlocks_1_16_4_Copy(world, getChunkX(), getChunkZ()) : null; copy = createCopy ? new BukkitGetBlocks_1_16_4_Copy(world) : null;
try { try {
WorldServer nmsWorld = world; WorldServer nmsWorld = world;
Chunk nmsChunk = ensureLoaded(nmsWorld, chunkX, chunkZ); Chunk nmsChunk = ensureLoaded(nmsWorld, chunkX, chunkZ);
@ -365,12 +364,9 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks {
bitMask |= 1 << layer; bitMask |= 1 << layer;
char[] setArr = set.load(layer); char[] setArr = set.load(layer).clone();
// 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) { if (createCopy) {
copy.storeSection(layer); copy.storeSection(layer, load(layer).clone());
copy.storeSetBlocks(layer, setArr);
} }
ChunkSection newSection; ChunkSection newSection;

Datei anzeigen

@ -2,7 +2,10 @@ package com.boydti.fawe.bukkit.adapter.mc1_16_4;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunkGetCopy; import com.boydti.fawe.beta.IBlocks;
import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.implementation.lighting.HeightMapType;
import com.boydti.fawe.bukkit.adapter.mc1_16_4.nbt.LazyCompoundTag_1_16_4; import com.boydti.fawe.bukkit.adapter.mc1_16_4.nbt.LazyCompoundTag_1_16_4;
import com.google.common.base.Suppliers; import com.google.common.base.Suppliers;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
@ -23,23 +26,25 @@ import net.minecraft.server.v1_16_R3.TileEntity;
import net.minecraft.server.v1_16_R3.WorldServer; import net.minecraft.server.v1_16_R3.WorldServer;
import org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock; import org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Range;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.Future;
public class BukkitGetBlocks_1_16_4_Copy extends BukkitGetBlocks_1_16_4 implements IChunkGetCopy { public class BukkitGetBlocks_1_16_4_Copy implements IChunkGet {
private final Map<BlockVector3, CompoundTag> tiles = new HashMap<>(); private final Map<BlockVector3, CompoundTag> tiles = new HashMap<>();
private final Set<CompoundTag> entities = new HashSet<>(); private final Set<CompoundTag> entities = new HashSet<>();
private BiomeStorage biomeStorage; private BiomeStorage biomeStorage;
private final char[][] blocks = new char[16][4096]; private final char[][] blocks = new char[16][];
private final char[][] newSetBlocks = new char[16][]; private final WorldServer world;
protected BukkitGetBlocks_1_16_4_Copy(WorldServer world, int X, int Z) { protected BukkitGetBlocks_1_16_4_Copy(WorldServer world) {
super(world, X, Z); this.world = world;
} }
protected void storeTile(TileEntity tile) { protected void storeTile(TileEntity tile) {
@ -90,6 +95,16 @@ public class BukkitGetBlocks_1_16_4_Copy extends BukkitGetBlocks_1_16_4 implemen
return null; return null;
} }
@Override
public void setCreateCopy(boolean createCopy) {
}
@Override
public boolean isCreateCopy() {
return false;
}
protected void storeBiomes(BiomeStorage biomeStorage) { protected void storeBiomes(BiomeStorage biomeStorage) {
this.biomeStorage = new BiomeStorage(biomeStorage.g, BukkitAdapter_1_16_4.getBiomeArray(biomeStorage).clone()); this.biomeStorage = new BiomeStorage(biomeStorage.g, BukkitAdapter_1_16_4.getBiomeArray(biomeStorage).clone());
} }
@ -108,8 +123,18 @@ public class BukkitGetBlocks_1_16_4_Copy extends BukkitGetBlocks_1_16_4 implemen
return base != null ? BukkitAdapter.adapt(CraftBlock.biomeBaseToBiome(world.r().b(IRegistry.ay), base)) : null; return base != null ? BukkitAdapter.adapt(CraftBlock.biomeBaseToBiome(world.r().b(IRegistry.ay), base)) : null;
} }
protected void storeSection(int layer) { @Override
blocks[layer] = load(layer).clone(); public boolean trim(boolean aggressive, int layer) {
return false;
}
@Override
public IBlocks reset() {
return null;
}
protected void storeSection(int layer, char[] data) {
blocks[layer] = data;
} }
@Override @Override
@ -118,24 +143,50 @@ public class BukkitGetBlocks_1_16_4_Copy extends BukkitGetBlocks_1_16_4 implemen
return state.toBaseBlock(this, x, y, z); return state.toBaseBlock(this, x, y, z);
} }
@Override
public boolean hasSection(@Range(from = 0, to = 15) int layer) {
return blocks[layer] != null;
}
@Override
public char[] load(int layer) {
return blocks[layer];
}
@Override @Override
public BlockState getBlock(int x, int y, int z) { public BlockState getBlock(int x, int y, int z) {
return BlockTypesCache.states[get(x, y, z)]; return BlockTypesCache.states[get(x, y, z)];
} }
@Override @Override
public int getSkyLight(int x, int y, int z) {
return 0;
}
@Override
public int getEmmittedLight(int x, int y, int z) {
return 0;
}
@Override
public int[] getHeightMap(HeightMapType type) {
return new int[0];
}
@Override
public <T extends Future<T>> T call(IChunkSet set, Runnable finalize) {
return null;
}
public char get(int x, int y, int z) { public char get(int x, int y, int z) {
final int layer = y >> 4; final int layer = y >> 4;
final int index = (y & 15) << 8 | z << 4 | x; final int index = (y & 15) << 8 | z << 4 | x;
return blocks[layer][index]; return blocks[layer][index];
} }
protected void storeSetBlocks(int layer, char[] blocks) {
newSetBlocks[layer] = blocks.clone();
}
@Override @Override
public char[] getNewSetArr(int layer) { public boolean trim(boolean aggressive) {
return newSetBlocks[layer]; return false;
} }
} }

Datei anzeigen

@ -1,6 +0,0 @@
package com.boydti.fawe.beta;
public interface IChunkGetCopy {
char[] getNewSetArr(int layer);
}

Datei anzeigen

@ -5,7 +5,6 @@ import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IBatchProcessor; import com.boydti.fawe.beta.IBatchProcessor;
import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkGetCopy;
import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.object.HistoryExtent; import com.boydti.fawe.object.HistoryExtent;
import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.EditSessionBuilder;
@ -157,7 +156,6 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
addEntityCreate(tag); addEntityCreate(tag);
} }
} }
boolean updateSet = get instanceof IChunkGetCopy;
for (int layer = 0; layer < 16; layer++) { for (int layer = 0; layer < 16; layer++) {
if (!set.hasSection(layer)) { if (!set.hasSection(layer)) {
continue; continue;
@ -168,11 +166,7 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
blocksGet = FaweCache.IMP.EMPTY_CHAR_4096; blocksGet = FaweCache.IMP.EMPTY_CHAR_4096;
} }
char[] blocksSet = set.load(layer); char[] blocksSet = set.load(layer);
char[] newBlocksSet = null;
if (updateSet) {
newBlocksSet = ((IChunkGetCopy) get).getNewSetArr(layer);
}
;
int by = layer << 4; int by = layer << 4;
for (int y = 0, index = 0; y < 16; y++) { for (int y = 0, index = 0; y < 16; y++) {
int yy = y + by; int yy = y + by;
@ -189,9 +183,6 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
if (combinedTo != 0) { if (combinedTo != 0) {
add(xx, yy, zz, combinedFrom, combinedTo); add(xx, yy, zz, combinedFrom, combinedTo);
} }
if (updateSet) {
blocksSet[index] = newBlocksSet[index];
}
} }
} }
} }