we don't need to "update" when copying sections

Dieser Commit ist enthalten in:
dordsor21 2021-01-01 16:07:57 +00:00
Ursprung fbfe3221d7
Commit 606cfa5cbc
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
8 geänderte Dateien mit 36 neuen und 39 gelöschten Zeilen

Datei anzeigen

@ -90,6 +90,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
public NibbleArray[] skyLight = new NibbleArray[16]; public NibbleArray[] skyLight = new NibbleArray[16];
private boolean createCopy = false; private boolean createCopy = false;
private BukkitGetBlocks_1_15_2_Copy copy = null; private BukkitGetBlocks_1_15_2_Copy copy = null;
private boolean forceLoadSections = true;
public BukkitGetBlocks_1_15_2(World world, int chunkX, int chunkZ) { public BukkitGetBlocks_1_15_2(World world, int chunkX, int chunkZ) {
this(((CraftWorld) world).getHandle(), chunkX, chunkZ); this(((CraftWorld) world).getHandle(), chunkX, chunkZ);
@ -316,6 +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;
copy = createCopy ? new BukkitGetBlocks_1_15_2_Copy(world, getChunkX(), getChunkZ()) : null; copy = createCopy ? new BukkitGetBlocks_1_15_2_Copy(world, getChunkX(), getChunkZ()) : null;
try { try {
WorldServer nmsWorld = world; WorldServer nmsWorld = world;
@ -364,7 +366,6 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
// If we're creating a copy, it's because we're delaying history so we do not want to write to // If we're creating a copy, it's because we're delaying history so we do not want to write to
// the chunkSet yet. // the chunkSet yet.
if (createCopy) { if (createCopy) {
setArr = setArr.clone();
copy.storeSection(layer); copy.storeSection(layer);
copy.storeSetBlocks(layer, setArr); copy.storeSetBlocks(layer, setArr);
} }
@ -408,7 +409,6 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
newSection = BukkitAdapter_1_15_2.newChunkSection(layer, this::load, setArr, fastmode); newSection = BukkitAdapter_1_15_2.newChunkSection(layer, this::load, setArr, fastmode);
if (!BukkitAdapter_1_15_2.setSectionAtomic(sections, existingSection, newSection, layer)) { if (!BukkitAdapter_1_15_2.setSectionAtomic(sections, existingSection, newSection, layer)) {
log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer); log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer);
continue;
} else { } else {
updateGet(this, nmsChunk, sections, newSection, setArr, layer); updateGet(this, nmsChunk, sections, newSection, setArr, layer);
} }
@ -475,9 +475,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
Set<UUID> entityRemoves = set.getEntityRemoves(); Set<UUID> entityRemoves = set.getEntityRemoves();
if (entityRemoves != null && !entityRemoves.isEmpty()) { if (entityRemoves != null && !entityRemoves.isEmpty()) {
if (syncTasks == null) { syncTasks = new Runnable[3];
syncTasks = new Runnable[3];
}
syncTasks[2] = () -> { syncTasks[2] = () -> {
final List<Entity>[] entities = nmsChunk.getEntitySlices(); final List<Entity>[] entities = nmsChunk.getEntitySlices();
@ -637,6 +635,8 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} finally {
forceLoadSections = true;
} }
} }
@ -758,7 +758,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
} }
public ChunkSection[] getSections(boolean force) { public ChunkSection[] getSections(boolean force) {
if (force) { if (force && forceLoadSections) {
return sections = getChunk().getSections().clone(); return sections = getChunk().getSections().clone();
} }
ChunkSection[] tmp = sections; ChunkSection[] tmp = sections;
@ -828,7 +828,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
if (!hasSection(i) || super.sections[i] == CharBlocks.EMPTY) { if (!hasSection(i) || super.sections[i] == CharBlocks.EMPTY) {
continue; continue;
} }
ChunkSection existing = getSections(false)[i]; ChunkSection existing = getSections(true)[i];
try { try {
final DataPaletteBlock<IBlockData> blocksExisting = existing.getBlocks(); final DataPaletteBlock<IBlockData> blocksExisting = existing.getBlocks();

Datei anzeigen

@ -108,7 +108,7 @@ public class BukkitGetBlocks_1_15_2_Copy extends BukkitGetBlocks_1_15_2 implemen
} }
protected void storeSection(int layer) { protected void storeSection(int layer) {
blocks[layer] = update(layer, null).clone(); blocks[layer] = load(layer).clone();
} }
@Override @Override
@ -130,7 +130,7 @@ public class BukkitGetBlocks_1_15_2_Copy extends BukkitGetBlocks_1_15_2 implemen
} }
protected void storeSetBlocks(int layer, char[] blocks) { protected void storeSetBlocks(int layer, char[] blocks) {
newSetBlocks[layer] = blocks; newSetBlocks[layer] = blocks.clone();
} }
@Override @Override

