From c7a490fa03a2d49e891cd21ac739e96e35b8b22a Mon Sep 17 00:00:00 2001 From: Pierre Maurice Schwang Date: Mon, 18 Oct 2021 21:38:43 +0200 Subject: [PATCH] Fix paperweight changes (#1364) --- gradle.properties | 4 -- .../fawe}/PaperweightAdapter.java | 2 +- .../fawe}/PaperweightDataConverters.java | 2 +- .../fawe}/PaperweightFakePlayer.java | 2 +- .../fawe}/PaperweightWorldNativeAccess.java | 2 +- .../v1_17_R1_2}/PaperweightBlockMaterial.java | 12 ++++-- .../v1_17_R1_2}/PaperweightFaweAdapter.java | 11 +++--- .../PaperweightFaweWorldNativeAccess.java | 2 +- .../v1_17_R1_2}/PaperweightGetBlocks.java | 4 +- .../PaperweightGetBlocks_Copy.java | 4 +- .../v1_17_R1_2}/PaperweightMapChunkUtil.java | 17 +++++---- .../PaperweightPlatformAdapter.java | 38 ++++++++++++------- .../PaperweightStarlightRelighter.java | 2 +- .../PaperweightStarlightRelighterFactory.java | 2 +- .../nbt/PaperweightLazyCompoundTag.java | 2 +- .../v1_17_R1_2}/regen/PaperweightRegen.java | 18 ++++++--- .../core/util/ReflectionUtils.java | 23 +++++++++++ 17 files changed, 94 insertions(+), 53 deletions(-) rename worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/{impl/v1_17_R1_2 => ext/fawe}/PaperweightAdapter.java (99%) rename worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/{impl/v1_17_R1_2 => ext/fawe}/PaperweightDataConverters.java (99%) rename worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/{impl/v1_17_R1_2 => ext/fawe}/PaperweightFakePlayer.java (97%) rename worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/{impl/v1_17_R1_2 => ext/fawe}/PaperweightWorldNativeAccess.java (99%) rename worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/{v1_17_R1_2/fawe => fawe/v1_17_R1_2}/PaperweightBlockMaterial.java (92%) rename worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/{v1_17_R1_2/fawe => fawe/v1_17_R1_2}/PaperweightFaweAdapter.java (98%) rename worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/{v1_17_R1_2/fawe => fawe/v1_17_R1_2}/PaperweightFaweWorldNativeAccess.java (99%) rename worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/{v1_17_R1_2/fawe => fawe/v1_17_R1_2}/PaperweightGetBlocks.java (99%) rename worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/{v1_17_R1_2/fawe => fawe/v1_17_R1_2}/PaperweightGetBlocks_Copy.java (98%) rename worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/{v1_17_R1_2/fawe => fawe/v1_17_R1_2}/PaperweightMapChunkUtil.java (72%) rename worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/{v1_17_R1_2/fawe => fawe/v1_17_R1_2}/PaperweightPlatformAdapter.java (94%) rename worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/{v1_17_R1_2/fawe => fawe/v1_17_R1_2}/PaperweightStarlightRelighter.java (99%) rename worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/{v1_17_R1_2/fawe => fawe/v1_17_R1_2}/PaperweightStarlightRelighterFactory.java (94%) rename worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/{v1_17_R1_2/fawe => fawe/v1_17_R1_2}/nbt/PaperweightLazyCompoundTag.java (98%) rename worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/{v1_17_R1_2/fawe => fawe/v1_17_R1_2}/regen/PaperweightRegen.java (97%) diff --git a/gradle.properties b/gradle.properties index 38b892464..56bf5783f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,11 +1,7 @@ group=com.fastasyncworldedit org.gradle.jvmargs=-Xmx1512M -org.gradle.daemon=true -org.gradle.configureondemand=true org.gradle.parallel=true -org.gradle.caching=true -org.gradle.vfs.watch=true loom.version=0.5.43 mixin.version=0.8.1+build.21 diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/PaperweightAdapter.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/PaperweightAdapter.java similarity index 99% rename from worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/PaperweightAdapter.java rename to worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/PaperweightAdapter.java index 9d2c53368..6b1f0635a 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/PaperweightAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/PaperweightAdapter.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.bukkit.adapter.impl.v1_17_R1_2; +package com.sk89q.worldedit.bukkit.adapter.ext.fawe; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/PaperweightDataConverters.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/PaperweightDataConverters.java similarity index 99% rename from worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/PaperweightDataConverters.java rename to worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/PaperweightDataConverters.java index e2b4fac88..195187267 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/PaperweightDataConverters.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/PaperweightDataConverters.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.bukkit.adapter.impl.v1_17_R1_2; +package com.sk89q.worldedit.bukkit.adapter.ext.fawe; import com.google.common.collect.Lists; import com.google.common.collect.Maps; diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/PaperweightFakePlayer.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/PaperweightFakePlayer.java similarity index 97% rename from worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/PaperweightFakePlayer.java rename to worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/PaperweightFakePlayer.java index 3402def33..1c2bc02a4 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/PaperweightFakePlayer.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/PaperweightFakePlayer.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.bukkit.adapter.impl.v1_17_R1_2; +package com.sk89q.worldedit.bukkit.adapter.ext.fawe; import com.mojang.authlib.GameProfile; import net.minecraft.network.chat.ChatType; diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/PaperweightWorldNativeAccess.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/PaperweightWorldNativeAccess.java similarity index 99% rename from worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/PaperweightWorldNativeAccess.java rename to worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/PaperweightWorldNativeAccess.java index c9b310881..bf4af5863 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/PaperweightWorldNativeAccess.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/PaperweightWorldNativeAccess.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package com.sk89q.worldedit.bukkit.adapter.impl.v1_17_R1_2; +package com.sk89q.worldedit.bukkit.adapter.ext.fawe; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.internal.block.BlockStateIdAccess; diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightBlockMaterial.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightBlockMaterial.java similarity index 92% rename from worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightBlockMaterial.java rename to worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightBlockMaterial.java index b81512b7c..aac664459 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightBlockMaterial.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightBlockMaterial.java @@ -1,9 +1,10 @@ -package com.sk89q.worldedit.bukkit.adapter.impl.v1_17_R1_2.fawe; +package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2; import com.google.common.base.Suppliers; import com.sk89q.jnbt.CompoundTag; import com.sk89q.util.ReflectionUtil; -import com.sk89q.worldedit.bukkit.adapter.impl.v1_17_R1_2.fawe.nbt.PaperweightLazyCompoundTag; +import com.sk89q.worldedit.bukkit.adapter.Refraction; +import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2.nbt.PaperweightLazyCompoundTag; import com.sk89q.worldedit.world.registry.BlockMaterial; import net.minecraft.core.BlockPos; import net.minecraft.world.level.EmptyBlockGetter; @@ -37,8 +38,11 @@ public class PaperweightBlockMaterial implements BlockMaterial { this.material = blockState.getMaterial(); this.craftBlockData = CraftBlockData.fromData(blockState); this.craftMaterial = craftBlockData.getMaterial(); - BlockBehaviour.Properties blockInfo = ReflectionUtil.getField(BlockBehaviour.class, block, "properties"); - this.isTranslucent = !(boolean) ReflectionUtil.getField(BlockBehaviour.Properties.class, blockInfo, "canOcclude"); + BlockBehaviour.Properties blockInfo = ReflectionUtil.getField(BlockBehaviour.class, block, Refraction.pickName( + "properties", "aP")); + this.isTranslucent = !(boolean) ReflectionUtil.getField(BlockBehaviour.Properties.class, blockInfo, + Refraction.pickName("canOcclude", "n") + ); opacity = blockState.getLightBlock(EmptyBlockGetter.INSTANCE, BlockPos.ZERO); BlockEntity tileEntity = !(block instanceof EntityBlock) ? null : ((EntityBlock) block).newBlockEntity( BlockPos.ZERO, diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightFaweAdapter.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweAdapter.java similarity index 98% rename from worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightFaweAdapter.java rename to worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweAdapter.java index 0487cdebc..6f64ff6d3 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightFaweAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweAdapter.java @@ -1,4 +1,4 @@ -package com.sk89q.worldedit.bukkit.adapter.impl.v1_17_R1_2.fawe; +package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2; import com.fastasyncworldedit.bukkit.adapter.CachedBukkitAdapter; import com.fastasyncworldedit.bukkit.adapter.IDelegateBukkitImplAdapter; @@ -20,8 +20,9 @@ import com.sk89q.worldedit.blocks.TileEntityBlock; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; -import com.sk89q.worldedit.bukkit.adapter.impl.v1_17_R1_2.fawe.nbt.PaperweightLazyCompoundTag; -import com.sk89q.worldedit.bukkit.adapter.impl.v1_17_R1_2.fawe.regen.PaperweightRegen; +import com.sk89q.worldedit.bukkit.adapter.ext.fawe.PaperweightAdapter; +import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2.nbt.PaperweightLazyCompoundTag; +import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2.regen.PaperweightRegen; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.internal.block.BlockStateIdAccess; @@ -110,7 +111,7 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements private static final Logger LOGGER = LogManagerCompat.getLogger(); - private final BukkitImplAdapter parent; + private final PaperweightAdapter parent; // ------------------------------------------------------------------------ // Code that may break between versions of Minecraft // ------------------------------------------------------------------------ @@ -121,7 +122,7 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements private Map>> allBlockProperties = null; public PaperweightFaweAdapter() throws NoSuchFieldException, NoSuchMethodException { - this.parent = new PaperweightFaweAdapter(); + this.parent = new PaperweightAdapter(); } @Nullable diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightFaweWorldNativeAccess.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweWorldNativeAccess.java similarity index 99% rename from worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightFaweWorldNativeAccess.java rename to worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweWorldNativeAccess.java index 017bb5622..ba56db4a7 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightFaweWorldNativeAccess.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightFaweWorldNativeAccess.java @@ -1,4 +1,4 @@ -package com.sk89q.worldedit.bukkit.adapter.impl.v1_17_R1_2.fawe; +package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2; import com.fastasyncworldedit.core.Fawe; import com.fastasyncworldedit.core.math.IntPair; diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightGetBlocks.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightGetBlocks.java similarity index 99% rename from worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightGetBlocks.java rename to worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightGetBlocks.java index 3147e659c..b147a1650 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightGetBlocks.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightGetBlocks.java @@ -1,4 +1,4 @@ -package com.sk89q.worldedit.bukkit.adapter.impl.v1_17_R1_2.fawe; +package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2; import com.fastasyncworldedit.bukkit.adapter.BukkitGetBlocks; import com.fastasyncworldedit.bukkit.adapter.DelegateSemaphore; @@ -20,7 +20,7 @@ import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.WorldEditPlugin; -import com.sk89q.worldedit.bukkit.adapter.impl.v1_17_R1_2.fawe.nbt.PaperweightLazyCompoundTag; +import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2.nbt.PaperweightLazyCompoundTag; import com.sk89q.worldedit.internal.Constants; import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightGetBlocks_Copy.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightGetBlocks_Copy.java similarity index 98% rename from worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightGetBlocks_Copy.java rename to worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightGetBlocks_Copy.java index 5a1f87bd6..63ecb5776 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightGetBlocks_Copy.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightGetBlocks_Copy.java @@ -1,4 +1,4 @@ -package com.sk89q.worldedit.bukkit.adapter.impl.v1_17_R1_2.fawe; +package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2; import com.fastasyncworldedit.core.extent.processor.heightmap.HeightMapType; import com.fastasyncworldedit.core.queue.IBlocks; @@ -8,7 +8,7 @@ import com.google.common.base.Suppliers; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; -import com.sk89q.worldedit.bukkit.adapter.impl.v1_17_R1_2.fawe.nbt.PaperweightLazyCompoundTag; +import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2.nbt.PaperweightLazyCompoundTag; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightMapChunkUtil.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightMapChunkUtil.java similarity index 72% rename from worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightMapChunkUtil.java rename to worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightMapChunkUtil.java index be0fbd418..c9d5ed124 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightMapChunkUtil.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightMapChunkUtil.java @@ -1,18 +1,19 @@ -package com.sk89q.worldedit.bukkit.adapter.impl.v1_17_R1_2.fawe; +package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2; import com.fastasyncworldedit.bukkit.adapter.MapChunkUtil; +import com.sk89q.worldedit.bukkit.adapter.Refraction; import net.minecraft.network.protocol.game.ClientboundLevelChunkPacket; public class PaperweightMapChunkUtil extends MapChunkUtil { public PaperweightMapChunkUtil() throws NoSuchFieldException { - fieldX = ClientboundLevelChunkPacket.class.getDeclaredField("TWO_MEGABYTES"); - fieldZ = ClientboundLevelChunkPacket.class.getDeclaredField("x"); - fieldBitMask = ClientboundLevelChunkPacket.class.getDeclaredField("z"); - fieldHeightMap = ClientboundLevelChunkPacket.class.getDeclaredField("availableSections"); - fieldChunkData = ClientboundLevelChunkPacket.class.getDeclaredField("biomes"); - fieldBlockEntities = ClientboundLevelChunkPacket.class.getDeclaredField("buffer"); - fieldFull = ClientboundLevelChunkPacket.class.getDeclaredField("blockEntitiesTags"); + fieldX = ClientboundLevelChunkPacket.class.getDeclaredField(Refraction.pickName("TWO_MEGABYTES", "a")); + fieldZ = ClientboundLevelChunkPacket.class.getDeclaredField(Refraction.pickName("x", "b")); + fieldBitMask = ClientboundLevelChunkPacket.class.getDeclaredField(Refraction.pickName("z", "c")); + fieldHeightMap = ClientboundLevelChunkPacket.class.getDeclaredField(Refraction.pickName("availableSections", "d")); + fieldChunkData = ClientboundLevelChunkPacket.class.getDeclaredField(Refraction.pickName("biomes", "f")); + fieldBlockEntities = ClientboundLevelChunkPacket.class.getDeclaredField(Refraction.pickName("buffer", "g")); + fieldFull = ClientboundLevelChunkPacket.class.getDeclaredField(Refraction.pickName("blockEntitiesTags", "h")); fieldX.setAccessible(true); fieldZ.setAccessible(true); fieldBitMask.setAccessible(true); diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightPlatformAdapter.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightPlatformAdapter.java similarity index 94% rename from worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightPlatformAdapter.java rename to worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightPlatformAdapter.java index ab3fa79a7..6e20e604e 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightPlatformAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightPlatformAdapter.java @@ -1,4 +1,4 @@ -package com.sk89q.worldedit.bukkit.adapter.impl.v1_17_R1_2.fawe; +package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2; import com.fastasyncworldedit.bukkit.adapter.CachedBukkitAdapter; import com.fastasyncworldedit.bukkit.adapter.DelegateSemaphore; @@ -11,6 +11,7 @@ import com.fastasyncworldedit.core.util.MathMan; import com.fastasyncworldedit.core.util.TaskManager; import com.fastasyncworldedit.core.util.UnsafeUtility; import com.mojang.datafixers.util.Either; +import com.sk89q.worldedit.bukkit.adapter.Refraction; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeTypes; @@ -91,41 +92,50 @@ public final class PaperweightPlatformAdapter extends NMSAdapter { static { try { - fieldBits = PalettedContainer.class.getDeclaredField("bits"); + fieldBits = PalettedContainer.class.getDeclaredField(Refraction.pickName("bits", "l")); fieldBits.setAccessible(true); - fieldStorage = PalettedContainer.class.getDeclaredField("storage"); + fieldStorage = PalettedContainer.class.getDeclaredField(Refraction.pickName("storage", "c")); fieldStorage.setAccessible(true); - fieldPalette = PalettedContainer.class.getDeclaredField("palette"); + fieldPalette = PalettedContainer.class.getDeclaredField(Refraction.pickName("palette", "k")); fieldPalette.setAccessible(true); - fieldBitsPerEntry = BitStorage.class.getDeclaredField("bits"); + fieldBitsPerEntry = BitStorage.class.getDeclaredField(Refraction.pickName("bits", "c")); fieldBitsPerEntry.setAccessible(true); - fieldTickingFluidContent = LevelChunkSection.class.getDeclaredField("tickingFluidCount"); + fieldTickingFluidContent = LevelChunkSection.class.getDeclaredField(Refraction.pickName("tickingFluidCount", "h")); fieldTickingFluidContent.setAccessible(true); - fieldTickingBlockCount = LevelChunkSection.class.getDeclaredField("tickingBlockCount"); + fieldTickingBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("tickingBlockCount", "g")); fieldTickingBlockCount.setAccessible(true); - fieldNonEmptyBlockCount = LevelChunkSection.class.getDeclaredField("nonEmptyBlockCount"); + fieldNonEmptyBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("nonEmptyBlockCount", "f")); fieldNonEmptyBlockCount.setAccessible(true); - fieldBiomes = ChunkBiomeContainer.class.getDeclaredField("biomes"); + fieldBiomes = ChunkBiomeContainer.class.getDeclaredField(Refraction.pickName("biomes", "f")); fieldBiomes.setAccessible(true); - Method getVisibleChunkIfPresent = ChunkMap.class.getDeclaredMethod("getVisibleChunkIfPresent", long.class); + Method getVisibleChunkIfPresent = ChunkMap.class.getDeclaredMethod(Refraction.pickName( + "getVisibleChunkIfPresent", + "getVisibleChunk" + ), long.class); getVisibleChunkIfPresent.setAccessible(true); methodGetVisibleChunk = MethodHandles.lookup().unreflect(getVisibleChunkIfPresent); Unsafe unsafe = UnsafeUtility.getUNSAFE(); - fieldLock = PalettedContainer.class.getDeclaredField("lock"); + fieldLock = PalettedContainer.class.getDeclaredField(Refraction.pickName("lock", "m")); fieldLockOffset = unsafe.objectFieldOffset(fieldLock); - fieldGameEventDispatcherSections = LevelChunk.class.getDeclaredField("gameEventDispatcherSections"); + fieldGameEventDispatcherSections = LevelChunk.class.getDeclaredField(Refraction.pickName( + "gameEventDispatcherSections", "x")); fieldGameEventDispatcherSections.setAccessible(true); - Method removeBlockEntityTicker = LevelChunk.class.getDeclaredMethod("removeBlockEntityTicker", BlockPos.class); + Method removeBlockEntityTicker = LevelChunk.class.getDeclaredMethod( + Refraction.pickName( + "removeBlockEntityTicker", + "l" + ), BlockPos.class + ); removeBlockEntityTicker.setAccessible(true); methodremoveTickingBlockEntity = MethodHandles.lookup().unreflect(removeBlockEntityTicker); - fieldRemove = BlockEntity.class.getDeclaredField("remove"); + fieldRemove = BlockEntity.class.getDeclaredField(Refraction.pickName("remove", "p")); fieldRemove.setAccessible(true); CHUNKSECTION_BASE = unsafe.arrayBaseOffset(LevelChunkSection[].class); diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightStarlightRelighter.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightStarlightRelighter.java similarity index 99% rename from worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightStarlightRelighter.java rename to worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightStarlightRelighter.java index a6a1f06bd..bd8363ece 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightStarlightRelighter.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightStarlightRelighter.java @@ -1,4 +1,4 @@ -package com.sk89q.worldedit.bukkit.adapter.impl.v1_17_R1_2.fawe; +package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2; import com.fastasyncworldedit.core.configuration.Settings; import com.fastasyncworldedit.core.extent.processor.lighting.NMSRelighter; diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightStarlightRelighterFactory.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightStarlightRelighterFactory.java similarity index 94% rename from worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightStarlightRelighterFactory.java rename to worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightStarlightRelighterFactory.java index c87213e8d..d8d6a92fd 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/PaperweightStarlightRelighterFactory.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightStarlightRelighterFactory.java @@ -1,4 +1,4 @@ -package com.sk89q.worldedit.bukkit.adapter.impl.v1_17_R1_2.fawe; +package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2; import com.fastasyncworldedit.core.extent.processor.lighting.NullRelighter; import com.fastasyncworldedit.core.extent.processor.lighting.RelightMode; diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/nbt/PaperweightLazyCompoundTag.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/nbt/PaperweightLazyCompoundTag.java similarity index 98% rename from worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/nbt/PaperweightLazyCompoundTag.java rename to worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/nbt/PaperweightLazyCompoundTag.java index 9e20f9591..41cc94827 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/nbt/PaperweightLazyCompoundTag.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/nbt/PaperweightLazyCompoundTag.java @@ -1,4 +1,4 @@ -package com.sk89q.worldedit.bukkit.adapter.impl.v1_17_R1_2.fawe.nbt; +package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2.nbt; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.LazyCompoundTag; diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/regen/PaperweightRegen.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/regen/PaperweightRegen.java similarity index 97% rename from worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/regen/PaperweightRegen.java rename to worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/regen/PaperweightRegen.java index 698d8bd0a..2d5d0e3fd 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/v1_17_R1_2/fawe/regen/PaperweightRegen.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/regen/PaperweightRegen.java @@ -1,15 +1,17 @@ -package com.sk89q.worldedit.bukkit.adapter.impl.v1_17_R1_2.fawe.regen; +package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2.regen; import com.fastasyncworldedit.bukkit.adapter.Regenerator; import com.fastasyncworldedit.core.Fawe; import com.fastasyncworldedit.core.queue.IChunkCache; import com.fastasyncworldedit.core.queue.IChunkGet; +import com.fastasyncworldedit.core.util.ReflectionUtils; import com.google.common.collect.ImmutableList; import com.mojang.datafixers.util.Either; import com.mojang.serialization.Codec; import com.mojang.serialization.Dynamic; import com.mojang.serialization.Lifecycle; -import com.sk89q.worldedit.bukkit.adapter.impl.v1_17_R1_2.fawe.PaperweightGetBlocks; +import com.sk89q.worldedit.bukkit.adapter.Refraction; +import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_17_R1_2.PaperweightGetBlocks; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.regions.Region; @@ -71,8 +73,11 @@ import org.bukkit.generator.BlockPopulator; import javax.annotation.Nullable; import java.io.IOException; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.VarHandle; import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.lang.reflect.Modifier; import java.nio.file.Path; import java.util.Collections; import java.util.HashSet; @@ -145,16 +150,17 @@ public class PaperweightRegen extends Regenerator T as(Class t, Object o) { return t.isInstance(o) ? t.cast(o) : null; } @@ -112,4 +126,13 @@ public class ReflectionUtils { } } + public static void unsafeSet(Object base, long offset, Object value) { + UNSAFE.putObject(base, offset, value); + } + + public static void unsafeSet(Field field, Object base, Object value) { + UNSAFE.putObject(base, UNSAFE.objectFieldOffset(field), value); + } + + }