1.16.1 Prep work

Dieser Commit ist enthalten in:
MattBDev 2020-06-25 19:56:10 -04:00
Ursprung 6d056847c1
Commit b7debce4d4
9 geänderte Dateien mit 146 neuen und 176 gelöschten Zeilen

Datei anzeigen

@ -41,12 +41,13 @@ dependencies {
"compile"("org.spigotmcv1_14_r1:spigotmcv1_14_r1:1_14_r1") "compile"("org.spigotmcv1_14_r1:spigotmcv1_14_r1:1_14_r1")
"compile"("org.spigotmcv1_15_r1:spigotmcv1_15_r1:1_15_r1") "compile"("org.spigotmcv1_15_r1:spigotmcv1_15_r1:1_15_r1")
"compile"("it.unimi.dsi:fastutil:8.2.1") "compile"("it.unimi.dsi:fastutil:8.2.1")
"api"("com.destroystokyo.paper:paper-api:1.15.2-R0.1-SNAPSHOT") { "api"("com.destroystokyo.paper:paper-api:1.16.1-R0.1-SNAPSHOT") {
exclude("junit", "junit") exclude("junit", "junit")
isTransitive = false isTransitive = false
} }
"compileOnly"("org.spigotmc:spigot:1.14.4-R0.1-SNAPSHOT") "compileOnly"("org.spigotmc:spigot:1.14.4-R0.1-SNAPSHOT")
"compileOnly"("org.spigotmc:spigot:1.15.2-R0.1-SNAPSHOT") "compileOnly"("org.spigotmc:spigot:1.15.2-R0.1-SNAPSHOT")
"compileOnly"("org.spigotmc:spigot:1.16.1-R0.1-SNAPSHOT")
"implementation"("io.papermc:paperlib:1.0.2") "implementation"("io.papermc:paperlib:1.0.2")
"compileOnly"("com.sk89q:dummypermscompat:1.10") "compileOnly"("com.sk89q:dummypermscompat:1.10")
"implementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1") "implementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")

Datei anzeigen

