Ensure chunk sections are reloaded for every edit/chunk read

Add an option for force-reloading the cached chunk sections when a layer is updated
Dieser Commit ist enthalten in:
dordsor21 2020-12-17 22:04:49 +00:00
Ursprung d379b0af9b
Commit 884ec322b8
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
4 geänderte Dateien mit 35 neuen und 20 gelöschten Zeilen

Datei anzeigen

@ -397,7 +397,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
this.nmsChunk = nmsChunk; this.nmsChunk = nmsChunk;
this.sections = null; this.sections = null;
this.reset(); this.reset();
} else if (existingSection != getSections()[layer]) { } else if (existingSection != getSections(false)[layer]) {
this.sections[layer] = existingSection; this.sections[layer] = existingSection;
this.reset(); this.reset();
} else if (!Arrays.equals(update(layer, new char[4096]), load(layer))) { } else if (!Arrays.equals(update(layer, new char[4096]), load(layer))) {
@ -642,7 +642,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
@Override @Override
public synchronized char[] update(int layer, char[] data) { public synchronized char[] update(int layer, char[] data) {
ChunkSection section = getSections()[layer]; ChunkSection section = getSections(true)[layer];
// Section is null, return empty array // Section is null, return empty array
if (section == null) { if (section == null) {
data = new char[4096]; data = new char[4096];
@ -757,7 +757,10 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
} }
} }
public ChunkSection[] getSections() { public ChunkSection[] getSections(boolean force) {
if (force) {
return sections = getChunk().getSections().clone();
}
ChunkSection[] tmp = sections; ChunkSection[] tmp = sections;
if (tmp == null) { if (tmp == null) {
synchronized (this) { synchronized (this) {
@ -809,7 +812,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
@Override @Override
public boolean hasSection(int layer) { public boolean hasSection(int layer) {
return getSections()[layer] != null; return getSections(false)[layer] != null;
} }
@Override @Override
@ -825,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()[i]; ChunkSection existing = getSections(false)[i];
try { try {
final DataPaletteBlock<IBlockData> blocksExisting = existing.getBlocks(); final DataPaletteBlock<IBlockData> blocksExisting = existing.getBlocks();

Datei anzeigen

@ -397,7 +397,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
this.nmsChunk = nmsChunk; this.nmsChunk = nmsChunk;
this.sections = null; this.sections = null;
this.reset(); this.reset();
} else if (existingSection != getSections()[layer]) { } else if (existingSection != getSections(false)[layer]) {
this.sections[layer] = existingSection; this.sections[layer] = existingSection;
this.reset(); this.reset();
} else if (!Arrays.equals(update(layer, new char[4096]), load(layer))) { } else if (!Arrays.equals(update(layer, new char[4096]), load(layer))) {
@ -644,7 +644,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
@Override @Override
public synchronized char[] update(int layer, char[] data) { public synchronized char[] update(int layer, char[] data) {
ChunkSection section = getSections()[layer]; ChunkSection section = getSections(true)[layer];
// Section is null, return empty array // Section is null, return empty array
if (section == null) { if (section == null) {
data = new char[4096]; data = new char[4096];
@ -759,7 +759,10 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
} }
} }
public ChunkSection[] getSections() { public ChunkSection[] getSections(boolean force) {
if (force) {
return sections = getChunk().getSections().clone();
}
ChunkSection[] tmp = sections; ChunkSection[] tmp = sections;
if (tmp == null) { if (tmp == null) {
synchronized (this) { synchronized (this) {
@ -811,7 +814,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
@Override @Override
public boolean hasSection(int layer) { public boolean hasSection(int layer) {
return getSections()[layer] != null; return getSections(false)[layer] != null;
} }
@Override @Override
@ -827,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()[i]; ChunkSection existing = getSections(false)[i];
try { try {
final DataPaletteBlock<IBlockData> blocksExisting = existing.getBlocks(); final DataPaletteBlock<IBlockData> blocksExisting = existing.getBlocks();

Datei anzeigen

@ -400,7 +400,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
this.nmsChunk = nmsChunk; this.nmsChunk = nmsChunk;
this.sections = null; this.sections = null;
this.reset(); this.reset();
} else if (existingSection != getSections()[layer]) { } else if (existingSection != getSections(false)[layer]) {
this.sections[layer] = existingSection; this.sections[layer] = existingSection;
this.reset(); this.reset();
} else if (!Arrays.equals(update(layer, new char[4096]), load(layer))) { } else if (!Arrays.equals(update(layer, new char[4096]), load(layer))) {
@ -647,7 +647,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
@Override @Override
public synchronized char[] update(int layer, char[] data) { public synchronized char[] update(int layer, char[] data) {
ChunkSection section = getSections()[layer]; ChunkSection section = getSections(true)[layer];
// Section is null, return empty array // Section is null, return empty array
if (section == null) { if (section == null) {
data = new char[4096]; data = new char[4096];
@ -762,7 +762,10 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
} }
} }
public ChunkSection[] getSections() { public ChunkSection[] getSections(boolean force) {
if (force) {
return sections = getChunk().getSections().clone();
}
ChunkSection[] tmp = sections; ChunkSection[] tmp = sections;
if (tmp == null) { if (tmp == null) {
synchronized (this) { synchronized (this) {
@ -814,7 +817,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
@Override @Override
public boolean hasSection(int layer) { public boolean hasSection(int layer) {
return getSections()[layer] != null; return getSections(false)[layer] != null;
} }
@Override @Override
@ -830,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()[i]; ChunkSection existing = getSections(false)[i];
try { try {
final DataPaletteBlock<IBlockData> blocksExisting = existing.getBlocks(); final DataPaletteBlock<IBlockData> blocksExisting = existing.getBlocks();

Datei anzeigen

@ -1,6 +1,7 @@
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;
@ -27,8 +28,10 @@ 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;
@ -400,7 +403,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks {
this.nmsChunk = nmsChunk; this.nmsChunk = nmsChunk;
this.sections = null; this.sections = null;
this.reset(); this.reset();
} else if (existingSection != getSections()[layer]) { } else if (existingSection != getSections(false)[layer]) {
this.sections[layer] = existingSection; this.sections[layer] = existingSection;
this.reset(); this.reset();
} else if (!Arrays.equals(update(layer, new char[4096]), load(layer))) { } else if (!Arrays.equals(update(layer, new char[4096]), load(layer))) {
@ -647,7 +650,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks {
@Override @Override
public synchronized char[] update(int layer, char[] data) { public synchronized char[] update(int layer, char[] data) {
ChunkSection section = getSections()[layer]; ChunkSection section = getSections(true)[layer];
// Section is null, return empty array // Section is null, return empty array
if (section == null) { if (section == null) {
data = new char[4096]; data = new char[4096];
@ -762,7 +765,10 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks {
} }
} }
public ChunkSection[] getSections() { public ChunkSection[] getSections(boolean force) {
if (force) {
return sections = getChunk().getSections().clone();
}
ChunkSection[] tmp = sections; ChunkSection[] tmp = sections;
if (tmp == null) { if (tmp == null) {
synchronized (this) { synchronized (this) {
@ -814,7 +820,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks {
@Override @Override
public boolean hasSection(int layer) { public boolean hasSection(int layer) {
return getSections()[layer] != null; return getSections(false)[layer] != null;
} }
@Override @Override
@ -830,7 +836,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()[i]; ChunkSection existing = getSections(false)[i];
try { try {
final DataPaletteBlock<IBlockData> blocksExisting = existing.getBlocks(); final DataPaletteBlock<IBlockData> blocksExisting = existing.getBlocks();