From be73d2935498b199f5d169739151893f9baab559 Mon Sep 17 00:00:00 2001 From: IronApollo Date: Wed, 24 Oct 2018 18:25:50 -0400 Subject: [PATCH] 1.13.2 setType adaptation --- .../bukkit/adapter/v1_13_1/Spigot_v1_13_R2.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/Spigot_v1_13_R2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/Spigot_v1_13_R2.java index 10eda3100..22df9a2c1 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/Spigot_v1_13_R2.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/v1_13_1/Spigot_v1_13_R2.java @@ -53,6 +53,7 @@ import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import javax.annotation.Nullable; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.*; import java.util.function.Consumer; @@ -68,6 +69,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit private final Field nbtListTagListField; private final Method nbtCreateTagMethod; + private Method chunkSetTypeMethod; static { // A simple test @@ -86,6 +88,13 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit // The method to create an NBTBase tag given its type ID nbtCreateTagMethod = NBTBase.class.getDeclaredMethod("createTag", byte.class); nbtCreateTagMethod.setAccessible(true); + + // 1.13.2 Adaptation to find the a/setType method + try { + chunkSetTypeMethod = Chunk.class.getMethod("setType", BlockPosition.class, IBlockData.class, boolean.class); + }catch(NoSuchMethodException e) { + chunkSetTypeMethod = Chunk.class.getMethod("a", BlockPosition.class, IBlockData.class, boolean.class); + } } private int[] idbToStateOrdinal; @@ -276,7 +285,12 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit sections[y4] = section = new ChunkSection(y4 << 4, nmsWorld.worldProvider.g()); } if (existing.e() != blockData.e() || existing.getMaterial().f() != blockData.getMaterial().f()) { - nmsChunk.a(pos = new BlockPosition(x, y, z), blockData, false); + try { + chunkSetTypeMethod.invoke(pos = new BlockPosition(x, y, z), blockData, false); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + logger.warning("Error when setting block!"); + e.printStackTrace(); + } } else { section.setType(x & 15, y & 15, z & 15, blockData); }