Datei anzeigen

@ -90,6 +90,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
public NibbleArray[] skyLight = new NibbleArray[16]; public NibbleArray[] skyLight = new NibbleArray[16];
private boolean createCopy = false; private boolean createCopy = false;
private BukkitGetBlocks_1_16_1_Copy copy = null; private BukkitGetBlocks_1_16_1_Copy copy = null;
private boolean forceLoadSections = true;
public BukkitGetBlocks_1_16_1(World world, int chunkX, int chunkZ) { public BukkitGetBlocks_1_16_1(World world, int chunkX, int chunkZ) {
this(((CraftWorld) world).getHandle(), chunkX, chunkZ); this(((CraftWorld) world).getHandle(), chunkX, chunkZ);
@ -316,6 +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;
copy = createCopy ? new BukkitGetBlocks_1_16_1_Copy(world, getChunkX(), getChunkZ()) : null; copy = createCopy ? new BukkitGetBlocks_1_16_1_Copy(world, getChunkX(), getChunkZ()) : null;
try { try {
WorldServer nmsWorld = world; WorldServer nmsWorld = world;
@ -364,7 +366,6 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
// If we're creating a copy, it's because we're delaying history so we do not want to write to // If we're creating a copy, it's because we're delaying history so we do not want to write to
// the chunkSet yet. // the chunkSet yet.
if (createCopy) { if (createCopy) {
setArr = setArr.clone();
copy.storeSection(layer); copy.storeSection(layer);
copy.storeSetBlocks(layer, setArr); copy.storeSetBlocks(layer, setArr);
} }
@ -410,7 +411,6 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
if (!BukkitAdapter_1_16_1 if (!BukkitAdapter_1_16_1
.setSectionAtomic(sections, existingSection, newSection, layer)) { .setSectionAtomic(sections, existingSection, newSection, layer)) {
log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer); log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer);
continue;
} else { } else {
updateGet(this, nmsChunk, sections, newSection, setArr, layer); updateGet(this, nmsChunk, sections, newSection, setArr, layer);
} }
@ -477,9 +477,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
Set<UUID> entityRemoves = set.getEntityRemoves(); Set<UUID> entityRemoves = set.getEntityRemoves();
if (entityRemoves != null && !entityRemoves.isEmpty()) { if (entityRemoves != null && !entityRemoves.isEmpty()) {
if (syncTasks == null) { syncTasks = new Runnable[3];
syncTasks = new Runnable[3];
}
syncTasks[2] = () -> { syncTasks[2] = () -> {
final List<Entity>[] entities = nmsChunk.getEntitySlices(); final List<Entity>[] entities = nmsChunk.getEntitySlices();
@ -639,6 +637,8 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} finally {
forceLoadSections = true;
} }
} }
@ -760,7 +760,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
} }
public ChunkSection[] getSections(boolean force) { public ChunkSection[] getSections(boolean force) {
if (force) { if (force && forceLoadSections) {
return sections = getChunk().getSections().clone(); return sections = getChunk().getSections().clone();
} }
ChunkSection[] tmp = sections; ChunkSection[] tmp = sections;
@ -830,7 +830,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
if (!hasSection(i) || super.sections[i] == CharBlocks.EMPTY) { if (!hasSection(i) || super.sections[i] == CharBlocks.EMPTY) {
continue; continue;
} }
ChunkSection existing = getSections(false)[i]; ChunkSection existing = getSections(true)[i];
try { try {
final DataPaletteBlock<IBlockData> blocksExisting = existing.getBlocks(); final DataPaletteBlock<IBlockData> blocksExisting = existing.getBlocks();

Datei anzeigen

@ -109,7 +109,7 @@ public class BukkitGetBlocks_1_16_1_Copy extends BukkitGetBlocks_1_16_1 implemen
} }
protected void storeSection(int layer) { protected void storeSection(int layer) {
blocks[layer] = update(layer, null).clone(); blocks[layer] = load(layer).clone();
} }
@Override @Override
@ -131,7 +131,7 @@ public class BukkitGetBlocks_1_16_1_Copy extends BukkitGetBlocks_1_16_1 implemen
} }
protected void storeSetBlocks(int layer, char[] blocks) { protected void storeSetBlocks(int layer, char[] blocks) {
newSetBlocks[layer] = blocks; newSetBlocks[layer] = blocks.clone();
} }
@Override @Override

Datei anzeigen

