mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Fix setting the same block multiple times sequencially
This commit is contained in:
@ -20,6 +20,7 @@
|
||||
package com.boydti.fawe.bukkit.adapter.v1_13_1;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.object.collection.ObjObjMap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
|
@ -65,10 +65,10 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
|
||||
public IntFaweChunk copy(boolean shallow) {
|
||||
BukkitChunk_All copy;
|
||||
if (shallow) {
|
||||
copy = new BukkitChunk_All(getParent(), getX(), getZ(), ids, count, air);
|
||||
copy = new BukkitChunk_All(getParent(), getX(), getZ(), setBlocks, count, air);
|
||||
copy.biomes = biomes;
|
||||
} else {
|
||||
copy = new BukkitChunk_All(getParent(), getX(), getZ(), (int[][]) MainUtil.copyNd(ids), count.clone(), air.clone());
|
||||
copy = new BukkitChunk_All(getParent(), getX(), getZ(), (int[][]) MainUtil.copyNd(setBlocks), count.clone(), air.clone());
|
||||
copy.biomes = biomes != null ? biomes.clone() : null;
|
||||
}
|
||||
copy.chunk = chunk;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.boydti.fawe.bukkit.v0;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
@ -10,7 +9,6 @@ import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import java.util.*;
|
||||
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
@ -75,7 +73,7 @@ public class BukkitChunk_All_ReadonlySnapshot extends FaweChunk {
|
||||
@Nullable
|
||||
@Override
|
||||
public int[] getIdArray(int layer) {
|
||||
int[] nextLayer = next.ids[layer];
|
||||
int[] nextLayer = next.setBlocks[layer];
|
||||
if (nextLayer == null) return null;
|
||||
int[] ids = Arrays.copyOf(nextLayer, nextLayer.length);
|
||||
int index = 0;
|
||||
|
@ -6,6 +6,7 @@ import com.boydti.fawe.bukkit.adapter.v1_13_1.Spigot_v1_13_R2;
|
||||
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.example.IntFaweChunk;
|
||||
import com.boydti.fawe.jnbt.anvil.BitArray4096;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
@ -60,6 +61,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.boydti.fawe.bukkit.v0.BukkitQueue_0.getAdapter;
|
||||
import static com.boydti.fawe.bukkit.v1_13.BukkitQueue_1_13.fieldRegistryb;
|
||||
import static com.boydti.fawe.bukkit.v1_13.BukkitQueue_1_13.fieldRegistryc;
|
||||
import static com.boydti.fawe.bukkit.v1_13.BukkitQueue_1_13.fieldRegistryd;
|
||||
@ -69,6 +71,7 @@ import static com.boydti.fawe.bukkit.v1_13.BukkitQueue_1_13.fieldRegistryf;
|
||||
public class BukkitChunk_1_13 extends IntFaweChunk<Chunk, BukkitQueue_1_13> {
|
||||
|
||||
public ChunkSection[] sectionPalettes;
|
||||
|
||||
private static final IBlockData AIR = ((BlockMaterial_1_13) BlockTypes.AIR.getMaterial()).getState();
|
||||
|
||||
/**
|
||||
@ -97,6 +100,52 @@ public class BukkitChunk_1_13 extends IntFaweChunk<Chunk, BukkitQueue_1_13> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[][] getCombinedIdArrays() {
|
||||
if (this.sectionPalettes != null) {
|
||||
for (int i = 0; i < setBlocks.length; i++) {
|
||||
getIdArray(i);
|
||||
}
|
||||
}
|
||||
return this.setBlocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getIdArray(int layer) {
|
||||
if (this.setBlocks[layer] == null && this.sectionPalettes != null) {
|
||||
ChunkSection section = this.sectionPalettes[layer];
|
||||
int[] idsArray = this.setBlocks[layer];
|
||||
if (section != null && idsArray == null) {
|
||||
this.setBlocks[layer] = idsArray = new int[4096];
|
||||
if (!section.a()) {
|
||||
try {
|
||||
DataPaletteBlock<IBlockData> blocks = section.getBlocks();
|
||||
DataBits bits = (DataBits) BukkitQueue_1_13.fieldBits.get(blocks);
|
||||
DataPalette<IBlockData> palette = (DataPalette<IBlockData>) BukkitQueue_1_13.fieldPalette.get(blocks);
|
||||
|
||||
long[] raw = bits.a();
|
||||
int bitsPerEntry = bits.c();
|
||||
|
||||
new BitArray4096(raw, bitsPerEntry).toRaw(idsArray);
|
||||
IBlockData defaultBlock = (IBlockData) BukkitQueue_1_13.fieldDefaultBlock.get(blocks);
|
||||
// TODO optimize away palette.a
|
||||
for (int i = 0; i < 4096; i++) {
|
||||
IBlockData ibd = palette.a(idsArray[i]);
|
||||
if (ibd == null) {
|
||||
ibd = defaultBlock;
|
||||
}
|
||||
int ordinal = ((Spigot_v1_13_R2) getAdapter()).adaptToInt(ibd);
|
||||
idsArray[i] = BlockTypes.states[ordinal].getInternalId();
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.setBlocks[layer];
|
||||
}
|
||||
|
||||
public boolean storeTile(TileEntity tile, BlockPosition pos) {
|
||||
CompoundTag nativeTag = getParent().getTag(tile);
|
||||
setTile(pos.getX() & 15, pos.getY(), pos.getZ() & 15, nativeTag);
|
||||
@ -216,11 +265,11 @@ public class BukkitChunk_1_13 extends IntFaweChunk<Chunk, BukkitQueue_1_13> {
|
||||
public IntFaweChunk<Chunk, BukkitQueue_1_13> copy(boolean shallow) {
|
||||
BukkitChunk_1_13 copy;
|
||||
if (shallow) {
|
||||
copy = new BukkitChunk_1_13(getParent(), getX(), getZ(), ids, count, air);
|
||||
copy = new BukkitChunk_1_13(getParent(), getX(), getZ(), setBlocks, count, air);
|
||||
copy.biomes = biomes;
|
||||
copy.chunk = chunk;
|
||||
} else {
|
||||
copy = new BukkitChunk_1_13(getParent(), getX(), getZ(), (int[][]) MainUtil.copyNd(ids), count.clone(), air.clone());
|
||||
copy = new BukkitChunk_1_13(getParent(), getX(), getZ(), (int[][]) MainUtil.copyNd(setBlocks), count.clone(), air.clone());
|
||||
copy.biomes = biomes != null ? biomes.clone() : null;
|
||||
copy.chunk = chunk;
|
||||
}
|
||||
@ -281,7 +330,7 @@ public class BukkitChunk_1_13 extends IntFaweChunk<Chunk, BukkitQueue_1_13> {
|
||||
public FaweChunk call() {
|
||||
Spigot_v1_13_R2 adapter = (Spigot_v1_13_R2) BukkitQueue_0.getAdapter();
|
||||
try {
|
||||
BukkitChunk_1_13_Copy copy = getParent().getChangeTask() != null ? new BukkitChunk_1_13_Copy(getParent(), getX(), getZ()) : null;
|
||||
BukkitChunk_1_13 copy = getParent().getChangeTask() != null ? new BukkitChunk_1_13(getParent(), getX(), getZ()) : null;
|
||||
final Chunk chunk = this.getChunk();
|
||||
final World world = chunk.getWorld();
|
||||
Settings settings = getParent().getSettings();
|
||||
@ -439,7 +488,7 @@ public class BukkitChunk_1_13 extends IntFaweChunk<Chunk, BukkitQueue_1_13> {
|
||||
section = sections[j] = getParent().newChunkSection(j, flag, array);
|
||||
continue;
|
||||
}
|
||||
} else if (count >= 4096) {
|
||||
} else if (count >= 4096 && false) {
|
||||
if (countAir >= 4096) {
|
||||
sections[j] = null;
|
||||
continue;
|
||||
@ -452,6 +501,11 @@ public class BukkitChunk_1_13 extends IntFaweChunk<Chunk, BukkitQueue_1_13> {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (count >= 4096) {
|
||||
for (int i = 0; i < 4096; i++) {
|
||||
if (array[i] == 0) System.out.println("Invalid ");
|
||||
}
|
||||
}
|
||||
int by = j << 4;
|
||||
DataPaletteBlock<IBlockData> nibble = section.getBlocks();
|
||||
int nonEmptyBlockCount = 0;
|
||||
|
@ -1,90 +0,0 @@
|
||||
package com.boydti.fawe.bukkit.v1_13;
|
||||
|
||||
import com.boydti.fawe.bukkit.adapter.v1_13_1.Spigot_v1_13_R2;
|
||||
import com.boydti.fawe.jnbt.anvil.BitArray4096;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import net.minecraft.server.v1_13_R2.ChunkSection;
|
||||
import net.minecraft.server.v1_13_R2.DataBits;
|
||||
import net.minecraft.server.v1_13_R2.DataPalette;
|
||||
import net.minecraft.server.v1_13_R2.DataPaletteBlock;
|
||||
import net.minecraft.server.v1_13_R2.IBlockData;
|
||||
|
||||
import static com.boydti.fawe.bukkit.v0.BukkitQueue_0.getAdapter;
|
||||
|
||||
public class BukkitChunk_1_13_Copy extends BukkitChunk_1_13 {
|
||||
public BukkitChunk_1_13_Copy(FaweQueue parent, int x, int z) {
|
||||
super(parent, x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[][] getCombinedIdArrays() {
|
||||
if (this.sectionPalettes == null) {
|
||||
return this.ids;
|
||||
}
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
getIdArray(i);
|
||||
}
|
||||
return super.getCombinedIdArrays();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getIdArray(int layer) {
|
||||
if (this.sectionPalettes != null) {
|
||||
ChunkSection section = this.sectionPalettes[layer];
|
||||
int[] idsArray = this.ids[layer];
|
||||
if (section != null && idsArray == null) {
|
||||
idsArray = new int[4096];
|
||||
if (!section.a()) {
|
||||
try {
|
||||
DataPaletteBlock<IBlockData> blocks = section.getBlocks();
|
||||
DataBits bits = (DataBits) BukkitQueue_1_13.fieldBits.get(blocks);
|
||||
DataPalette<IBlockData> palette = (DataPalette<IBlockData>) BukkitQueue_1_13.fieldPalette.get(blocks);
|
||||
|
||||
long[] raw = bits.a();
|
||||
int bitsPerEntry = bits.c();
|
||||
|
||||
new BitArray4096(raw, bitsPerEntry).toRaw(idsArray);
|
||||
IBlockData defaultBlock = (IBlockData) BukkitQueue_1_13.fieldDefaultBlock.get(blocks);
|
||||
// TODO optimize away palette.a
|
||||
for (int i = 0; i < 4096; i++) {
|
||||
IBlockData ibd = palette.a(idsArray[i]);
|
||||
if (ibd == null) {
|
||||
ibd = defaultBlock;
|
||||
}
|
||||
int ordinal = ((Spigot_v1_13_R2) getAdapter()).adaptToInt(ibd);
|
||||
idsArray[i] = BlockTypes.states[ordinal].getInternalId();
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return idsArray;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> void setBlock(int x, int y, int z, B block) {
|
||||
throw new UnsupportedOperationException("Read only");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(BiomeType biome) {
|
||||
throw new UnsupportedOperationException("Read only");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int x, int z, BiomeType biome) {
|
||||
throw new UnsupportedOperationException("Read only");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(int x, int y, int z, int combinedId) {
|
||||
throw new UnsupportedOperationException("Read only");
|
||||
}
|
||||
}
|
@ -879,7 +879,11 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
|
||||
|
||||
// BlockStates
|
||||
int bitsPerEntry = MathMan.log2nlz(num_palette - 1);
|
||||
bitsPerEntry = Math.max(bitsPerEntry, 4);
|
||||
if (Settings.IMP.PROTOCOL_SUPPORT_FIX || num_palette != 1) {
|
||||
bitsPerEntry = Math.max(bitsPerEntry, 4); // Protocol support breaks <4 bits per entry
|
||||
} else {
|
||||
bitsPerEntry = Math.max(bitsPerEntry, 1); // For some reason minecraft needs 4096 bits to store 0 entries
|
||||
}
|
||||
|
||||
int blockBitArrayEnd = (bitsPerEntry * 4096) >> 6;
|
||||
if (num_palette == 1) {
|
||||
|
Reference in New Issue
Block a user