mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-12 04:23:54 +00:00
Merge branch 'main' of https://github.com/IntellectualSites/FastAsyncWorldEdit
Conflicts: worldedit-bukkit/build.gradle.kts
This commit is contained in:
@ -27,6 +27,7 @@ import com.sk89q.worldedit.internal.Constants;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import net.minecraft.server.v1_15_R1.BiomeBase;
|
||||
import net.minecraft.server.v1_15_R1.BiomeStorage;
|
||||
import net.minecraft.server.v1_15_R1.BlockPosition;
|
||||
@ -150,7 +151,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks implements BukkitGetBl
|
||||
public void setHeightmapToGet(HeightMapType type, int[] data) {
|
||||
BitArray bitArray = new BitArray(9, 256);
|
||||
bitArray.fromRaw(data);
|
||||
nmsChunk.heightMap.get(HeightMap.Type.valueOf(type.name())).a(bitArray.getData());
|
||||
getChunk().heightMap.get(HeightMap.Type.valueOf(type.name())).a(bitArray.getData());
|
||||
}
|
||||
|
||||
public int getChunkZ() {
|
||||
@ -176,25 +177,25 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks implements BukkitGetBl
|
||||
|
||||
@Override
|
||||
public void removeSectionLighting(int layer, boolean sky) {
|
||||
SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer);
|
||||
SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer);
|
||||
NibbleArray nibble = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).a(sectionPosition);
|
||||
if (nibble != null) {
|
||||
lightUpdate = true;
|
||||
synchronized (nibble) {
|
||||
byte[] bytes = nibble.getCloneIfSet();
|
||||
if (bytes != NibbleArray.EMPTY_NIBBLE) {
|
||||
byte[] bytes = PaperLib.isPaper() ? nibble.getIfSet() : nibble.asBytes();
|
||||
if (!PaperLib.isPaper() || bytes != NibbleArray.EMPTY_NIBBLE) {
|
||||
Arrays.fill(bytes, (byte) 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sky) {
|
||||
SectionPosition sectionPositionSky = SectionPosition.a(nmsChunk.getPos(), layer);
|
||||
SectionPosition sectionPositionSky = SectionPosition.a(getChunk().getPos(), layer);
|
||||
NibbleArray nibbleSky = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(sectionPositionSky);
|
||||
if (nibble != null) {
|
||||
lightUpdate = true;
|
||||
synchronized (nibbleSky) {
|
||||
byte[] bytes = nibbleSky.getCloneIfSet();
|
||||
if (bytes != NibbleArray.EMPTY_NIBBLE) {
|
||||
byte[] bytes = PaperLib.isPaper() ? nibbleSky.getIfSet() : nibbleSky.asBytes();
|
||||
if (!PaperLib.isPaper() || bytes != NibbleArray.EMPTY_NIBBLE) {
|
||||
Arrays.fill(bytes, (byte) 0);
|
||||
}
|
||||
}
|
||||
@ -225,7 +226,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks implements BukkitGetBl
|
||||
public int getSkyLight(int x, int y, int z) {
|
||||
int layer = y >> 4;
|
||||
if (skyLight[layer] == null) {
|
||||
SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer);
|
||||
SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer);
|
||||
NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(sectionPosition);
|
||||
// If the server hasn't generated the section's NibbleArray yet, it will be null
|
||||
if (nibbleArray == null) {
|
||||
@ -245,7 +246,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks implements BukkitGetBl
|
||||
public int getEmmittedLight(int x, int y, int z) {
|
||||
int layer = y >> 4;
|
||||
if (blockLight[layer] == null) {
|
||||
SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer);
|
||||
SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer);
|
||||
NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).a(sectionPosition);
|
||||
// If the server hasn't generated the section's NibbleArray yet, it will be null
|
||||
if (nibbleArray == null) {
|
||||
@ -352,7 +353,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks implements BukkitGetBl
|
||||
|
||||
private void updateGet(BukkitGetBlocks_1_15_2 get, Chunk nmsChunk, ChunkSection[] sections, ChunkSection section, char[] arr, int layer) {
|
||||
synchronized (get) {
|
||||
if (this.nmsChunk != nmsChunk) {
|
||||
if (this.getChunk() != nmsChunk) {
|
||||
this.nmsChunk = nmsChunk;
|
||||
this.sections = sections.clone();
|
||||
this.reset();
|
||||
@ -376,7 +377,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks implements BukkitGetBl
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) {
|
||||
public synchronized <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) {
|
||||
forceLoadSections = false;
|
||||
copy = createCopy ? new BukkitGetBlocks_1_15_2_Copy(world) : null;
|
||||
try {
|
||||
@ -424,7 +425,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks implements BukkitGetBl
|
||||
|
||||
char[] setArr = set.load(layer).clone();
|
||||
if (createCopy) {
|
||||
copy.storeSection(layer, load(layer).clone());
|
||||
copy.storeSection(layer, loadPrivately(layer).clone());
|
||||
}
|
||||
|
||||
ChunkSection newSection;
|
||||
@ -451,19 +452,19 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks implements BukkitGetBl
|
||||
synchronized (this) {
|
||||
synchronized (lock) {
|
||||
lock.untilFree();
|
||||
if (this.nmsChunk != nmsChunk) {
|
||||
if (this.getChunk() != nmsChunk) {
|
||||
this.nmsChunk = nmsChunk;
|
||||
this.sections = null;
|
||||
this.reset();
|
||||
} else if (existingSection != getSections(false)[layer]) {
|
||||
this.sections[layer] = existingSection;
|
||||
this.reset();
|
||||
} else if (!Arrays.equals(update(layer, new char[4096]), load(layer))) {
|
||||
} else if (!Arrays.equals(update(layer, new char[4096]), loadPrivately(layer))) {
|
||||
this.reset(layer);
|
||||
} else if (lock.isModified()) {
|
||||
this.reset(layer);
|
||||
}
|
||||
newSection = BukkitAdapter_1_15_2.newChunkSection(layer, this::load, setArr, fastmode);
|
||||
newSection = BukkitAdapter_1_15_2.newChunkSection(layer, this::loadPrivately, setArr, fastmode);
|
||||
if (!BukkitAdapter_1_15_2.setSectionAtomic(sections, existingSection, newSection, layer)) {
|
||||
log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer);
|
||||
} else {
|
||||
@ -676,6 +677,14 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks implements BukkitGetBl
|
||||
}
|
||||
}
|
||||
|
||||
private char[] loadPrivately(int layer) {
|
||||
if (super.sections[layer].isFull()) {
|
||||
return super.blocks[layer];
|
||||
} else {
|
||||
return BukkitGetBlocks_1_15_2.this.update(layer, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void send(int mask, boolean lighting) {
|
||||
BukkitAdapter_1_15_2.sendChunk(world, chunkX, chunkZ, mask, lighting);
|
||||
|
@ -27,6 +27,7 @@ import com.sk89q.worldedit.internal.Constants;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import net.minecraft.server.v1_16_R1.BiomeBase;
|
||||
import net.minecraft.server.v1_16_R1.BiomeStorage;
|
||||
import net.minecraft.server.v1_16_R1.BlockPosition;
|
||||
@ -151,7 +152,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks implements BukkitGetBl
|
||||
public void setHeightmapToGet(HeightMapType type, int[] data) {
|
||||
BitArrayUnstretched bitArray = new BitArrayUnstretched(9, 256);
|
||||
bitArray.fromRaw(data);
|
||||
nmsChunk.heightMap.get(HeightMap.Type.valueOf(type.name())).a(bitArray.getData());
|
||||
getChunk().heightMap.get(HeightMap.Type.valueOf(type.name())).a(bitArray.getData());
|
||||
}
|
||||
|
||||
public int getChunkZ() {
|
||||
@ -177,25 +178,25 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks implements BukkitGetBl
|
||||
|
||||
@Override
|
||||
public void removeSectionLighting(int layer, boolean sky) {
|
||||
SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer);
|
||||
SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer);
|
||||
NibbleArray nibble = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).a(sectionPosition);
|
||||
if (nibble != null) {
|
||||
lightUpdate = true;
|
||||
synchronized (nibble) {
|
||||
byte[] bytes = nibble.getCloneIfSet();
|
||||
if (bytes != NibbleArray.EMPTY_NIBBLE) {
|
||||
byte[] bytes = PaperLib.isPaper() ? nibble.getIfSet() : nibble.asBytes();
|
||||
if (!PaperLib.isPaper() || bytes != NibbleArray.EMPTY_NIBBLE) {
|
||||
Arrays.fill(bytes, (byte) 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sky) {
|
||||
SectionPosition sectionPositionSky = SectionPosition.a(nmsChunk.getPos(), layer);
|
||||
SectionPosition sectionPositionSky = SectionPosition.a(getChunk().getPos(), layer);
|
||||
NibbleArray nibbleSky = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(sectionPositionSky);
|
||||
if (nibble != null) {
|
||||
lightUpdate = true;
|
||||
synchronized (nibbleSky) {
|
||||
byte[] bytes = nibbleSky.getCloneIfSet();
|
||||
if (bytes != NibbleArray.EMPTY_NIBBLE) {
|
||||
byte[] bytes = PaperLib.isPaper() ? nibbleSky.getIfSet() : nibbleSky.asBytes();
|
||||
if (!PaperLib.isPaper() || bytes != NibbleArray.EMPTY_NIBBLE) {
|
||||
Arrays.fill(bytes, (byte) 0);
|
||||
}
|
||||
}
|
||||
@ -226,7 +227,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks implements BukkitGetBl
|
||||
@Override public int getSkyLight(int x, int y, int z) {
|
||||
int layer = y >> 4;
|
||||
if (skyLight[layer] == null) {
|
||||
SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer);
|
||||
SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer);
|
||||
NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(sectionPosition);
|
||||
// If the server hasn't generated the section's NibbleArray yet, it will be null
|
||||
if (nibbleArray == null) {
|
||||
@ -245,7 +246,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks implements BukkitGetBl
|
||||
@Override public int getEmmittedLight(int x, int y, int z) {
|
||||
int layer = y >> 4;
|
||||
if (blockLight[layer] == null) {
|
||||
SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer);
|
||||
SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer);
|
||||
NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).a(sectionPosition);
|
||||
// If the server hasn't generated the section's NibbleArray yet, it will be null
|
||||
if (nibbleArray == null) {
|
||||
@ -352,7 +353,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks implements BukkitGetBl
|
||||
|
||||
private void updateGet(BukkitGetBlocks_1_16_1 get, Chunk nmsChunk, ChunkSection[] sections, ChunkSection section, char[] arr, int layer) {
|
||||
synchronized (get) {
|
||||
if (this.nmsChunk != nmsChunk) {
|
||||
if (this.getChunk() != nmsChunk) {
|
||||
this.nmsChunk = nmsChunk;
|
||||
this.sections = sections.clone();
|
||||
this.reset();
|
||||
@ -376,7 +377,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks implements BukkitGetBl
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) {
|
||||
public synchronized <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) {
|
||||
forceLoadSections = false;
|
||||
copy = createCopy ? new BukkitGetBlocks_1_16_1_Copy(world) : null;
|
||||
try {
|
||||
@ -424,7 +425,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks implements BukkitGetBl
|
||||
|
||||
char[] setArr = set.load(layer).clone();
|
||||
if (createCopy) {
|
||||
copy.storeSection(layer, load(layer).clone());
|
||||
copy.storeSection(layer, loadPrivately(layer).clone());
|
||||
}
|
||||
|
||||
ChunkSection newSection;
|
||||
@ -451,20 +452,20 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks implements BukkitGetBl
|
||||
synchronized (this) {
|
||||
synchronized (lock) {
|
||||
lock.untilFree();
|
||||
if (this.nmsChunk != nmsChunk) {
|
||||
if (this.getChunk() != nmsChunk) {
|
||||
this.nmsChunk = nmsChunk;
|
||||
this.sections = null;
|
||||
this.reset();
|
||||
} else if (existingSection != getSections(false)[layer]) {
|
||||
this.sections[layer] = existingSection;
|
||||
this.reset();
|
||||
} else if (!Arrays.equals(update(layer, new char[4096]), load(layer))) {
|
||||
} else if (!Arrays.equals(update(layer, new char[4096]), loadPrivately(layer))) {
|
||||
this.reset(layer);
|
||||
} else if (lock.isModified()) {
|
||||
this.reset(layer);
|
||||
}
|
||||
newSection = BukkitAdapter_1_16_1
|
||||
.newChunkSection(layer, this::load, setArr, fastmode);
|
||||
.newChunkSection(layer, this::loadPrivately, setArr, fastmode);
|
||||
if (!BukkitAdapter_1_16_1
|
||||
.setSectionAtomic(sections, existingSection, newSection, layer)) {
|
||||
log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer);
|
||||
@ -678,6 +679,14 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks implements BukkitGetBl
|
||||
}
|
||||
}
|
||||
|
||||
private char[] loadPrivately(int layer) {
|
||||
if (super.sections[layer].isFull()) {
|
||||
return super.blocks[layer];
|
||||
} else {
|
||||
return BukkitGetBlocks_1_16_1.this.update(layer, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void send(int mask, boolean lighting) {
|
||||
BukkitAdapter_1_16_1.sendChunk(world, chunkX, chunkZ, mask, lighting);
|
||||
|
@ -27,6 +27,7 @@ import com.sk89q.worldedit.internal.Constants;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import net.minecraft.server.v1_16_R2.BiomeBase;
|
||||
import net.minecraft.server.v1_16_R2.BiomeStorage;
|
||||
import net.minecraft.server.v1_16_R2.BlockPosition;
|
||||
@ -151,7 +152,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks implements BukkitGetBl
|
||||
public void setHeightmapToGet(HeightMapType type, int[] data) {
|
||||
BitArrayUnstretched bitArray = new BitArrayUnstretched(9, 256);
|
||||
bitArray.fromRaw(data);
|
||||
nmsChunk.heightMap.get(HeightMap.Type.valueOf(type.name())).a(bitArray.getData());
|
||||
getChunk().heightMap.get(HeightMap.Type.valueOf(type.name())).a(bitArray.getData());
|
||||
}
|
||||
|
||||
public int getChunkZ() {
|
||||
@ -177,25 +178,25 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks implements BukkitGetBl
|
||||
|
||||
@Override
|
||||
public void removeSectionLighting(int layer, boolean sky) {
|
||||
SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer);
|
||||
SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer);
|
||||
NibbleArray nibble = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).a(sectionPosition);
|
||||
if (nibble != null) {
|
||||
lightUpdate = true;
|
||||
synchronized (nibble) {
|
||||
byte[] bytes = nibble.getCloneIfSet();
|
||||
if (bytes != NibbleArray.EMPTY_NIBBLE) {
|
||||
byte[] bytes = PaperLib.isPaper() ? nibble.getIfSet() : nibble.asBytes();
|
||||
if (!PaperLib.isPaper() || bytes != NibbleArray.EMPTY_NIBBLE) {
|
||||
Arrays.fill(bytes, (byte) 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sky) {
|
||||
SectionPosition sectionPositionSky = SectionPosition.a(nmsChunk.getPos(), layer);
|
||||
SectionPosition sectionPositionSky = SectionPosition.a(getChunk().getPos(), layer);
|
||||
NibbleArray nibbleSky = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(sectionPositionSky);
|
||||
if (nibble != null) {
|
||||
lightUpdate = true;
|
||||
synchronized (nibbleSky) {
|
||||
byte[] bytes = nibbleSky.getCloneIfSet();
|
||||
if (bytes != NibbleArray.EMPTY_NIBBLE) {
|
||||
byte[] bytes = PaperLib.isPaper() ? nibbleSky.getIfSet() : nibbleSky.asBytes();
|
||||
if (!PaperLib.isPaper() || bytes != NibbleArray.EMPTY_NIBBLE) {
|
||||
Arrays.fill(bytes, (byte) 0);
|
||||
}
|
||||
}
|
||||
@ -227,7 +228,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks implements BukkitGetBl
|
||||
public int getSkyLight(int x, int y, int z) {
|
||||
int layer = y >> 4;
|
||||
if (skyLight[layer] == null) {
|
||||
SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer);
|
||||
SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer);
|
||||
NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(sectionPosition);
|
||||
// If the server hasn't generated the section's NibbleArray yet, it will be null
|
||||
if (nibbleArray == null) {
|
||||
@ -247,7 +248,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks implements BukkitGetBl
|
||||
public int getEmmittedLight(int x, int y, int z) {
|
||||
int layer = y >> 4;
|
||||
if (blockLight[layer] == null) {
|
||||
SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer);
|
||||
SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer);
|
||||
NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).a(sectionPosition);
|
||||
// If the server hasn't generated the section's NibbleArray yet, it will be null
|
||||
if (nibbleArray == null) {
|
||||
@ -355,7 +356,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks implements BukkitGetBl
|
||||
|
||||
private void updateGet(BukkitGetBlocks_1_16_2 get, Chunk nmsChunk, ChunkSection[] sections, ChunkSection section, char[] arr, int layer) {
|
||||
synchronized (get) {
|
||||
if (this.nmsChunk != nmsChunk) {
|
||||
if (this.getChunk() != nmsChunk) {
|
||||
this.nmsChunk = nmsChunk;
|
||||
this.sections = sections.clone();
|
||||
this.reset();
|
||||
@ -379,7 +380,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks implements BukkitGetBl
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) {
|
||||
public synchronized <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) {
|
||||
forceLoadSections = false;
|
||||
copy = createCopy ? new BukkitGetBlocks_1_16_2_Copy(world) : null;
|
||||
try {
|
||||
@ -427,7 +428,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks implements BukkitGetBl
|
||||
|
||||
char[] setArr = set.load(layer).clone();
|
||||
if (createCopy) {
|
||||
copy.storeSection(layer, load(layer).clone());
|
||||
copy.storeSection(layer, loadPrivately(layer).clone());
|
||||
}
|
||||
|
||||
ChunkSection newSection;
|
||||
@ -454,20 +455,20 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks implements BukkitGetBl
|
||||
synchronized (this) {
|
||||
synchronized (lock) {
|
||||
lock.untilFree();
|
||||
if (this.nmsChunk != nmsChunk) {
|
||||
if (this.getChunk() != nmsChunk) {
|
||||
this.nmsChunk = nmsChunk;
|
||||
this.sections = null;
|
||||
this.reset();
|
||||
} else if (existingSection != getSections(false)[layer]) {
|
||||
this.sections[layer] = existingSection;
|
||||
this.reset();
|
||||
} else if (!Arrays.equals(update(layer, new char[4096]), load(layer))) {
|
||||
} else if (!Arrays.equals(update(layer, new char[4096]), loadPrivately(layer))) {
|
||||
this.reset(layer);
|
||||
} else if (lock.isModified()) {
|
||||
this.reset(layer);
|
||||
}
|
||||
newSection = BukkitAdapter_1_16_2
|
||||
.newChunkSection(layer, this::load, setArr, fastmode);
|
||||
.newChunkSection(layer, this::loadPrivately, setArr, fastmode);
|
||||
if (!BukkitAdapter_1_16_2
|
||||
.setSectionAtomic(sections, existingSection, newSection, layer)) {
|
||||
log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer);
|
||||
@ -681,6 +682,14 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks implements BukkitGetBl
|
||||
}
|
||||
}
|
||||
|
||||
private char[] loadPrivately(int layer) {
|
||||
if (super.sections[layer].isFull()) {
|
||||
return super.blocks[layer];
|
||||
} else {
|
||||
return BukkitGetBlocks_1_16_2.this.update(layer, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void send(int mask, boolean lighting) {
|
||||
BukkitAdapter_1_16_2.sendChunk(world, chunkX, chunkZ, mask, lighting);
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.boydti.fawe.bukkit.adapter.mc1_16_4;
|
||||
package com.boydti.fawe.bukkit.adapter.mc1_16_5;
|
||||
|
||||
import com.sk89q.util.ReflectionUtil;
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
@ -12,7 +12,7 @@ import net.minecraft.server.v1_16_R3.ITileEntity;
|
||||
import net.minecraft.server.v1_16_R3.Material;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.block.data.CraftBlockData;
|
||||
|
||||
public class BlockMaterial_1_16_4 implements BlockMaterial {
|
||||
public class BlockMaterial_1_16_5 implements BlockMaterial {
|
||||
private final Block block;
|
||||
private final IBlockData defaultState;
|
||||
private final Material material;
|
||||
@ -21,11 +21,11 @@ public class BlockMaterial_1_16_4 implements BlockMaterial {
|
||||
private final org.bukkit.Material craftMaterial;
|
||||
private final int opacity;
|
||||
|
||||
public BlockMaterial_1_16_4(Block block) {
|
||||
public BlockMaterial_1_16_5(Block block) {
|
||||
this(block, block.getBlockData());
|
||||
}
|
||||
|
||||
public BlockMaterial_1_16_4(Block block, IBlockData defaultState) {
|
||||
public BlockMaterial_1_16_5(Block block, IBlockData defaultState) {
|
||||
this.block = block;
|
||||
this.defaultState = defaultState;
|
||||
this.material = defaultState.getMaterial();
|
@ -1,4 +1,4 @@
|
||||
package com.boydti.fawe.bukkit.adapter.mc1_16_4;
|
||||
package com.boydti.fawe.bukkit.adapter.mc1_16_5;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
@ -51,7 +51,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.function.Function;
|
||||
|
||||
public final class BukkitAdapter_1_16_4 extends NMSAdapter {
|
||||
public final class BukkitAdapter_1_16_5 extends NMSAdapter {
|
||||
/*
|
||||
NMS fields
|
||||
*/
|
||||
@ -310,7 +310,7 @@ public final class BukkitAdapter_1_16_4 extends NMSAdapter {
|
||||
final int ordinal = paletteToBlock[i];
|
||||
blockToPalette[ordinal] = Integer.MAX_VALUE;
|
||||
final BlockState state = BlockTypesCache.states[ordinal];
|
||||
final IBlockData ibd = ((BlockMaterial_1_16_4) state.getMaterial()).getState();
|
||||
final IBlockData ibd = ((BlockMaterial_1_16_5) state.getMaterial()).getState();
|
||||
palette.a(ibd);
|
||||
}
|
||||
try {
|
@ -1,4 +1,4 @@
|
||||
package com.boydti.fawe.bukkit.adapter.mc1_16_4;
|
||||
package com.boydti.fawe.bukkit.adapter.mc1_16_5;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
@ -9,7 +9,7 @@ import com.boydti.fawe.beta.implementation.lighting.HeightMapType;
|
||||
import com.boydti.fawe.beta.implementation.queue.QueueHandler;
|
||||
import com.boydti.fawe.bukkit.adapter.BukkitGetBlocks;
|
||||
import com.boydti.fawe.bukkit.adapter.DelegateLock;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_4.nbt.LazyCompoundTag_1_16_4;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_5.nbt.LazyCompoundTag_1_16_5;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.collection.AdaptedMap;
|
||||
import com.boydti.fawe.object.collection.BitArrayUnstretched;
|
||||
@ -27,6 +27,7 @@ import com.sk89q.worldedit.internal.Constants;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import net.minecraft.server.v1_16_R3.BiomeBase;
|
||||
import net.minecraft.server.v1_16_R3.BiomeStorage;
|
||||
import net.minecraft.server.v1_16_R3.BlockPosition;
|
||||
@ -76,12 +77,12 @@ import java.util.function.Function;
|
||||
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBlocks {
|
||||
public class BukkitGetBlocks_1_16_5 extends CharGetBlocks implements BukkitGetBlocks {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(BukkitGetBlocks_1_16_4.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(BukkitGetBlocks_1_16_5.class);
|
||||
|
||||
private static final Function<BlockPosition, BlockVector3> posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ());
|
||||
private static final Function<TileEntity, CompoundTag> nmsTile2We = tileEntity -> new LazyCompoundTag_1_16_4(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
|
||||
private static final Function<TileEntity, CompoundTag> nmsTile2We = tileEntity -> new LazyCompoundTag_1_16_5(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
|
||||
public ChunkSection[] sections;
|
||||
public Chunk nmsChunk;
|
||||
public WorldServer world;
|
||||
@ -90,15 +91,15 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl
|
||||
public NibbleArray[] blockLight = new NibbleArray[16];
|
||||
public NibbleArray[] skyLight = new NibbleArray[16];
|
||||
private boolean createCopy = false;
|
||||
private BukkitGetBlocks_1_16_4_Copy copy = null;
|
||||
private BukkitGetBlocks_1_16_5_Copy copy = null;
|
||||
private boolean forceLoadSections = true;
|
||||
private boolean lightUpdate = false;
|
||||
|
||||
public BukkitGetBlocks_1_16_4(World world, int chunkX, int chunkZ) {
|
||||
public BukkitGetBlocks_1_16_5(World world, int chunkX, int chunkZ) {
|
||||
this(((CraftWorld) world).getHandle(), chunkX, chunkZ);
|
||||
}
|
||||
|
||||
public BukkitGetBlocks_1_16_4(WorldServer world, int chunkX, int chunkZ) {
|
||||
public BukkitGetBlocks_1_16_5(WorldServer world, int chunkX, int chunkZ) {
|
||||
this.world = world;
|
||||
this.chunkX = chunkX;
|
||||
this.chunkZ = chunkZ;
|
||||
@ -151,7 +152,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl
|
||||
public void setHeightmapToGet(HeightMapType type, int[] data) {
|
||||
BitArrayUnstretched bitArray = new BitArrayUnstretched(9, 256);
|
||||
bitArray.fromRaw(data);
|
||||
nmsChunk.heightMap.get(HeightMap.Type.valueOf(type.name())).a(bitArray.getData());
|
||||
getChunk().heightMap.get(HeightMap.Type.valueOf(type.name())).a(bitArray.getData());
|
||||
}
|
||||
|
||||
public int getChunkZ() {
|
||||
@ -177,25 +178,25 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl
|
||||
|
||||
@Override
|
||||
public void removeSectionLighting(int layer, boolean sky) {
|
||||
SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer);
|
||||
SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer);
|
||||
NibbleArray nibble = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).a(sectionPosition);
|
||||
if (nibble != null) {
|
||||
lightUpdate = true;
|
||||
synchronized (nibble) {
|
||||
byte[] bytes = nibble.getCloneIfSet();
|
||||
if (bytes != NibbleArray.EMPTY_NIBBLE) {
|
||||
byte[] bytes = PaperLib.isPaper() ? nibble.getIfSet() : nibble.asBytes();
|
||||
if (!PaperLib.isPaper() || bytes != NibbleArray.EMPTY_NIBBLE) {
|
||||
Arrays.fill(bytes, (byte) 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sky) {
|
||||
SectionPosition sectionPositionSky = SectionPosition.a(nmsChunk.getPos(), layer);
|
||||
SectionPosition sectionPositionSky = SectionPosition.a(getChunk().getPos(), layer);
|
||||
NibbleArray nibbleSky = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(sectionPositionSky);
|
||||
if (nibble != null) {
|
||||
lightUpdate = true;
|
||||
synchronized (nibbleSky) {
|
||||
byte[] bytes = nibbleSky.getCloneIfSet();
|
||||
if (bytes != NibbleArray.EMPTY_NIBBLE) {
|
||||
byte[] bytes = PaperLib.isPaper() ? nibbleSky.getIfSet() : nibbleSky.asBytes();
|
||||
if (!PaperLib.isPaper() || bytes != NibbleArray.EMPTY_NIBBLE) {
|
||||
Arrays.fill(bytes, (byte) 0);
|
||||
}
|
||||
}
|
||||
@ -211,7 +212,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl
|
||||
if (tileEntity == null) {
|
||||
return null;
|
||||
}
|
||||
return new LazyCompoundTag_1_16_4(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
|
||||
return new LazyCompoundTag_1_16_5(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -227,7 +228,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl
|
||||
public int getSkyLight(int x, int y, int z) {
|
||||
int layer = y >> 4;
|
||||
if (skyLight[layer] == null) {
|
||||
SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer);
|
||||
SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer);
|
||||
NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.SKY).a(sectionPosition);
|
||||
// If the server hasn't generated the section's NibbleArray yet, it will be null
|
||||
if (nibbleArray == null) {
|
||||
@ -247,7 +248,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl
|
||||
public int getEmmittedLight(int x, int y, int z) {
|
||||
int layer = y >> 4;
|
||||
if (blockLight[layer] == null) {
|
||||
SectionPosition sectionPosition = SectionPosition.a(nmsChunk.getPos(), layer);
|
||||
SectionPosition sectionPosition = SectionPosition.a(getChunk().getPos(), layer);
|
||||
NibbleArray nibbleArray = world.getChunkProvider().getLightEngine().a(EnumSkyBlock.BLOCK).a(sectionPosition);
|
||||
// If the server hasn't generated the section's NibbleArray yet, it will be null
|
||||
if (nibbleArray == null) {
|
||||
@ -353,9 +354,9 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl
|
||||
};
|
||||
}
|
||||
|
||||
private void updateGet(BukkitGetBlocks_1_16_4 get, Chunk nmsChunk, ChunkSection[] sections, ChunkSection section, char[] arr, int layer) {
|
||||
private void updateGet(BukkitGetBlocks_1_16_5 get, Chunk nmsChunk, ChunkSection[] sections, ChunkSection section, char[] arr, int layer) {
|
||||
synchronized (get) {
|
||||
if (this.nmsChunk != nmsChunk) {
|
||||
if (this.getChunk() != nmsChunk) {
|
||||
this.nmsChunk = nmsChunk;
|
||||
this.sections = sections.clone();
|
||||
this.reset();
|
||||
@ -375,13 +376,13 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl
|
||||
}
|
||||
|
||||
public Chunk ensureLoaded(net.minecraft.server.v1_16_R3.World nmsWorld, int chunkX, int chunkZ) {
|
||||
return BukkitAdapter_1_16_4.ensureLoaded(nmsWorld, chunkX, chunkZ);
|
||||
return BukkitAdapter_1_16_5.ensureLoaded(nmsWorld, chunkX, chunkZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) {
|
||||
public synchronized <T extends Future<T>> T call(IChunkSet set, Runnable finalizer) {
|
||||
forceLoadSections = false;
|
||||
copy = createCopy ? new BukkitGetBlocks_1_16_4_Copy(world) : null;
|
||||
copy = createCopy ? new BukkitGetBlocks_1_16_5_Copy(world) : null;
|
||||
try {
|
||||
WorldServer nmsWorld = world;
|
||||
Chunk nmsChunk = ensureLoaded(nmsWorld, chunkX, chunkZ);
|
||||
@ -427,14 +428,14 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl
|
||||
|
||||
char[] setArr = set.load(layer).clone();
|
||||
if (createCopy) {
|
||||
copy.storeSection(layer, load(layer).clone());
|
||||
copy.storeSection(layer, loadPrivately(layer).clone());
|
||||
}
|
||||
|
||||
ChunkSection newSection;
|
||||
ChunkSection existingSection = sections[layer];
|
||||
if (existingSection == null) {
|
||||
newSection = BukkitAdapter_1_16_4.newChunkSection(layer, setArr, fastmode);
|
||||
if (BukkitAdapter_1_16_4.setSectionAtomic(sections, null, newSection, layer)) {
|
||||
newSection = BukkitAdapter_1_16_5.newChunkSection(layer, setArr, fastmode);
|
||||
if (BukkitAdapter_1_16_5.setSectionAtomic(sections, null, newSection, layer)) {
|
||||
updateGet(this, nmsChunk, sections, newSection, setArr, layer);
|
||||
continue;
|
||||
} else {
|
||||
@ -446,29 +447,29 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl
|
||||
}
|
||||
}
|
||||
}
|
||||
BukkitAdapter_1_16_4.fieldTickingBlockCount.set(existingSection, (short) 0);
|
||||
BukkitAdapter_1_16_5.fieldTickingBlockCount.set(existingSection, (short) 0);
|
||||
|
||||
//ensure that the server doesn't try to tick the chunksection while we're editing it.
|
||||
DelegateLock lock = BukkitAdapter_1_16_4.applyLock(existingSection);
|
||||
DelegateLock lock = BukkitAdapter_1_16_5.applyLock(existingSection);
|
||||
|
||||
synchronized (this) {
|
||||
synchronized (lock) {
|
||||
lock.untilFree();
|
||||
if (this.nmsChunk != nmsChunk) {
|
||||
if (this.getChunk() != nmsChunk) {
|
||||
this.nmsChunk = nmsChunk;
|
||||
this.sections = null;
|
||||
this.reset();
|
||||
} else if (existingSection != getSections(false)[layer]) {
|
||||
this.sections[layer] = existingSection;
|
||||
this.reset();
|
||||
} else if (!Arrays.equals(update(layer, new char[4096]), load(layer))) {
|
||||
} else if (!Arrays.equals(update(layer, new char[4096]), loadPrivately(layer))) {
|
||||
this.reset(layer);
|
||||
} else if (lock.isModified()) {
|
||||
this.reset(layer);
|
||||
}
|
||||
newSection = BukkitAdapter_1_16_4
|
||||
.newChunkSection(layer, this::load, setArr, fastmode);
|
||||
if (!BukkitAdapter_1_16_4
|
||||
newSection = BukkitAdapter_1_16_5
|
||||
.newChunkSection(layer, this::loadPrivately, setArr, fastmode);
|
||||
if (!BukkitAdapter_1_16_5
|
||||
.setSectionAtomic(sections, existingSection, newSection, layer)) {
|
||||
log.error("Failed to set chunk section:" + chunkX + "," + chunkZ + " layer: " + layer);
|
||||
} else {
|
||||
@ -502,10 +503,10 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl
|
||||
|
||||
Map<HeightMapType, int[]> heightMaps = set.getHeightMaps();
|
||||
for (Map.Entry<HeightMapType, int[]> entry : heightMaps.entrySet()) {
|
||||
BukkitGetBlocks_1_16_4.this.setHeightmapToGet(entry.getKey(), entry.getValue());
|
||||
BukkitGetBlocks_1_16_5.this.setHeightmapToGet(entry.getKey(), entry.getValue());
|
||||
}
|
||||
BukkitGetBlocks_1_16_4.this.setLightingToGet(set.getLight());
|
||||
BukkitGetBlocks_1_16_4.this.setSkyLightingToGet(set.getSkyLight());
|
||||
BukkitGetBlocks_1_16_5.this.setLightingToGet(set.getLight());
|
||||
BukkitGetBlocks_1_16_5.this.setSkyLightingToGet(set.getSkyLight());
|
||||
|
||||
Runnable[] syncTasks = null;
|
||||
|
||||
@ -551,7 +552,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl
|
||||
final ListTag rotTag = (ListTag) entityTagMap.get("Rotation");
|
||||
if (idTag == null || posTag == null || rotTag == null) {
|
||||
getLogger(
|
||||
BukkitGetBlocks_1_16_4.class).debug("Unknown entity tag: " + nativeTag);
|
||||
BukkitGetBlocks_1_16_5.class).debug("Unknown entity tag: " + nativeTag);
|
||||
continue;
|
||||
}
|
||||
final double x = posTag.getDouble(0);
|
||||
@ -681,9 +682,17 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl
|
||||
}
|
||||
}
|
||||
|
||||
private char[] loadPrivately(int layer) {
|
||||
if (super.sections[layer].isFull()) {
|
||||
return super.blocks[layer];
|
||||
} else {
|
||||
return BukkitGetBlocks_1_16_5.this.update(layer, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void send(int mask, boolean lighting) {
|
||||
BukkitAdapter_1_16_4.sendChunk(world, chunkX, chunkZ, mask, lighting);
|
||||
BukkitAdapter_1_16_5.sendChunk(world, chunkX, chunkZ, mask, lighting);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -699,7 +708,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl
|
||||
data = new char[4096];
|
||||
Arrays.fill(data, (char) 1);
|
||||
}
|
||||
DelegateLock lock = BukkitAdapter_1_16_4.applyLock(section);
|
||||
DelegateLock lock = BukkitAdapter_1_16_5.applyLock(section);
|
||||
synchronized (lock) {
|
||||
lock.untilFree();
|
||||
lock.setModified(false);
|
||||
@ -708,10 +717,10 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl
|
||||
FAWE_Spigot_v1_16_R3 adapter = ((FAWE_Spigot_v1_16_R3) WorldEditPlugin.getInstance().getBukkitImplAdapter());
|
||||
|
||||
final DataPaletteBlock<IBlockData> blocks = section.getBlocks();
|
||||
final DataBits bits = (DataBits) BukkitAdapter_1_16_4.fieldBits.get(blocks);
|
||||
final DataPalette<IBlockData> palette = (DataPalette<IBlockData>) BukkitAdapter_1_16_4.fieldPalette.get(blocks);
|
||||
final DataBits bits = (DataBits) BukkitAdapter_1_16_5.fieldBits.get(blocks);
|
||||
final DataPalette<IBlockData> palette = (DataPalette<IBlockData>) BukkitAdapter_1_16_5.fieldPalette.get(blocks);
|
||||
|
||||
final int bitsPerEntry = (int) BukkitAdapter_1_16_4.fieldBitsPerEntry.get(bits);
|
||||
final int bitsPerEntry = (int) BukkitAdapter_1_16_5.fieldBitsPerEntry.get(bits);
|
||||
final long[] blockStates = bits.a();
|
||||
|
||||
new BitArrayUnstretched(bitsPerEntry, 4096, blockStates).toRaw(data);
|
||||
@ -878,7 +887,7 @@ public class BukkitGetBlocks_1_16_4 extends CharGetBlocks implements BukkitGetBl
|
||||
try {
|
||||
final DataPaletteBlock<IBlockData> blocksExisting = existing.getBlocks();
|
||||
|
||||
final DataPalette<IBlockData> palette = (DataPalette<IBlockData>) BukkitAdapter_1_16_4.fieldPalette.get(blocksExisting);
|
||||
final DataPalette<IBlockData> palette = (DataPalette<IBlockData>) BukkitAdapter_1_16_5.fieldPalette.get(blocksExisting);
|
||||
int paletteSize;
|
||||
|
||||
if (palette instanceof DataPaletteLinear) {
|
@ -1,4 +1,4 @@
|
||||
package com.boydti.fawe.bukkit.adapter.mc1_16_4;
|
||||
package com.boydti.fawe.bukkit.adapter.mc1_16_5;
|
||||
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
@ -6,7 +6,7 @@ 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_5.nbt.LazyCompoundTag_1_16_5;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
@ -35,7 +35,7 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class BukkitGetBlocks_1_16_4_Copy implements IChunkGet {
|
||||
public class BukkitGetBlocks_1_16_5_Copy implements IChunkGet {
|
||||
|
||||
private final Map<BlockVector3, CompoundTag> tiles = new HashMap<>();
|
||||
private final Set<CompoundTag> entities = new HashSet<>();
|
||||
@ -43,13 +43,13 @@ public class BukkitGetBlocks_1_16_4_Copy implements IChunkGet {
|
||||
private final char[][] blocks = new char[16][];
|
||||
private final WorldServer world;
|
||||
|
||||
protected BukkitGetBlocks_1_16_4_Copy(WorldServer world) {
|
||||
protected BukkitGetBlocks_1_16_5_Copy(WorldServer world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
protected void storeTile(TileEntity tile) {
|
||||
tiles.put(BlockVector3.at(tile.getPosition().getX(), tile.getPosition().getY(), tile.getPosition().getZ()),
|
||||
new LazyCompoundTag_1_16_4(Suppliers.memoize(() -> tile.save(new NBTTagCompound()))));
|
||||
new LazyCompoundTag_1_16_5(Suppliers.memoize(() -> tile.save(new NBTTagCompound()))));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -115,7 +115,7 @@ public class BukkitGetBlocks_1_16_4_Copy implements IChunkGet {
|
||||
public void setHeightmapToGet(HeightMapType type, int[] data) {}
|
||||
|
||||
protected void storeBiomes(BiomeStorage biomeStorage) {
|
||||
this.biomeStorage = new BiomeStorage(biomeStorage.g, BukkitAdapter_1_16_4.getBiomeArray(biomeStorage).clone());
|
||||
this.biomeStorage = new BiomeStorage(biomeStorage.registry, BukkitAdapter_1_16_5.getBiomeArray(biomeStorage).clone());
|
||||
}
|
||||
|
||||
@Override
|
@ -1,4 +1,4 @@
|
||||
package com.boydti.fawe.bukkit.adapter.mc1_16_4;
|
||||
package com.boydti.fawe.bukkit.adapter.mc1_16_5;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.object.IntPair;
|
||||
@ -214,7 +214,7 @@ public class FAWEWorldNativeAccess_1_16_R3 implements WorldNativeAccess<Chunk, I
|
||||
return;
|
||||
}
|
||||
for (IntPair chunk : toSend) {
|
||||
BukkitAdapter_1_16_4.sendChunk(getWorld().getWorld().getHandle(), chunk.x, chunk.z, 0, false);
|
||||
BukkitAdapter_1_16_5.sendChunk(getWorld().getWorld().getHandle(), chunk.x, chunk.z, 0, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -229,7 +229,7 @@ public class FAWEWorldNativeAccess_1_16_R3 implements WorldNativeAccess<Chunk, I
|
||||
cachedChanges.forEach(cc -> cc.chunk.setType(cc.position, cc.blockData,
|
||||
sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE)));
|
||||
for (IntPair chunk : cachedChunksToSend) {
|
||||
BukkitAdapter_1_16_4.sendChunk(getWorld().getWorld().getHandle(), chunk.x, chunk.z, 0, false);
|
||||
BukkitAdapter_1_16_5.sendChunk(getWorld().getWorld().getHandle(), chunk.x, chunk.z, 0, false);
|
||||
}
|
||||
}
|
||||
};
|
@ -1,10 +1,10 @@
|
||||
package com.boydti.fawe.bukkit.adapter.mc1_16_4;
|
||||
package com.boydti.fawe.bukkit.adapter.mc1_16_5;
|
||||
|
||||
import com.boydti.fawe.bukkit.adapter.MapChunkUtil;
|
||||
import net.minecraft.server.v1_16_R3.PacketPlayOutMapChunk;
|
||||
|
||||
public class MapChunkUtil_1_16_4 extends MapChunkUtil<PacketPlayOutMapChunk> {
|
||||
public MapChunkUtil_1_16_4() throws NoSuchFieldException {
|
||||
public class MapChunkUtil_1_16_5 extends MapChunkUtil<PacketPlayOutMapChunk> {
|
||||
public MapChunkUtil_1_16_5() throws NoSuchFieldException {
|
||||
fieldX = PacketPlayOutMapChunk.class.getDeclaredField("a");
|
||||
fieldZ = PacketPlayOutMapChunk.class.getDeclaredField("b");
|
||||
fieldBitMask = PacketPlayOutMapChunk.class.getDeclaredField("c");
|
@ -1,4 +1,4 @@
|
||||
package com.boydti.fawe.bukkit.adapter.mc1_16_4.nbt;
|
||||
package com.boydti.fawe.bukkit.adapter.mc1_16_5.nbt;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
@ -17,17 +17,17 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class LazyCompoundTag_1_16_4 extends CompoundTag {
|
||||
public class LazyCompoundTag_1_16_5 extends CompoundTag {
|
||||
|
||||
private final Supplier<NBTTagCompound> nmsTag;
|
||||
private CompoundTag cachedValue;
|
||||
|
||||
public LazyCompoundTag_1_16_4(Supplier<NBTTagCompound> tag) {
|
||||
public LazyCompoundTag_1_16_5(Supplier<NBTTagCompound> tag) {
|
||||
super(new HashMap<>());
|
||||
this.nmsTag = tag;
|
||||
}
|
||||
|
||||
public LazyCompoundTag_1_16_4(NBTTagCompound tag) {
|
||||
public LazyCompoundTag_1_16_5(NBTTagCompound tag) {
|
||||
this(() -> tag);
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ public class LazyCompoundTag_1_16_4 extends CompoundTag {
|
||||
NBTTagList nbtList = (NBTTagList) tag;
|
||||
for (NBTBase elem : nbtList) {
|
||||
if (elem instanceof NBTTagCompound) {
|
||||
list.add(new LazyCompoundTag_1_16_4((NBTTagCompound) elem));
|
||||
list.add(new LazyCompoundTag_1_16_5((NBTTagCompound) elem));
|
||||
} else {
|
||||
list.add(WorldEditPlugin.getInstance().getBukkitImplAdapter().toNative(elem));
|
||||
}
|
@ -144,7 +144,7 @@ public final class FAWE_Spigot_v1_15_R2 extends CachedBukkitAdapter implements I
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockMaterial getMaterial(BlockState state) {
|
||||
public synchronized BlockMaterial getMaterial(BlockState state) {
|
||||
IBlockData bs = ((CraftBlockData) Bukkit.createBlockData(state.getAsString())).getState();
|
||||
return new BlockMaterial_1_15_2(bs.getBlock(), bs);
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ public final class FAWE_Spigot_v1_16_R1 extends CachedBukkitAdapter implements I
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockMaterial getMaterial(BlockState state) {
|
||||
public synchronized BlockMaterial getMaterial(BlockState state) {
|
||||
IBlockData bs = ((CraftBlockData) Bukkit.createBlockData(state.getAsString())).getState();
|
||||
return new BlockMaterial_1_16_1(bs.getBlock(), bs);
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ public final class FAWE_Spigot_v1_16_R2 extends CachedBukkitAdapter implements I
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockMaterial getMaterial(BlockState state) {
|
||||
public synchronized BlockMaterial getMaterial(BlockState state) {
|
||||
IBlockData bs = ((CraftBlockData) Bukkit.createBlockData(state.getAsString())).getState();
|
||||
return new BlockMaterial_1_16_2(bs.getBlock(), bs);
|
||||
}
|
||||
|
@ -22,12 +22,12 @@ package com.sk89q.worldedit.bukkit.adapter.impl;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.beta.IChunkGet;
|
||||
import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_4.BlockMaterial_1_16_4;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_4.BukkitAdapter_1_16_4;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_4.BukkitGetBlocks_1_16_4;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_4.FAWEWorldNativeAccess_1_16_R3;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_4.MapChunkUtil_1_16_4;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_4.nbt.LazyCompoundTag_1_16_4;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_5.BlockMaterial_1_16_5;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_5.BukkitAdapter_1_16_5;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_5.BukkitGetBlocks_1_16_5;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_5.FAWEWorldNativeAccess_1_16_R3;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_5.MapChunkUtil_1_16_5;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_5.nbt.LazyCompoundTag_1_16_5;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
@ -130,7 +130,7 @@ public final class FAWE_Spigot_v1_16_R3 extends CachedBukkitAdapter implements I
|
||||
ordinalToIbdID = new int[ibdToStateOrdinal.length]; // size
|
||||
for (int i = 0; i < ibdToStateOrdinal.length; i++) {
|
||||
BlockState state = BlockTypesCache.states[i];
|
||||
BlockMaterial_1_16_4 material = (BlockMaterial_1_16_4) state.getMaterial();
|
||||
BlockMaterial_1_16_5 material = (BlockMaterial_1_16_5) state.getMaterial();
|
||||
int id = Block.REGISTRY_ID.getId(material.getState());
|
||||
char ordinal = state.getOrdinalChar();
|
||||
ibdToStateOrdinal[id] = ordinal;
|
||||
@ -142,13 +142,13 @@ public final class FAWE_Spigot_v1_16_R3 extends CachedBukkitAdapter implements I
|
||||
@Override
|
||||
public BlockMaterial getMaterial(BlockType blockType) {
|
||||
Block block = getBlock(blockType);
|
||||
return new BlockMaterial_1_16_4(block);
|
||||
return new BlockMaterial_1_16_5(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockMaterial getMaterial(BlockState state) {
|
||||
public synchronized BlockMaterial getMaterial(BlockState state) {
|
||||
IBlockData bs = ((CraftBlockData) Bukkit.createBlockData(state.getAsString())).getState();
|
||||
return new BlockMaterial_1_16_4(bs.getBlock(), bs);
|
||||
return new BlockMaterial_1_16_5(bs.getBlock(), bs);
|
||||
}
|
||||
|
||||
public Block getBlock(BlockType blockType) {
|
||||
@ -195,14 +195,14 @@ public final class FAWE_Spigot_v1_16_R3 extends CachedBukkitAdapter implements I
|
||||
World nmsWorld = nmsChunk.getWorld();
|
||||
|
||||
BlockPosition blockPos = new BlockPosition(x, y, z);
|
||||
IBlockData blockData = ((BlockMaterial_1_16_4) state.getMaterial()).getState();
|
||||
IBlockData blockData = ((BlockMaterial_1_16_5) state.getMaterial()).getState();
|
||||
ChunkSection[] sections = nmsChunk.getSections();
|
||||
int y4 = y >> 4;
|
||||
ChunkSection section = sections[y4];
|
||||
|
||||
IBlockData existing;
|
||||
if (section == null) {
|
||||
existing = ((BlockMaterial_1_16_4) BlockTypes.AIR.getDefaultState().getMaterial()).getState();
|
||||
existing = ((BlockMaterial_1_16_5) BlockTypes.AIR.getDefaultState().getMaterial()).getState();
|
||||
} else {
|
||||
existing = section.getType(x & 15, y & 15, z & 15);
|
||||
}
|
||||
@ -303,7 +303,7 @@ public final class FAWE_Spigot_v1_16_R3 extends CachedBukkitAdapter implements I
|
||||
|
||||
@Override
|
||||
public OptionalInt getInternalBlockStateId(BlockState state) {
|
||||
BlockMaterial_1_16_4 material = (BlockMaterial_1_16_4) state.getMaterial();
|
||||
BlockMaterial_1_16_5 material = (BlockMaterial_1_16_5) state.getMaterial();
|
||||
IBlockData mcState = material.getCraftBlockData().getState();
|
||||
return OptionalInt.of(Block.REGISTRY_ID.getId(mcState));
|
||||
}
|
||||
@ -366,16 +366,16 @@ public final class FAWE_Spigot_v1_16_R3 extends CachedBukkitAdapter implements I
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> BlockData adapt(B state) {
|
||||
BlockMaterial_1_16_4 material = (BlockMaterial_1_16_4) state.getMaterial();
|
||||
BlockMaterial_1_16_5 material = (BlockMaterial_1_16_5) state.getMaterial();
|
||||
return material.getCraftBlockData();
|
||||
}
|
||||
|
||||
private MapChunkUtil_1_16_4 mapUtil = new MapChunkUtil_1_16_4();
|
||||
private MapChunkUtil_1_16_5 mapUtil = new MapChunkUtil_1_16_5();
|
||||
|
||||
@Override
|
||||
public void sendFakeChunk(org.bukkit.World world, Player player, ChunkPacket packet) {
|
||||
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
|
||||
PlayerChunk map = BukkitAdapter_1_16_4.getPlayerChunk(nmsWorld, packet.getChunkX(), packet.getChunkZ());
|
||||
PlayerChunk map = BukkitAdapter_1_16_5.getPlayerChunk(nmsWorld, packet.getChunkX(), packet.getChunkZ());
|
||||
if (map != null && map.hasBeenLoaded()) {
|
||||
boolean flag = false;
|
||||
PlayerChunk.d players = map.players;
|
||||
@ -428,8 +428,8 @@ public final class FAWE_Spigot_v1_16_R3 extends CachedBukkitAdapter implements I
|
||||
|
||||
@Override
|
||||
public NBTBase fromNative(Tag foreign) {
|
||||
if (foreign instanceof LazyCompoundTag_1_16_4) {
|
||||
return ((LazyCompoundTag_1_16_4) foreign).get();
|
||||
if (foreign instanceof LazyCompoundTag_1_16_5) {
|
||||
return ((LazyCompoundTag_1_16_5) foreign).get();
|
||||
}
|
||||
return parent.fromNative(foreign);
|
||||
}
|
||||
@ -441,7 +441,7 @@ public final class FAWE_Spigot_v1_16_R3 extends CachedBukkitAdapter implements I
|
||||
|
||||
@Override
|
||||
public IChunkGet get(org.bukkit.World world, int chunkX, int chunkZ) {
|
||||
return new BukkitGetBlocks_1_16_4(world, chunkX, chunkZ);
|
||||
return new BukkitGetBlocks_1_16_5(world, chunkX, chunkZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,7 +3,7 @@ package com.sk89q.worldedit.bukkit.adapter.impl.regen;
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.beta.IChunkCache;
|
||||
import com.boydti.fawe.beta.IChunkGet;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_4.BukkitGetBlocks_1_16_4;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_5.BukkitGetBlocks_1_16_5;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.datafixers.util.Either;
|
||||
import com.mojang.serialization.Codec;
|
||||
@ -328,7 +328,7 @@ public class Regen_v1_16_R3 extends Regenerator<IChunkAccess, ProtoChunk, Chunk,
|
||||
|
||||
@Override
|
||||
protected IChunkCache<IChunkGet> initSourceQueueCache() {
|
||||
return (chunkX, chunkZ) -> new BukkitGetBlocks_1_16_4(freshNMSWorld, chunkX, chunkZ) {
|
||||
return (chunkX, chunkZ) -> new BukkitGetBlocks_1_16_5(freshNMSWorld, chunkX, chunkZ) {
|
||||
@Override
|
||||
public Chunk ensureLoaded(World nmsWorld, int x, int z) {
|
||||
return getChunkAt(x, z);
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user