@ -91,6 +91,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
public NibbleArray[] skyLight = new NibbleArray[16]; public NibbleArray[] skyLight = new NibbleArray[16];
private boolean createCopy = false; private boolean createCopy = false;
private BukkitGetBlocks_1_16_2_Copy copy = null; private BukkitGetBlocks_1_16_2_Copy copy = null;
private boolean forceLoadSections = true;
public BukkitGetBlocks_1_16_2(World world, int chunkX, int chunkZ) { public BukkitGetBlocks_1_16_2(World world, int chunkX, int chunkZ) {
this(((CraftWorld) world).getHandle(), chunkX, chunkZ); this(((CraftWorld) world).getHandle(), chunkX, chunkZ);
@ -319,6 +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;
copy = createCopy ? new BukkitGetBlocks_1_16_2_Copy(world, getChunkX(), getChunkZ()) : null; copy = createCopy ? new BukkitGetBlocks_1_16_2_Copy(world, getChunkX(), getChunkZ()) : null;
try { try {
WorldServer nmsWorld = world; WorldServer nmsWorld = world;
@ -367,7 +369,6 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
// If we're creating a copy, it's because we're delaying history so we do not want to write to // If we're creating a copy, it's because we're delaying history so we do not want to write to
// the chunkSet yet. // the chunkSet yet.
if (createCopy) { if (createCopy) {
setArr = setArr.clone();
copy.storeSection(layer); copy.storeSection(layer);
copy.storeSetBlocks(layer, setArr); copy.storeSetBlocks(layer, setArr);
} }
@ -413,7 +414,6 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
if (!BukkitAdapter_1_16_2 if (!BukkitAdapter_1_16_2
.setSectionAtomic(sections, existingSection, newSection, layer)) { .setSectionAtomic(sections, existingSection, newSection, layer)) {
log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer); log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer);
continue;
} else { } else {
updateGet(this, nmsChunk, sections, newSection, setArr, layer); updateGet(this, nmsChunk, sections, newSection, setArr, layer);
} }
@ -480,9 +480,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
Set<UUID> entityRemoves = set.getEntityRemoves(); Set<UUID> entityRemoves = set.getEntityRemoves();
if (entityRemoves != null && !entityRemoves.isEmpty()) { if (entityRemoves != null && !entityRemoves.isEmpty()) {
if (syncTasks == null) { syncTasks = new Runnable[3];
syncTasks = new Runnable[3];
}
syncTasks[2] = () -> { syncTasks[2] = () -> {
final List<Entity>[] entities = nmsChunk.getEntitySlices(); final List<Entity>[] entities = nmsChunk.getEntitySlices();
@ -642,6 +640,8 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} finally {
forceLoadSections = true;
} }
} }
@ -763,7 +763,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
} }
public ChunkSection[] getSections(boolean force) { public ChunkSection[] getSections(boolean force) {
if (force) { if (force && forceLoadSections) {
return sections = getChunk().getSections().clone(); return sections = getChunk().getSections().clone();
} }
ChunkSection[] tmp = sections; ChunkSection[] tmp = sections;
@ -833,7 +833,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
if (!hasSection(i) || super.sections[i] == CharBlocks.EMPTY) { if (!hasSection(i) || super.sections[i] == CharBlocks.EMPTY) {
continue; continue;
} }
ChunkSection existing = getSections(false)[i]; ChunkSection existing = getSections(true)[i];
try { try {
final DataPaletteBlock<IBlockData> blocksExisting = existing.getBlocks(); final DataPaletteBlock<IBlockData> blocksExisting = existing.getBlocks();

Datei anzeigen

@ -109,7 +109,7 @@ public class BukkitGetBlocks_1_16_2_Copy extends BukkitGetBlocks_1_16_2 implemen
} }
protected void storeSection(int layer) { protected void storeSection(int layer) {
blocks[layer] = update(layer, null).clone(); blocks[layer] = load(layer).clone();
} }
@Override @Override
@ -131,7 +131,7 @@ public class BukkitGetBlocks_1_16_2_Copy extends BukkitGetBlocks_1_16_2 implemen
} }
protected void storeSetBlocks(int layer, char[] blocks) { protected void storeSetBlocks(int layer, char[] blocks) {
newSetBlocks[layer] = blocks; newSetBlocks[layer] = blocks.clone();
} }
@Override @Override

Datei anzeigen

