- My IJ is broke but this should work. Dunno if I got all nms changes, but we will see.
This commit is contained in:
N0tMyFaultOG
2020-08-23 17:18:29 +02:00
parent 1e070b3a71
commit 6cb8352686
31 changed files with 226 additions and 122 deletions

View File

@ -35,7 +35,7 @@ import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplLoader;
import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_14_R4;
import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_15_R2;
import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_16_R1;
import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_16_R2;
import com.sk89q.worldedit.event.platform.CommandEvent;
import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
@ -391,7 +391,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
try {
adapterLoader.addClass(FAWE_Spigot_v1_14_R4.class);
adapterLoader.addClass(FAWE_Spigot_v1_15_R2.class);
adapterLoader.addClass(FAWE_Spigot_v1_16_R1.class);
adapterLoader.addClass(FAWE_Spigot_v1_16_R2.class);
} catch (Throwable throwable) {
throwable.printStackTrace();
}

View File

@ -23,8 +23,8 @@ import com.boydti.fawe.Fawe;
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_1.*;
import com.boydti.fawe.bukkit.adapter.mc1_16_1.nbt.LazyCompoundTag_1_16_1;
import com.boydti.fawe.bukkit.adapter.mc1_16_2.*;
import com.boydti.fawe.bukkit.adapter.mc1_16_2.nbt.LazyCompoundTag_1_16_2;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.EditSession;
@ -46,17 +46,17 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.*;
import com.sk89q.worldedit.world.entity.EntityType;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import net.minecraft.server.v1_16_R1.*;
import net.minecraft.server.v1_16_R2.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.v1_16_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_16_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_16_R1.block.CraftBlock;
import org.bukkit.craftbukkit.v1_16_R1.block.data.CraftBlockData;
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_16_R2.CraftChunk;
import org.bukkit.craftbukkit.v1_16_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_16_R2.block.CraftBlock;
import org.bukkit.craftbukkit.v1_16_R2.block.data.CraftBlockData;
import org.bukkit.craftbukkit.v1_16_R2.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import javax.annotation.Nullable;
@ -70,16 +70,16 @@ import java.util.stream.Stream;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.jnbt.StringTag;
public final class FAWE_Spigot_v1_16_R1 extends CachedBukkitAdapter implements IDelegateBukkitImplAdapter<NBTBase> {
private final Spigot_v1_16_R1 parent;
public final class FAWE_Spigot_v1_16_R2 extends CachedBukkitAdapter implements IDelegateBukkitImplAdapter<NBTBase> {
private final Spigot_v1_16_R2 parent;
private char[] ibdToStateOrdinal;
// ------------------------------------------------------------------------
// Code that may break between versions of Minecraft
// ------------------------------------------------------------------------
public FAWE_Spigot_v1_16_R1() throws NoSuchFieldException, NoSuchMethodException {
this.parent = new Spigot_v1_16_R1();
public FAWE_Spigot_v1_16_R2() throws NoSuchFieldException, NoSuchMethodException {
this.parent = new Spigot_v1_16_R2();
}
@Override
@ -92,7 +92,7 @@ public final class FAWE_Spigot_v1_16_R1 extends CachedBukkitAdapter implements I
ibdToStateOrdinal = new char[Block.REGISTRY_ID.a()]; // size
for (int i = 0; i < ibdToStateOrdinal.length; i++) {
BlockState state = BlockTypesCache.states[i];
BlockMaterial_1_16_1 material = (BlockMaterial_1_16_1) state.getMaterial();
BlockMaterial_1_16_2 material = (BlockMaterial_1_16_2) state.getMaterial();
int id = Block.REGISTRY_ID.getId(material.getState());
ibdToStateOrdinal[id] = state.getOrdinalChar();
}
@ -102,13 +102,13 @@ public final class FAWE_Spigot_v1_16_R1 extends CachedBukkitAdapter implements I
@Override
public BlockMaterial getMaterial(BlockType blockType) {
Block block = getBlock(blockType);
return new BlockMaterial_1_16_1(block);
return new BlockMaterial_1_16_2(block);
}
@Override
public BlockMaterial getMaterial(BlockState state) {
IBlockData bs = ((CraftBlockData) Bukkit.createBlockData(state.getAsString())).getState();
return new BlockMaterial_1_16_1(bs.getBlock(), bs);
return new BlockMaterial_1_16_2(bs.getBlock(), bs);
}
@ -157,14 +157,14 @@ public final class FAWE_Spigot_v1_16_R1 extends CachedBukkitAdapter implements I
World nmsWorld = nmsChunk.getWorld();
BlockPosition blockPos = new BlockPosition(x, y, z);
IBlockData blockData = ((BlockMaterial_1_16_1) state.getMaterial()).getState();
IBlockData blockData = ((BlockMaterial_1_16_2) state.getMaterial()).getState();
ChunkSection[] sections = nmsChunk.getSections();
int y4 = y >> 4;
ChunkSection section = sections[y4];
IBlockData existing;
if (section == null) {
existing = ((BlockMaterial_1_16_1) BlockTypes.AIR.getDefaultState().getMaterial()).getState();
existing = ((BlockMaterial_1_16_2) BlockTypes.AIR.getDefaultState().getMaterial()).getState();
} else {
existing = section.getType(x & 15, y & 15, z & 15);
}
@ -246,7 +246,7 @@ public final class FAWE_Spigot_v1_16_R1 extends CachedBukkitAdapter implements I
@Override
public OptionalInt getInternalBlockStateId(BlockState state) {
BlockMaterial_1_16_1 material = (BlockMaterial_1_16_1) state.getMaterial();
BlockMaterial_1_16_2 material = (BlockMaterial_1_16_2) state.getMaterial();
IBlockData mcState = material.getCraftBlockData().getState();
return OptionalInt.of(Block.REGISTRY_ID.getId(mcState));
}
@ -296,16 +296,16 @@ public final class FAWE_Spigot_v1_16_R1 extends CachedBukkitAdapter implements I
@Override
public <B extends BlockStateHolder<B>> BlockData adapt(B state) {
BlockMaterial_1_16_1 material = (BlockMaterial_1_16_1) state.getMaterial();
BlockMaterial_1_16_2 material = (BlockMaterial_1_16_2) state.getMaterial();
return material.getCraftBlockData();
}
private MapChunkUtil_1_16_1 mapUtil = new MapChunkUtil_1_16_1();
private MapChunkUtil_1_16_2 mapUtil = new MapChunkUtil_1_16_2();
@Override
public void sendFakeChunk(org.bukkit.World world, Player player, ChunkPacket packet) {
WorldServer nmsWorld = ((CraftWorld) world).getHandle();
PlayerChunk map = BukkitAdapter_1_16_1.getPlayerChunk(nmsWorld, packet.getChunkX(), packet.getChunkZ());
PlayerChunk map = BukkitAdapter_1_16_2.getPlayerChunk(nmsWorld, packet.getChunkX(), packet.getChunkZ());
if (map != null && map.hasBeenLoaded()) {
boolean flag = false;
PlayerChunk.d players = map.players;
@ -358,8 +358,8 @@ public final class FAWE_Spigot_v1_16_R1 extends CachedBukkitAdapter implements I
@Override
public NBTBase fromNative(Tag foreign) {
if (foreign instanceof LazyCompoundTag_1_16_1) {
return ((LazyCompoundTag_1_16_1) foreign).get();
if (foreign instanceof LazyCompoundTag_1_16_2) {
return ((LazyCompoundTag_1_16_2) foreign).get();
}
return parent.fromNative(foreign);
}
@ -406,7 +406,7 @@ public final class FAWE_Spigot_v1_16_R1 extends CachedBukkitAdapter implements I
// Fawe.get().getQueueHandler().startSet(true);
// try {
// IQueueExtent<IQueueChunk> extent = new SingleThreadQueueExtent();
// extent.init(null, (x, z) -> new BukkitGetBlocks_1_16_1(freshWorld, x, z) {
// extent.init(null, (x, z) -> new BukkitGetBlocks_1_16_2(freshWorld, x, z) {
// @Override
// public Chunk ensureLoaded(World nmsWorld, int X, int Z) {
// Chunk cached = nmsWorld.getChunkIfLoaded(X, Z);
@ -444,7 +444,7 @@ public final class FAWE_Spigot_v1_16_R1 extends CachedBukkitAdapter implements I
@Override
public IChunkGet get(org.bukkit.World world, int chunkX, int chunkZ) {
return new BukkitGetBlocks_1_16_1(world, chunkX, chunkZ);
return new BukkitGetBlocks_1_16_2(world, chunkX, chunkZ);
}
@Override