@ -1,15 +1,11 @@
package com.boydti.fawe.bukkit.adapter.mc1_15; package com.boydti.fawe.bukkit.adapter.mc1_16_1;
import com.sk89q.util.ReflectionUtil; import com.sk89q.util.ReflectionUtil;
import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.BlockMaterial;
import net.minecraft.server.v1_15_R1.Block; import net.minecraft.server.v1_16_R1.*;
import net.minecraft.server.v1_15_R1.EnumPistonReaction; import org.bukkit.craftbukkit.v1_16_R1.block.data.CraftBlockData;
import net.minecraft.server.v1_15_R1.IBlockData;
import net.minecraft.server.v1_15_R1.ITileEntity;
import net.minecraft.server.v1_15_R1.Material;
import org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData;
public class BlockMaterial_1_15 implements BlockMaterial { public class BlockMaterial_1_16_1 implements BlockMaterial {
private final Block block; private final Block block;
private final IBlockData defaultState; private final IBlockData defaultState;
private final Material material; private final Material material;
@ -17,17 +13,17 @@ public class BlockMaterial_1_15 implements BlockMaterial {
private final CraftBlockData craftBlockData; private final CraftBlockData craftBlockData;
private final org.bukkit.Material craftMaterial; private final org.bukkit.Material craftMaterial;
public BlockMaterial_1_15(Block block) { public BlockMaterial_1_16_1(Block block) {
this(block, block.getBlockData()); this(block, block.getBlockData());
} }
public BlockMaterial_1_15(Block block, IBlockData defaultState) { public BlockMaterial_1_16_1(Block block, IBlockData defaultState) {
this.block = block; this.block = block;
this.defaultState = defaultState; this.defaultState = defaultState;
this.material = defaultState.getMaterial(); this.material = defaultState.getMaterial();
this.craftBlockData = CraftBlockData.fromData(defaultState); this.craftBlockData = CraftBlockData.fromData(defaultState);
this.craftMaterial = craftBlockData.getMaterial(); this.craftMaterial = craftBlockData.getMaterial();
this.isTranslucent = !(boolean) ReflectionUtil.getField(Block.class, block, "v"); this.isTranslucent = !(boolean) ReflectionUtil.getField(Block.class, block, "v"); //TODO Update Mapping for 1.16.1
} }
public Block getBlock() { public Block getBlock() {
@ -78,7 +74,7 @@ public class BlockMaterial_1_15 implements BlockMaterial {
@Override @Override
public float getHardness() { public float getHardness() {
return block.strength; return craftBlockData.getState().strength;
} }
@Override @Override
@ -88,12 +84,12 @@ public class BlockMaterial_1_15 implements BlockMaterial {
@Override @Override
public float getSlipperiness() { public float getSlipperiness() {
return block.m(); return block.getFrictionFactor();
} }
@Override @Override
public int getLightValue() { public int getLightValue() {
return defaultState.h(); return defaultState.f();
} }
@Override @Override
@ -128,7 +124,8 @@ public class BlockMaterial_1_15 implements BlockMaterial {
@Override @Override
public boolean isToolRequired() { public boolean isToolRequired() {
return !material.isAlwaysDestroyable(); //TODO Removed in 1.16.1 Replacement not found.
return true;
} }
@Override @Override
@ -148,6 +145,6 @@ public class BlockMaterial_1_15 implements BlockMaterial {
@Override @Override
public int getMapColor() { public int getMapColor() {
return material.i().rgb; return material.h().rgb;
} }
} }

Datei anzeigen

@ -1,4 +1,4 @@
package com.boydti.fawe.bukkit.adapter.mc1_15; package com.boydti.fawe.bukkit.adapter.mc1_16_1;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
@ -14,22 +14,9 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypesCache; import com.sk89q.worldedit.world.block.BlockTypesCache;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import net.jpountz.util.UnsafeUtils; import net.jpountz.util.UnsafeUtils;
import net.minecraft.server.v1_15_R1.Block; import net.minecraft.server.v1_16_R1.*;
import net.minecraft.server.v1_15_R1.Chunk; import org.bukkit.craftbukkit.v1_16_R1.CraftChunk;
import net.minecraft.server.v1_15_R1.ChunkCoordIntPair; import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
import net.minecraft.server.v1_15_R1.ChunkSection;
import net.minecraft.server.v1_15_R1.DataBits;
import net.minecraft.server.v1_15_R1.DataPalette;
import net.minecraft.server.v1_15_R1.DataPaletteBlock;
import net.minecraft.server.v1_15_R1.DataPaletteLinear;
import net.minecraft.server.v1_15_R1.GameProfileSerializer;
import net.minecraft.server.v1_15_R1.IBlockData;
import net.minecraft.server.v1_15_R1.PacketPlayOutLightUpdate;
import net.minecraft.server.v1_15_R1.PlayerChunk;
import net.minecraft.server.v1_15_R1.PlayerChunkMap;
import net.minecraft.server.v1_15_R1.World;
import org.bukkit.craftbukkit.v1_15_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import sun.misc.Unsafe; import sun.misc.Unsafe;
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;
@ -43,7 +30,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Function; import java.util.function.Function;
public final class BukkitAdapter_1_15 extends NMSAdapter { public final class BukkitAdapter_1_16_1 extends NMSAdapter {
/* /*
NMS fields NMS fields
*/ */
@ -60,6 +47,8 @@ public final class BukkitAdapter_1_15 extends NMSAdapter {
private final static MethodHandle methodGetVisibleChunk; private final static MethodHandle methodGetVisibleChunk;
public final static MethodHandle methodSetLightNibbleArray;
private static final int CHUNKSECTION_BASE; private static final int CHUNKSECTION_BASE;
private static final int CHUNKSECTION_SHIFT; private static final int CHUNKSECTION_SHIFT;
@ -86,12 +75,14 @@ public final class BukkitAdapter_1_15 extends NMSAdapter {
fieldDirtyBits = PlayerChunk.class.getDeclaredField("r"); fieldDirtyBits = PlayerChunk.class.getDeclaredField("r");
fieldDirtyBits.setAccessible(true); fieldDirtyBits.setAccessible(true);
fieldTickingBlockCount.setAccessible(true);
Method declaredGetVisibleChunk = PlayerChunkMap.class.getDeclaredMethod("getVisibleChunk", long.class); Method declaredGetVisibleChunk = PlayerChunkMap.class.getDeclaredMethod("getVisibleChunk", long.class);
declaredGetVisibleChunk.setAccessible(true); declaredGetVisibleChunk.setAccessible(true);
methodGetVisibleChunk = MethodHandles.lookup().unreflect(declaredGetVisibleChunk); methodGetVisibleChunk = MethodHandles.lookup().unreflect(declaredGetVisibleChunk);
Method declaredSetLightNibbleArray = LightEngineStorage.class.getDeclaredMethod("a", long.class, NibbleArray.class);
declaredSetLightNibbleArray.setAccessible(true);
methodSetLightNibbleArray = MethodHandles.lookup().unreflect(declaredSetLightNibbleArray);
Field tmp = DataPaletteBlock.class.getDeclaredField("j"); Field tmp = DataPaletteBlock.class.getDeclaredField("j");
ReflectionUtils.setAccessibleNonFinal(tmp); ReflectionUtils.setAccessibleNonFinal(tmp);
fieldLock = tmp; fieldLock = tmp;
@ -120,6 +111,7 @@ public final class BukkitAdapter_1_15 extends NMSAdapter {
} }
protected static DelegateLock applyLock(ChunkSection section) { protected static DelegateLock applyLock(ChunkSection section) {
//todo there has to be a better way to do this. Maybe using a() in DataPaletteBlock which acquires the lock in NMS?
try { try {
synchronized (section) { synchronized (section) {
DataPaletteBlock<IBlockData> blocks = section.getBlocks(); DataPaletteBlock<IBlockData> blocks = section.getBlocks();
@ -159,7 +151,7 @@ public final class BukkitAdapter_1_15 extends NMSAdapter {
return TaskManager.IMP.sync(() -> nmsWorld.getChunkAt(X, Z)); return TaskManager.IMP.sync(() -> nmsWorld.getChunkAt(X, Z));
} }
public static PlayerChunk getPlayerChunk(net.minecraft.server.v1_15_R1.WorldServer nmsWorld, final int cx, final int cz) { public static PlayerChunk getPlayerChunk(WorldServer nmsWorld, final int cx, final int cz) {
PlayerChunkMap chunkMap = nmsWorld.getChunkProvider().playerChunkMap; PlayerChunkMap chunkMap = nmsWorld.getChunkProvider().playerChunkMap;
try { try {
return (PlayerChunk)methodGetVisibleChunk.invoke(chunkMap, ChunkCoordIntPair.pair(cx, cz)); return (PlayerChunk)methodGetVisibleChunk.invoke(chunkMap, ChunkCoordIntPair.pair(cx, cz));
@ -168,7 +160,7 @@ public final class BukkitAdapter_1_15 extends NMSAdapter {
} }
} }
public static void sendChunk(net.minecraft.server.v1_15_R1.WorldServer nmsWorld, int X, int Z, int mask, boolean lighting) { public static void sendChunk(WorldServer nmsWorld, int X, int Z, int mask, boolean lighting) {
PlayerChunk playerChunk = getPlayerChunk(nmsWorld, X, Z); PlayerChunk playerChunk = getPlayerChunk(nmsWorld, X, Z);
if (playerChunk == null) { if (playerChunk == null) {
return; return;
@ -227,9 +219,11 @@ public final class BukkitAdapter_1_15 extends NMSAdapter {
Map<BlockVector3, Integer> ticking_blocks = new HashMap<>(); Map<BlockVector3, Integer> ticking_blocks = new HashMap<>();
int air; int air;
if (get == null) { if (get == null) {
air = createPalette(blockToPalette, paletteToBlock, blocksCopy, num_palette_buffer, set, ticking_blocks, fastmode); air = createPalette(blockToPalette, paletteToBlock, blocksCopy, num_palette_buffer,
set, ticking_blocks, fastmode);
} else { } else {
air = createPalette(layer, blockToPalette, paletteToBlock, blocksCopy, num_palette_buffer, get, set, ticking_blocks, fastmode); air = createPalette(layer, blockToPalette, paletteToBlock, blocksCopy,
num_palette_buffer, get, set, ticking_blocks, fastmode);
} }
int num_palette = num_palette_buffer[0]; int num_palette = num_palette_buffer[0];
// BlockStates // BlockStates
@ -257,14 +251,14 @@ public final class BukkitAdapter_1_15 extends NMSAdapter {
final DataBits nmsBits = new DataBits(bitsPerEntry, 4096, bits); final DataBits nmsBits = new DataBits(bitsPerEntry, 4096, bits);
final DataPalette<IBlockData> palette; final DataPalette<IBlockData> palette;
// palette = new DataPaletteHash<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d, GameProfileSerializer::a); // palette = new DataPaletteHash<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d, GameProfileSerializer::a);
palette = new DataPaletteLinear<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d); palette = new DataPaletteLinear<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::c);
// set palette // set palette
for (int i = 0; i < num_palette; i++) { for (int i = 0; i < num_palette; i++) {
final int ordinal = paletteToBlock[i]; final int ordinal = paletteToBlock[i];
blockToPalette[ordinal] = Integer.MAX_VALUE; blockToPalette[ordinal] = Integer.MAX_VALUE;
final BlockState state = BlockTypesCache.states[ordinal]; final BlockState state = BlockTypesCache.states[ordinal];
final IBlockData ibd = ((BlockMaterial_1_15) state.getMaterial()).getState(); final IBlockData ibd = ((BlockMaterial_1_16_1) state.getMaterial()).getState();
palette.a(ibd); palette.a(ibd);
} }
try { try {
@ -272,10 +266,11 @@ public final class BukkitAdapter_1_15 extends NMSAdapter {
fieldPalette.set(dataPaletteBlocks, palette); fieldPalette.set(dataPaletteBlocks, palette);
fieldSize.set(dataPaletteBlocks, bitsPerEntry); fieldSize.set(dataPaletteBlocks, bitsPerEntry);
setCount(ticking_blocks.size(), 4096 - air, section); setCount(ticking_blocks.size(), 4096 - air, section);
ticking_blocks.forEach((pos, ordinal) -> { if (!fastmode) {
section.setType(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), ticking_blocks.forEach((pos, ordinal) -> section
Block.getByCombinedId(ordinal)); .setType(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(),
}); Block.getByCombinedId(ordinal)));
}
} catch (final IllegalAccessException | NoSuchFieldException e) { } catch (final IllegalAccessException | NoSuchFieldException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

Datei anzeigen

@ -1,6 +1,4 @@
package com.boydti.fawe.bukkit.adapter.mc1_15; package com.boydti.fawe.bukkit.adapter.mc1_16_1;
import static org.slf4j.LoggerFactory.getLogger;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
@ -9,71 +7,47 @@ import com.boydti.fawe.beta.implementation.blocks.CharBlocks;
import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks; import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks;
import com.boydti.fawe.beta.implementation.queue.QueueHandler; import com.boydti.fawe.beta.implementation.queue.QueueHandler;
import com.boydti.fawe.bukkit.adapter.DelegateLock; import com.boydti.fawe.bukkit.adapter.DelegateLock;
import com.boydti.fawe.bukkit.adapter.mc1_15.nbt.LazyCompoundTag_1_15; import com.boydti.fawe.bukkit.adapter.mc1_16_1.nbt.LazyCompoundTag_1_16_1;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.collection.AdaptedMap; import com.boydti.fawe.object.collection.AdaptedMap;
import com.boydti.fawe.object.collection.BitArray; import com.boydti.fawe.object.collection.BitArray;
import com.google.common.base.Suppliers; import com.google.common.base.Suppliers;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.ListTag;
import com.sk89q.jnbt.LongTag;
import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
import com.sk89q.jnbt.*;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_15_R1; import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_16_R1;
import com.sk89q.worldedit.internal.Constants; 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 java.util.AbstractSet; import net.minecraft.server.v1_16_R1.*;
import java.util.Arrays; import org.bukkit.World;
import java.util.Collection; import org.bukkit.block.Biome;
import java.util.Collections; import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
import java.util.Iterator; import org.bukkit.craftbukkit.v1_16_R1.block.CraftBlock;
import java.util.List; import org.bukkit.event.entity.CreatureSpawnEvent;
import java.util.Map; import org.jetbrains.annotations.NotNull;
import java.util.HashMap; import org.slf4j.Logger;
import java.util.Set; import org.slf4j.LoggerFactory;
import java.util.UUID;
import javax.annotation.Nullable;
import java.util.*;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import net.minecraft.server.v1_15_R1.BiomeBase;
import net.minecraft.server.v1_15_R1.BiomeStorage;
import net.minecraft.server.v1_15_R1.BlockPosition;
import net.minecraft.server.v1_15_R1.Chunk;
import net.minecraft.server.v1_15_R1.ChunkSection;
import net.minecraft.server.v1_15_R1.DataBits;
import net.minecraft.server.v1_15_R1.DataPalette;
import net.minecraft.server.v1_15_R1.DataPaletteBlock;
import net.minecraft.server.v1_15_R1.DataPaletteHash;
import net.minecraft.server.v1_15_R1.DataPaletteLinear;
import net.minecraft.server.v1_15_R1.Entity;
import net.minecraft.server.v1_15_R1.EntityTypes;
import net.minecraft.server.v1_15_R1.EnumSkyBlock;
import net.minecraft.server.v1_15_R1.IBlockData;
import net.minecraft.server.v1_15_R1.LightEngineThreaded;
import net.minecraft.server.v1_15_R1.NBTTagCompound;
import net.minecraft.server.v1_15_R1.NBTTagInt;
import net.minecraft.server.v1_15_R1.NibbleArray;
import net.minecraft.server.v1_15_R1.SectionPosition;
import net.minecraft.server.v1_15_R1.TileEntity;
import net.minecraft.server.v1_15_R1.WorldServer;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.jetbrains.annotations.NotNull;
public class BukkitGetBlocks_1_15 extends CharGetBlocks { import static org.slf4j.LoggerFactory.getLogger;
public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
private static final Logger log = LoggerFactory.getLogger(
BukkitGetBlocks_1_16_1.class);
private static final Function<BlockPosition, BlockVector3> posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ()); private static final Function<BlockPosition, BlockVector3> posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ());
private final static Function<TileEntity, CompoundTag> nmsTile2We = tileEntity -> new LazyCompoundTag_1_15(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound()))); private final static Function<TileEntity, CompoundTag> nmsTile2We = tileEntity -> new LazyCompoundTag_1_16_1(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
public ChunkSection[] sections; public ChunkSection[] sections;
public Chunk nmsChunk; public Chunk nmsChunk;
public WorldServer world; public WorldServer world;
@ -81,11 +55,11 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
public NibbleArray[] blockLight = new NibbleArray[16]; public NibbleArray[] blockLight = new NibbleArray[16];
public NibbleArray[] skyLight = new NibbleArray[16]; public NibbleArray[] skyLight = new NibbleArray[16];
public BukkitGetBlocks_1_15(World world, int X, int Z) { public BukkitGetBlocks_1_16_1(World world, int X, int Z) {
this(((CraftWorld) world).getHandle(), X, Z); this(((CraftWorld) world).getHandle(), X, Z);
} }
public BukkitGetBlocks_1_15(WorldServer world, int X, int Z) { public BukkitGetBlocks_1_16_1(WorldServer world, int X, int Z) {
this.world = world; this.world = world;
this.X = X; this.X = X;
this.Z = Z; this.Z = Z;
@ -120,7 +94,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
if (tileEntity == null) { if (tileEntity == null) {
return null; return null;
} }
return new LazyCompoundTag_1_15(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound()))); return new LazyCompoundTag_1_16_1(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
} }
@Override @Override
@ -219,19 +193,21 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
@NotNull @NotNull
@Override @Override
public Iterator<CompoundTag> iterator() { public Iterator<CompoundTag> iterator() {
Iterable<CompoundTag> result = StreamSupport Iterable<CompoundTag> result = Iterables.transform(Iterables.concat(slices), new com.google.common.base.Function<Entity, CompoundTag>() {
.stream(Iterables.concat(slices).spliterator(), false).map(input -> { @Nullable
BukkitImplAdapter adapter = WorldEditPlugin.getInstance() @Override
.getBukkitImplAdapter(); public CompoundTag apply(@Nullable Entity input) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound tag = new NBTTagCompound();
return (CompoundTag) adapter.toNative(input.save(tag)); return (CompoundTag) adapter.toNative(input.save(tag));
}).collect(Collectors.toList()); }
});
return result.iterator(); return result.iterator();
} }
}; };
} }
private void updateGet(BukkitGetBlocks_1_15 get, Chunk nmsChunk, ChunkSection[] sections, ChunkSection section, char[] arr, int layer) { private void updateGet(BukkitGetBlocks_1_16_1 get, Chunk nmsChunk, ChunkSection[] sections, ChunkSection section, char[] arr, int layer) {
synchronized (get) { synchronized (get) {
if (this.nmsChunk != nmsChunk) { if (this.nmsChunk != nmsChunk) {
this.nmsChunk = nmsChunk; this.nmsChunk = nmsChunk;
@ -242,7 +218,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
this.sections = sections.clone(); this.sections = sections.clone();
} }
if (this.sections[layer] != section) { if (this.sections[layer] != section) {
this.sections[layer] = section; this.sections[layer] = new ChunkSection[]{section}.clone()[0];
} }
this.blocks[layer] = arr; this.blocks[layer] = arr;
} }
@ -254,7 +230,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
} }
public Chunk ensureLoaded(net.minecraft.server.v1_15_R1.World nmsWorld, int X, int Z) { public Chunk ensureLoaded(net.minecraft.server.v1_15_R1.World nmsWorld, int X, int Z) {
return BukkitAdapter_1_15.ensureLoaded(nmsWorld, X, Z); return BukkitAdapter_1_16_1.ensureLoaded(nmsWorld, X, Z);
} }
@Override @Override
@ -266,6 +242,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
// Remove existing tiles // Remove existing tiles
{ {
// Create a copy so that we can remove blocks
Map<BlockPosition, TileEntity> tiles = new HashMap<>(nmsChunk.getTileEntities()); Map<BlockPosition, TileEntity> tiles = new HashMap<>(nmsChunk.getTileEntities());
if (!tiles.isEmpty()) { if (!tiles.isEmpty()) {
for (Map.Entry<BlockPosition, TileEntity> entry : tiles.entrySet()) { for (Map.Entry<BlockPosition, TileEntity> entry : tiles.entrySet()) {
@ -277,7 +254,9 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
if (!set.hasSection(layer)) { if (!set.hasSection(layer)) {
continue; continue;
} }
if (set.getBlock(lx, ly, lz).getOrdinal() != 0) {
int ordinal = set.getBlock(lx, ly, lz).getOrdinal();
if (ordinal != 0) {
TileEntity tile = entry.getValue(); TileEntity tile = entry.getValue();
nmsChunk.removeTileEntity(tile.getPosition()); nmsChunk.removeTileEntity(tile.getPosition());
} }
@ -290,7 +269,9 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
ChunkSection[] sections = nmsChunk.getSections(); ChunkSection[] sections = nmsChunk.getSections();
for (int layer = 0; layer < 16; layer++) { for (int layer = 0; layer < 16; layer++) {
if (!set.hasSection(layer)) continue; if (!set.hasSection(layer)){
continue;
}
bitMask |= 1 << layer; bitMask |= 1 << layer;
@ -298,8 +279,8 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
ChunkSection newSection; ChunkSection newSection;
ChunkSection existingSection = sections[layer]; ChunkSection existingSection = sections[layer];
if (existingSection == null) { if (existingSection == null) {
newSection = BukkitAdapter_1_15.newChunkSection(layer, setArr, fastmode); newSection = BukkitAdapter_1_16_1.newChunkSection(layer, setArr, fastmode);
if (BukkitAdapter_1_15.setSectionAtomic(sections, null, newSection, layer)) { if (BukkitAdapter_1_16_1.setSectionAtomic(sections, null, newSection, layer)) {
updateGet(this, nmsChunk, sections, newSection, setArr, layer); updateGet(this, nmsChunk, sections, newSection, setArr, layer);
continue; continue;
} else { } else {
@ -310,11 +291,11 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
} }
} }
} }
BukkitAdapter_1_16_1.fieldTickingBlockCount.set(existingSection, (short) 0);
//ensure that the server doesn't try to tick the chunksection while we're editing it. //ensure that the server doesn't try to tick the chunksection while we're editing it.
BukkitAdapter_1_15.fieldTickingBlockCount.set(existingSection, (short) 0); DelegateLock lock = BukkitAdapter_1_16_1.applyLock(existingSection);
DelegateLock lock = BukkitAdapter_1_15.applyLock(existingSection);
synchronized (this) { synchronized (this) {
synchronized (lock) { synchronized (lock) {
lock.untilFree(); lock.untilFree();
@ -330,8 +311,10 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
} else if (lock.isModified()) { } else if (lock.isModified()) {
this.reset(layer); this.reset(layer);
} }
newSection = BukkitAdapter_1_15.newChunkSection(layer, this::load, setArr, fastmode); newSection = BukkitAdapter_1_16_1
if (!BukkitAdapter_1_15.setSectionAtomic(sections, existingSection, newSection, layer)) { .newChunkSection(layer, this::load, setArr, fastmode);
if (!BukkitAdapter_1_16_1
.setSectionAtomic(sections, existingSection, newSection, layer)) {
System.out.println("Failed to set chunk section:" + X + "," + Z + " layer: " + layer); System.out.println("Failed to set chunk section:" + X + "," + Z + " layer: " + layer);
continue; continue;
} else { } else {
@ -421,7 +404,8 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
final ListTag posTag = (ListTag) entityTagMap.get("Pos"); final ListTag posTag = (ListTag) entityTagMap.get("Pos");
final ListTag rotTag = (ListTag) entityTagMap.get("Rotation"); final ListTag rotTag = (ListTag) entityTagMap.get("Rotation");
if (idTag == null || posTag == null || rotTag == null) { if (idTag == null || posTag == null || rotTag == null) {
getLogger(BukkitGetBlocks_1_15.class).debug("Unknown entity tag: " + nativeTag); getLogger(
BukkitGetBlocks_1_16_1.class).debug("Unknown entity tag: " + nativeTag);
continue; continue;
} }
final double x = posTag.getDouble(0); final double x = posTag.getDouble(0);
@ -500,7 +484,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
nmsChunk.mustNotSave = false; nmsChunk.mustNotSave = false;
nmsChunk.markDirty(); nmsChunk.markDirty();
// send to player // send to player
BukkitAdapter_1_15.sendChunk(nmsWorld, X, Z, finalMask, finalLightUpdate); BukkitAdapter_1_16_1.sendChunk(nmsWorld, X, Z, finalMask, finalLightUpdate);
if (finalizer != null) finalizer.run(); if (finalizer != null) finalizer.run();
}; };
} }
@ -554,31 +538,27 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
if (data == null || data == FaweCache.IMP.EMPTY_CHAR_4096) { if (data == null || data == FaweCache.IMP.EMPTY_CHAR_4096) {
data = new char[4096]; data = new char[4096];
} }
DelegateLock lock = BukkitAdapter_1_15.applyLock(section); DelegateLock lock = BukkitAdapter_1_16_1.applyLock(section);
synchronized (lock) { synchronized (lock) {
lock.untilFree(); lock.untilFree();
lock.setModified(false); lock.setModified(false);
// Efficiently convert ChunkSection to raw data // Efficiently convert ChunkSection to raw data
try { try {
FAWE_Spigot_v1_15_R1 adapter = ((FAWE_Spigot_v1_15_R1) WorldEditPlugin.getInstance().getBukkitImplAdapter()); FAWE_Spigot_v1_16_R1 adapter = ((FAWE_Spigot_v1_16_R1) WorldEditPlugin.getInstance().getBukkitImplAdapter());
final DataPaletteBlock<IBlockData> blocks = section.getBlocks(); final DataPaletteBlock<IBlockData> blocks = section.getBlocks();
final DataBits bits = (DataBits) BukkitAdapter_1_15.fieldBits.get(blocks); final DataBits bits = (DataBits) BukkitAdapter_1_16_1.fieldBits.get(blocks);
final DataPalette<IBlockData> palette = (DataPalette<IBlockData>) BukkitAdapter_1_15.fieldPalette.get(blocks); final DataPalette<IBlockData> palette = (DataPalette<IBlockData>) BukkitAdapter_1_16_1.fieldPalette.get(blocks);
//getBits()
final int bitsPerEntry = bits.c(); final int bitsPerEntry = bits.c();
//getRaw()
final long[] blockStates = bits.a(); final long[] blockStates = bits.a();
new BitArray(bitsPerEntry, 4096, blockStates).toRaw(data); new BitArray(bitsPerEntry, 4096, blockStates).toRaw(data);
int num_palette; int num_palette;
if (palette instanceof DataPaletteLinear) { if (palette instanceof DataPaletteLinear) {
//Get the size of the palette
num_palette = ((DataPaletteLinear<IBlockData>) palette).b(); num_palette = ((DataPaletteLinear<IBlockData>) palette).b();
} else if (palette instanceof DataPaletteHash) { } else if (palette instanceof DataPaletteHash) {
//Get the size of the palette
num_palette = ((DataPaletteHash<IBlockData>) palette).b(); num_palette = ((DataPaletteHash<IBlockData>) palette).b();
} else { } else {
num_palette = 0; num_palette = 0;
@ -590,7 +570,6 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
char ordinal = paletteToBlockChars[paletteVal]; char ordinal = paletteToBlockChars[paletteVal];
if (ordinal == Character.MAX_VALUE) { if (ordinal == Character.MAX_VALUE) {
paletteToBlockInts[num_palette++] = paletteVal; paletteToBlockInts[num_palette++] = paletteVal;
//palette.a(Object) is palette.idFor(Object)
IBlockData ibd = palette.a(data[i]); IBlockData ibd = palette.a(data[i]);
if (ibd == null) { if (ibd == null) {
ordinal = BlockTypes.AIR.getDefaultState().getOrdinalChar(); ordinal = BlockTypes.AIR.getDefaultState().getOrdinalChar();
@ -614,7 +593,6 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
try { try {
if (num_palette != 1) { if (num_palette != 1) {
for (int i = 0; i < num_palette; i++) { for (int i = 0; i < num_palette; i++) {
//palette.a(Object) is palette.idFor(Object)
char ordinal = ordinal(palette.a(i), adapter); char ordinal = ordinal(palette.a(i), adapter);
paletteToOrdinal[i] = ordinal; paletteToOrdinal[i] = ordinal;
} }
@ -644,7 +622,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
} }
} }
private final char ordinal(IBlockData ibd, FAWE_Spigot_v1_15_R1 adapter) { private final char ordinal(IBlockData ibd, FAWE_Spigot_v1_16_R1 adapter) {
if (ibd == null) { if (ibd == null) {
return BlockTypes.AIR.getDefaultState().getOrdinalChar(); return BlockTypes.AIR.getDefaultState().getOrdinalChar();
} else { } else {
@ -705,6 +683,8 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
@Override @Override
public boolean trim(boolean aggressive) { public boolean trim(boolean aggressive) {
skyLight = new NibbleArray[16];
blockLight = new NibbleArray[16];
if (aggressive) { if (aggressive) {
sections = null; sections = null;
nmsChunk = null; nmsChunk = null;
@ -718,7 +698,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
try { try {
final DataPaletteBlock<IBlockData> blocksExisting = existing.getBlocks(); final DataPaletteBlock<IBlockData> blocksExisting = existing.getBlocks();
final DataPalette<IBlockData> palette = (DataPalette<IBlockData>) BukkitAdapter_1_15.fieldPalette.get(blocksExisting); final DataPalette<IBlockData> palette = (DataPalette<IBlockData>) BukkitAdapter_1_16_1.fieldPalette.get(blocksExisting);
int paletteSize; int paletteSize;
if (palette instanceof DataPaletteLinear) { if (palette instanceof DataPaletteLinear) {

Datei anzeigen

@ -1,17 +1,17 @@
package com.boydti.fawe.bukkit.adapter.mc1_15; package com.boydti.fawe.bukkit.adapter.mc1_16_1;
import com.boydti.fawe.bukkit.adapter.MapChunkUtil; import com.boydti.fawe.bukkit.adapter.MapChunkUtil;
import net.minecraft.server.v1_15_R1.PacketPlayOutMapChunk; import net.minecraft.server.v1_16_R1.PacketPlayOutMapChunk;
public class MapChunkUtil_1_15 extends MapChunkUtil<PacketPlayOutMapChunk> { public class MapChunkUtil_1_16_1 extends MapChunkUtil<PacketPlayOutMapChunk> {
public MapChunkUtil_1_15() throws NoSuchFieldException { public MapChunkUtil_1_16_1() throws NoSuchFieldException {
fieldX = PacketPlayOutMapChunk.class.getDeclaredField("a"); fieldX = PacketPlayOutMapChunk.class.getDeclaredField("a");
fieldZ = PacketPlayOutMapChunk.class.getDeclaredField("b"); fieldZ = PacketPlayOutMapChunk.class.getDeclaredField("b");
fieldBitMask = PacketPlayOutMapChunk.class.getDeclaredField("c"); fieldBitMask = PacketPlayOutMapChunk.class.getDeclaredField("c");
fieldHeightMap = PacketPlayOutMapChunk.class.getDeclaredField("d"); fieldHeightMap = PacketPlayOutMapChunk.class.getDeclaredField("d");
fieldChunkData = PacketPlayOutMapChunk.class.getDeclaredField("e"); fieldChunkData = PacketPlayOutMapChunk.class.getDeclaredField("f");
fieldBlockEntities = PacketPlayOutMapChunk.class.getDeclaredField("f"); fieldBlockEntities = PacketPlayOutMapChunk.class.getDeclaredField("g");
fieldFull = PacketPlayOutMapChunk.class.getDeclaredField("g"); fieldFull = PacketPlayOutMapChunk.class.getDeclaredField("h");
fieldX.setAccessible(true); fieldX.setAccessible(true);
fieldZ.setAccessible(true); fieldZ.setAccessible(true);
fieldBitMask.setAccessible(true); fieldBitMask.setAccessible(true);

Datei anzeigen

@ -1,14 +1,14 @@
package com.boydti.fawe.bukkit.adapter.mc1_15.nbt; package com.boydti.fawe.bukkit.adapter.mc1_16_1.nbt;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.ListTag; import com.sk89q.jnbt.ListTag;
import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import net.minecraft.server.v1_15_R1.NBTBase; import net.minecraft.server.v1_16_R1.NBTBase;
import net.minecraft.server.v1_15_R1.NBTNumber; import net.minecraft.server.v1_16_R1.NBTNumber;
import net.minecraft.server.v1_15_R1.NBTTagCompound; import net.minecraft.server.v1_16_R1.NBTTagCompound;
import net.minecraft.server.v1_15_R1.NBTTagList; import net.minecraft.server.v1_16_R1.NBTTagList;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -16,15 +16,15 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Supplier; import java.util.function.Supplier;
public class LazyCompoundTag_1_15 extends CompoundTag { public class LazyCompoundTag_1_16_1 extends CompoundTag {
private final Supplier<NBTTagCompound> nmsTag; private final Supplier<NBTTagCompound> nmsTag;
public LazyCompoundTag_1_15(Supplier<NBTTagCompound> tag) { public LazyCompoundTag_1_16_1(Supplier<NBTTagCompound> tag) {
super(null); super(null);
this.nmsTag = tag; this.nmsTag = tag;
} }
public LazyCompoundTag_1_15(NBTTagCompound tag) { public LazyCompoundTag_1_16_1(NBTTagCompound tag) {
this(() -> tag); this(() -> tag);
} }
@ -93,7 +93,7 @@ public class LazyCompoundTag_1_15 extends CompoundTag {
NBTTagList nbtList = (NBTTagList) tag; NBTTagList nbtList = (NBTTagList) tag;
for (NBTBase elem : nbtList) { for (NBTBase elem : nbtList) {
if (elem instanceof NBTTagCompound) { if (elem instanceof NBTTagCompound) {
list.add(new LazyCompoundTag_1_15((NBTTagCompound) elem)); list.add(new LazyCompoundTag_1_16_1((NBTTagCompound) elem));
} else { } else {
list.add(WorldEditPlugin.getInstance().getBukkitImplAdapter().toNative(elem)); list.add(WorldEditPlugin.getInstance().getBukkitImplAdapter().toNative(elem));
} }

Datei anzeigen

@ -33,7 +33,6 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.adapter.AdapterLoadException; import com.sk89q.worldedit.bukkit.adapter.AdapterLoadException;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplLoader; import com.sk89q.worldedit.bukkit.adapter.BukkitImplLoader;
import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_15_R1;
import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_15_R2; import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_15_R2;
import com.sk89q.worldedit.event.platform.CommandEvent; import com.sk89q.worldedit.event.platform.CommandEvent;
import com.sk89q.worldedit.event.platform.CommandSuggestionEvent; import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
@ -371,7 +370,6 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
BukkitImplLoader adapterLoader = new BukkitImplLoader(); BukkitImplLoader adapterLoader = new BukkitImplLoader();
try { try {
adapterLoader.addClass(FAWE_Spigot_v1_14_R4.class); adapterLoader.addClass(FAWE_Spigot_v1_14_R4.class);
adapterLoader.addClass(FAWE_Spigot_v1_15_R1.class);
adapterLoader.addClass(FAWE_Spigot_v1_15_R2.class); adapterLoader.addClass(FAWE_Spigot_v1_15_R2.class);
} catch (Throwable throwable) { } catch (Throwable throwable) {
throwable.printStackTrace(); throwable.printStackTrace();

Datei anzeigen

@ -26,11 +26,8 @@ import com.boydti.fawe.beta.IQueueChunk;
import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.beta.implementation.packet.ChunkPacket; import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
import com.boydti.fawe.beta.implementation.queue.SingleThreadQueueExtent; import com.boydti.fawe.beta.implementation.queue.SingleThreadQueueExtent;
import com.boydti.fawe.bukkit.adapter.mc1_15.BlockMaterial_1_15; import com.boydti.fawe.bukkit.adapter.mc1_16_1.BlockMaterial_1_16_1;
import com.boydti.fawe.bukkit.adapter.mc1_15.BukkitAdapter_1_15; import com.boydti.fawe.bukkit.adapter.mc1_16_1.nbt.LazyCompoundTag_1_16_1;
import com.boydti.fawe.bukkit.adapter.mc1_15.BukkitGetBlocks_1_15;
import com.boydti.fawe.bukkit.adapter.mc1_15.MapChunkUtil_1_15;
import com.boydti.fawe.bukkit.adapter.mc1_15.nbt.LazyCompoundTag_1_15;
import com.google.common.io.Files; import com.google.common.io.Files;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
@ -48,7 +45,6 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.*; import com.sk89q.worldedit.world.block.*;
import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.entity.EntityType;
@ -81,16 +77,16 @@ import java.util.stream.Stream;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements IDelegateBukkitImplAdapter<NBTBase> { public final class FAWE_Spigot_v1_16_R1 extends CachedBukkitAdapter implements IDelegateBukkitImplAdapter<NBTBase> {
private final Spigot_v1_15_R1 parent; private final Spigot_v1_16_R1 parent;
private char[] ibdToStateOrdinal; private char[] ibdToStateOrdinal;
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// Code that may break between versions of Minecraft // Code that may break between versions of Minecraft
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
public FAWE_Spigot_v1_15_R1() throws NoSuchFieldException, NoSuchMethodException { public FAWE_Spigot_v1_16_R1() throws NoSuchFieldException, NoSuchMethodException {
this.parent = new Spigot_v1_15_R1(); this.parent = new Spigot_v1_16_R1();
} }
@Override @Override
@ -99,11 +95,11 @@ public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements I
} }
private synchronized boolean init() { private synchronized boolean init() {
if (ibdToStateOrdinal != null) return false; if (ibdToStateOrdinal != null && ibdToStateOrdinal[1] != 0) return false;
ibdToStateOrdinal = new char[Block.REGISTRY_ID.a()]; // size ibdToStateOrdinal = new char[Block.REGISTRY_ID.a()]; // size
for (int i = 0; i < ibdToStateOrdinal.length; i++) { for (int i = 0; i < ibdToStateOrdinal.length; i++) {
BlockState state = BlockTypesCache.states[i]; BlockState state = BlockTypesCache.states[i];
BlockMaterial_1_15 material = (BlockMaterial_1_15) state.getMaterial(); BlockMaterial_1_16_1 material = (BlockMaterial_1_16_1) state.getMaterial();
int id = Block.REGISTRY_ID.getId(material.getState()); int id = Block.REGISTRY_ID.getId(material.getState());
ibdToStateOrdinal[id] = state.getOrdinalChar(); ibdToStateOrdinal[id] = state.getOrdinalChar();
} }
@ -113,13 +109,15 @@ public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements I
@Override @Override
public BlockMaterial getMaterial(BlockType blockType) { public BlockMaterial getMaterial(BlockType blockType) {
Block block = getBlock(blockType); Block block = getBlock(blockType);
return new BlockMaterial_1_15(block); return new BlockMaterial_1_16_1(block);
} }
@Override @Override
public BlockMaterial getMaterial(BlockState state) { public BlockMaterial getMaterial(BlockState state) {
IBlockData bs = ((CraftBlockData) Bukkit.createBlockData(state.getAsString())).getState(); IBlockData bs = ((CraftBlockData) Bukkit.createBlockData(state.getAsString())).getState();
return new BlockMaterial_1_15(bs.getBlock(), bs); return new BlockMaterial_1_16_1(bs.getBlock(), bs);
} }
public Block getBlock(BlockType blockType) { public Block getBlock(BlockType blockType) {
@ -166,14 +164,14 @@ public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements I
World nmsWorld = nmsChunk.getWorld(); World nmsWorld = nmsChunk.getWorld();
BlockPosition blockPos = new BlockPosition(x, y, z); BlockPosition blockPos = new BlockPosition(x, y, z);
IBlockData blockData = ((BlockMaterial_1_15) state.getMaterial()).getState(); IBlockData blockData = ((BlockMaterial_1_16_1) state.getMaterial()).getState();
ChunkSection[] sections = nmsChunk.getSections(); ChunkSection[] sections = nmsChunk.getSections();
int y4 = y >> 4; int y4 = y >> 4;
ChunkSection section = sections[y4]; ChunkSection section = sections[y4];
IBlockData existing; IBlockData existing;
if (section == null) { if (section == null) {
existing = ((BlockMaterial_1_15) BlockTypes.AIR.getDefaultState().getMaterial()).getState(); existing = ((BlockMaterial_1_16_1) BlockTypes.AIR.getDefaultState().getMaterial()).getState();
} else { } else {
existing = section.getType(x & 15, y & 15, z & 15); existing = section.getType(x & 15, y & 15, z & 15);
} }
@ -245,7 +243,7 @@ public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements I
@Override @Override
public OptionalInt getInternalBlockStateId(BlockState state) { public OptionalInt getInternalBlockStateId(BlockState state) {
BlockMaterial_1_15 material = (BlockMaterial_1_15) state.getMaterial(); BlockMaterial_1_16_1 material = (BlockMaterial_1_16_1) state.getMaterial();
IBlockData mcState = material.getCraftBlockData().getState(); IBlockData mcState = material.getCraftBlockData().getState();
return OptionalInt.of(Block.REGISTRY_ID.getId(mcState)); return OptionalInt.of(Block.REGISTRY_ID.getId(mcState));
} }
@ -286,7 +284,7 @@ public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements I
} catch (NullPointerException e) { } catch (NullPointerException e) {
init(); init();
return adaptToChar(ibd); return adaptToChar(ibd);
} catch (ArrayIndexOutOfBoundsException e1) { } catch(ArrayIndexOutOfBoundsException e1){
Fawe.debug("Attempted to convert " + ibd.getBlock() + " with ID " + Block.REGISTRY_ID.getId(ibd) + " to char. ibdToStateOrdinal length: " + ibdToStateOrdinal.length + ". Defaulting to air!"); Fawe.debug("Attempted to convert " + ibd.getBlock() + " with ID " + Block.REGISTRY_ID.getId(ibd) + " to char. ibdToStateOrdinal length: " + ibdToStateOrdinal.length + ". Defaulting to air!");
return 0; return 0;
} }
@ -295,7 +293,7 @@ public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements I
@Override @Override
public <B extends BlockStateHolder<B>> BlockData adapt(B state) { public <B extends BlockStateHolder<B>> BlockData adapt(B state) {
BlockMaterial_1_15 material = (BlockMaterial_1_15) state.getMaterial(); BlockMaterial_1_16_1 material = (BlockMaterial_1_16_1) state.getMaterial();
return material.getCraftBlockData(); return material.getCraftBlockData();
} }
@ -304,12 +302,12 @@ public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements I
this.setBlock(position.getChunk(), position.getBlockX(), position.getBlockY(), position.getBlockZ(), previousType, true); this.setBlock(position.getChunk(), position.getBlockX(), position.getBlockY(), position.getBlockZ(), previousType, true);
} }
private MapChunkUtil_1_15 mapUtil = new MapChunkUtil_1_15(); private MapChunkUtil_1_16_1 mapUtil = new MapChunkUtil_1_16_1();
@Override @Override
public void sendFakeChunk(org.bukkit.World world, Player player, ChunkPacket packet) { public void sendFakeChunk(org.bukkit.World world, Player player, ChunkPacket packet) {
WorldServer nmsWorld = ((CraftWorld) world).getHandle(); WorldServer nmsWorld = ((CraftWorld) world).getHandle();
PlayerChunk map = BukkitAdapter_1_15.getPlayerChunk(nmsWorld, packet.getChunkX(), packet.getChunkZ()); PlayerChunk map = BukkitAdapter_1_16_1.getPlayerChunk(nmsWorld, packet.getChunkX(), packet.getChunkZ());
if (map != null && map.hasBeenLoaded()) { if (map != null && map.hasBeenLoaded()) {
boolean flag = false; boolean flag = false;
PlayerChunk.d players = map.players; PlayerChunk.d players = map.players;
@ -362,8 +360,8 @@ public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements I
@Override @Override
public NBTBase fromNative(Tag foreign) { public NBTBase fromNative(Tag foreign) {
if (foreign instanceof LazyCompoundTag_1_15) { if (foreign instanceof LazyCompoundTag_1_16_1) {
return ((LazyCompoundTag_1_15) foreign).get(); return ((LazyCompoundTag_1_16_1) foreign).get();
} }
return parent.fromNative(foreign); return parent.fromNative(foreign);
} }
@ -399,7 +397,7 @@ public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements I
env, env,
gen){ gen){
@Override @Override
public boolean addEntityChunk(net.minecraft.server.v1_15_R1.Entity entity) { public boolean addEntityChunk(Entity entity) {
//Fixes #320; Prevent adding entities so we aren't attempting to spawn them asynchronously //Fixes #320; Prevent adding entities so we aren't attempting to spawn them asynchronously
return false; return false;
} }
@ -410,7 +408,7 @@ public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements I
Fawe.get().getQueueHandler().startSet(true); Fawe.get().getQueueHandler().startSet(true);
try { try {
IQueueExtent<IQueueChunk> extent = new SingleThreadQueueExtent(); IQueueExtent<IQueueChunk> extent = new SingleThreadQueueExtent();
extent.init(null, (x, z) -> new BukkitGetBlocks_1_15(freshWorld, x, z) { extent.init(null, (x, z) -> new BukkitGetBlocks_1_16_1(freshWorld, x, z) {
@Override @Override
public Chunk ensureLoaded(World nmsWorld, int X, int Z) { public Chunk ensureLoaded(World nmsWorld, int X, int Z) {
Chunk cached = nmsWorld.getChunkIfLoaded(X, Z); Chunk cached = nmsWorld.getChunkIfLoaded(X, Z);
@ -446,7 +444,7 @@ public final class FAWE_Spigot_v1_15_R1 extends CachedBukkitAdapter implements I
@Override @Override
public IChunkGet get(org.bukkit.World world, int chunkX, int chunkZ) { public IChunkGet get(org.bukkit.World world, int chunkX, int chunkZ) {
return new BukkitGetBlocks_1_15(world, chunkX, chunkZ); return new BukkitGetBlocks_1_16_1(world, chunkX, chunkZ);
} }
@Override @Override

Datei anzeigen

@ -31,7 +31,8 @@ public class CopyPastaBrush implements Brush, ResettableTool {
private final LocalSession session; private final LocalSession session;
private final Player player; private final Player player;
public boolean autoRotate, randomRotate; public boolean autoRotate;
public boolean randomRotate;
public CopyPastaBrush(Player player, LocalSession session, boolean randomRotate, boolean autoRotate) { public CopyPastaBrush(Player player, LocalSession session, boolean randomRotate, boolean autoRotate) {
session.setClipboard(null); session.setClipboard(null);