@ -1,7 +1,6 @@
package com.boydti.fawe.bukkit.adapter.mc1_16_4; package com.boydti.fawe.bukkit.adapter.mc1_16_4;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI;
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;
@ -28,10 +27,8 @@ import com.sk89q.worldedit.internal.Constants;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.block.BlockTypesCache;
import net.minecraft.server.v1_16_R3.BiomeBase; import net.minecraft.server.v1_16_R3.BiomeBase;
import net.minecraft.server.v1_16_R3.BiomeStorage; import net.minecraft.server.v1_16_R3.BiomeStorage;
import net.minecraft.server.v1_16_R3.Block;
import net.minecraft.server.v1_16_R3.BlockPosition; import net.minecraft.server.v1_16_R3.BlockPosition;
import net.minecraft.server.v1_16_R3.Chunk; import net.minecraft.server.v1_16_R3.Chunk;
import net.minecraft.server.v1_16_R3.ChunkSection; import net.minecraft.server.v1_16_R3.ChunkSection;
@ -94,6 +91,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks {
public NibbleArray[] skyLight = new NibbleArray[16]; public NibbleArray[] skyLight = new NibbleArray[16];
private boolean createCopy = false; private boolean createCopy = false;
private BukkitGetBlocks_1_16_4_Copy copy = null; private BukkitGetBlocks_1_16_4_Copy copy = null;
private boolean forceLoadSections = true;
public BukkitGetBlocks_1_16_4(World world, int chunkX, int chunkZ) { public BukkitGetBlocks_1_16_4(World world, int chunkX, int chunkZ) {
this(((CraftWorld) world).getHandle(), chunkX, chunkZ); this(((CraftWorld) world).getHandle(), chunkX, chunkZ);
@ -322,6 +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;
copy = createCopy ? new BukkitGetBlocks_1_16_4_Copy(world, getChunkX(), getChunkZ()) : null; copy = createCopy ? new BukkitGetBlocks_1_16_4_Copy(world, getChunkX(), getChunkZ()) : null;
try { try {
WorldServer nmsWorld = world; WorldServer nmsWorld = world;
@ -370,7 +369,6 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks {
// If we're creating a copy, it's because we're delaying history so we do not want to write to // If we're creating a copy, it's because we're delaying history so we do not want to write to
// the chunkSet yet. // the chunkSet yet.
if (createCopy) { if (createCopy) {
setArr = setArr.clone();
copy.storeSection(layer); copy.storeSection(layer);
copy.storeSetBlocks(layer, setArr); copy.storeSetBlocks(layer, setArr);
} }
@ -416,7 +414,6 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks {
if (!BukkitAdapter_1_16_4 if (!BukkitAdapter_1_16_4
.setSectionAtomic(sections, existingSection, newSection, layer)) { .setSectionAtomic(sections, existingSection, newSection, layer)) {
log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer); log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer);
continue;
} else { } else {
updateGet(this, nmsChunk, sections, newSection, setArr, layer); updateGet(this, nmsChunk, sections, newSection, setArr, layer);
} }
@ -483,9 +480,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks {
Set<UUID> entityRemoves = set.getEntityRemoves(); Set<UUID> entityRemoves = set.getEntityRemoves();
if (entityRemoves != null && !entityRemoves.isEmpty()) { if (entityRemoves != null && !entityRemoves.isEmpty()) {
if (syncTasks == null) { syncTasks = new Runnable[3];
syncTasks = new Runnable[3];
}
syncTasks[2] = () -> { syncTasks[2] = () -> {
final List<Entity>[] entities = nmsChunk.getEntitySlices(); final List<Entity>[] entities = nmsChunk.getEntitySlices();
@ -645,6 +640,8 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks {
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} finally {
forceLoadSections = true;
} }
} }
@ -766,7 +763,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks {
} }
public ChunkSection[] getSections(boolean force) { public ChunkSection[] getSections(boolean force) {
if (force) { if (force && forceLoadSections) {
return sections = getChunk().getSections().clone(); return sections = getChunk().getSections().clone();
} }
ChunkSection[] tmp = sections; ChunkSection[] tmp = sections;
@ -836,7 +833,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks {
if (!hasSection(i) || super.sections[i] == CharBlocks.EMPTY) { if (!hasSection(i) || super.sections[i] == CharBlocks.EMPTY) {
continue; continue;
} }
ChunkSection existing = getSections(false)[i]; ChunkSection existing = getSections(true)[i];
try { try {
final DataPaletteBlock<IBlockData> blocksExisting = existing.getBlocks(); final DataPaletteBlock<IBlockData> blocksExisting = existing.getBlocks();

Datei anzeigen

@ -109,7 +109,7 @@ public class BukkitGetBlocks_1_16_4_Copy extends BukkitGetBlocks_1_16_4 implemen
} }
protected void storeSection(int layer) { protected void storeSection(int layer) {
blocks[layer] = update(layer, null).clone(); blocks[layer] = load(layer).clone();
} }
@Override @Override
@ -131,7 +131,7 @@ public class BukkitGetBlocks_1_16_4_Copy extends BukkitGetBlocks_1_16_4 implemen
} }
protected void storeSetBlocks(int layer, char[] blocks) { protected void storeSetBlocks(int layer, char[] blocks) {
newSetBlocks[layer] = blocks; newSetBlocks[layer] = blocks.clone();
} }
@Override @Override