Skip to content

Commit

Permalink
Cleanup and add for 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
dordsor21 committed Oct 26, 2024
1 parent 2662284 commit 2807219
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ public BaseItemStack adapt(org.bukkit.inventory.ItemStack itemStack) {
= CacheBuilder.newBuilder().weakKeys().softValues().build(CacheLoader.from(PaperweightFakePlayer::new));

@Override
public boolean simulateItemUse(org.bukkit.World world, BlockVector3 position, BaseItem item, Direction face) {
public boolean simulateItemUse(World world, BlockVector3 position, BaseItem item, Direction face) {
CraftWorld craftWorld = (CraftWorld) world;
ServerLevel worldServer = craftWorld.getHandle();
ItemStack stack = CraftItemStack.asNMSCopy(BukkitAdapter.adapt(item instanceof BaseItemStack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public Set<SideEffect> getSupportedSideEffects() {
}

@Override
public WorldNativeAccess<?, ?, ?> createWorldNativeAccess(org.bukkit.World world) {
public WorldNativeAccess<?, ?, ?> createWorldNativeAccess(World world) {
return new PaperweightFaweWorldNativeAccess(this, new WeakReference<>(getServerLevel(world)));
}

Expand Down Expand Up @@ -457,7 +457,7 @@ public <B extends BlockStateHolder<B>> BlockData adapt(B state) {
}

@Override
public void sendFakeChunk(org.bukkit.World world, Player player, ChunkPacket chunkPacket) {
public void sendFakeChunk(World world, Player player, ChunkPacket chunkPacket) {
ServerLevel nmsWorld = getServerLevel(world);
ChunkHolder map = PaperweightPlatformAdapter.getPlayerChunk(nmsWorld, chunkPacket.getChunkX(), chunkPacket.getChunkZ());
if (map != null && wasAccessibleSinceLastSave(map)) {
Expand Down Expand Up @@ -492,7 +492,7 @@ public void sendFakeChunk(org.bukkit.World world, Player player, ChunkPacket chu
}

@Override
public boolean canPlaceAt(org.bukkit.World world, BlockVector3 blockVector3, BlockState blockState) {
public boolean canPlaceAt(World world, BlockVector3 blockVector3, BlockState blockState) {
int internalId = BlockStateIdAccess.getBlockStateId(blockState);
net.minecraft.world.level.block.state.BlockState blockState1 = Block.stateById(internalId);
return blockState1.hasPostProcess(
Expand Down Expand Up @@ -720,12 +720,12 @@ public net.minecraft.nbt.Tag fromNative(Tag foreign) {
}

@Override
public boolean regenerate(org.bukkit.World bukkitWorld, Region region, Extent target, RegenOptions options) throws Exception {
public boolean regenerate(World bukkitWorld, Region region, Extent target, RegenOptions options) throws Exception {
return new PaperweightRegen(bukkitWorld, region, target, options).regenerate();
}

@Override
public IChunkGet get(org.bukkit.World world, int chunkX, int chunkZ) {
public IChunkGet get(World world, int chunkX, int chunkZ) {
return new PaperweightGetBlocks(world, chunkX, chunkZ);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.StateHolder;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.GlobalPalette;
Expand Down Expand Up @@ -100,8 +99,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
private static final Field fieldTickingFluidCount;
private static final Field fieldTickingBlockCount;

private static final Field fieldPropertiesCodec;

private static final MethodHandle methodGetVisibleChunk;

private static final Field fieldThreadingDetector;
Expand Down Expand Up @@ -157,9 +154,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
fieldBiomes = tmpFieldBiomes;
fieldBiomes.setAccessible(true);

fieldPropertiesCodec = StateHolder.class.getDeclaredField(Refraction.pickName("propertiesCodec", "f"));
fieldPropertiesCodec.setAccessible(true);

Method getVisibleChunkIfPresent = ChunkMap.class.getDeclaredMethod(Refraction.pickName(
"getVisibleChunkIfPresent",
"b"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public Set<SideEffect> getSupportedSideEffects() {
}

@Override
public WorldNativeAccess<?, ?, ?> createWorldNativeAccess(org.bukkit.World world) {
public WorldNativeAccess<?, ?, ?> createWorldNativeAccess(World world) {
return new PaperweightFaweWorldNativeAccess(this, new WeakReference<>(getServerLevel(world)));
}

Expand Down Expand Up @@ -457,7 +457,7 @@ public <B extends BlockStateHolder<B>> BlockData adapt(B state) {
}

@Override
public void sendFakeChunk(org.bukkit.World world, Player player, ChunkPacket chunkPacket) {
public void sendFakeChunk(World world, Player player, ChunkPacket chunkPacket) {
ServerLevel nmsWorld = getServerLevel(world);
ChunkHolder map = PaperweightPlatformAdapter.getPlayerChunk(nmsWorld, chunkPacket.getChunkX(), chunkPacket.getChunkZ());
if (map != null && wasAccessibleSinceLastSave(map)) {
Expand Down Expand Up @@ -492,7 +492,7 @@ public void sendFakeChunk(org.bukkit.World world, Player player, ChunkPacket chu
}

@Override
public boolean canPlaceAt(org.bukkit.World world, BlockVector3 blockVector3, BlockState blockState) {
public boolean canPlaceAt(World world, BlockVector3 blockVector3, BlockState blockState) {
int internalId = BlockStateIdAccess.getBlockStateId(blockState);
net.minecraft.world.level.block.state.BlockState blockState1 = Block.stateById(internalId);
return blockState1.hasPostProcess(
Expand Down Expand Up @@ -721,12 +721,12 @@ public net.minecraft.nbt.Tag fromNative(Tag foreign) {
}

@Override
public boolean regenerate(org.bukkit.World bukkitWorld, Region region, Extent target, RegenOptions options) throws Exception {
public boolean regenerate(World bukkitWorld, Region region, Extent target, RegenOptions options) throws Exception {
return new PaperweightRegen(bukkitWorld, region, target, options).regenerate();
}

@Override
public IChunkGet get(org.bukkit.World world, int chunkX, int chunkZ) {
public IChunkGet get(World world, int chunkX, int chunkZ) {
return new PaperweightGetBlocks(world, chunkX, chunkZ);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.StateHolder;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.GlobalPalette;
Expand Down Expand Up @@ -101,8 +100,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
private static final Field fieldTickingBlockCount;
private static final Field fieldBiomes;

private static final Field fieldPropertiesCodec;

private static final MethodHandle methodGetVisibleChunk;

private static final Field fieldThreadingDetector;
Expand Down Expand Up @@ -157,9 +154,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
fieldBiomes = tmpFieldBiomes;
fieldBiomes.setAccessible(true);

fieldPropertiesCodec = StateHolder.class.getDeclaredField(Refraction.pickName("propertiesCodec", "f"));
fieldPropertiesCodec.setAccessible(true);

Method getVisibleChunkIfPresent = ChunkMap.class.getDeclaredMethod(Refraction.pickName(
"getVisibleChunkIfPresent",
"b"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public Set<SideEffect> getSupportedSideEffects() {
}

@Override
public WorldNativeAccess<?, ?, ?> createWorldNativeAccess(org.bukkit.World world) {
public WorldNativeAccess<?, ?, ?> createWorldNativeAccess(World world) {
return new PaperweightFaweWorldNativeAccess(this, new WeakReference<>(getServerLevel(world)));
}

Expand Down Expand Up @@ -465,7 +465,7 @@ public <B extends BlockStateHolder<B>> BlockData adapt(B state) {
}

@Override
public void sendFakeChunk(org.bukkit.World world, Player player, ChunkPacket chunkPacket) {
public void sendFakeChunk(World world, Player player, ChunkPacket chunkPacket) {
ServerLevel nmsWorld = getServerLevel(world);
ChunkHolder map = PaperweightPlatformAdapter.getPlayerChunk(nmsWorld, chunkPacket.getChunkX(), chunkPacket.getChunkZ());
if (map != null && wasAccessibleSinceLastSave(map)) {
Expand Down Expand Up @@ -500,7 +500,7 @@ public void sendFakeChunk(org.bukkit.World world, Player player, ChunkPacket chu
}

@Override
public boolean canPlaceAt(org.bukkit.World world, BlockVector3 blockVector3, BlockState blockState) {
public boolean canPlaceAt(World world, BlockVector3 blockVector3, BlockState blockState) {
int internalId = BlockStateIdAccess.getBlockStateId(blockState);
net.minecraft.world.level.block.state.BlockState blockState1 = Block.stateById(internalId);
return blockState1.hasPostProcess(
Expand Down Expand Up @@ -741,12 +741,12 @@ public net.minecraft.nbt.Tag fromNative(Tag foreign) {
}

@Override
public boolean regenerate(org.bukkit.World bukkitWorld, Region region, Extent target, RegenOptions options) throws Exception {
public boolean regenerate(World bukkitWorld, Region region, Extent target, RegenOptions options) throws Exception {
return new PaperweightRegen(bukkitWorld, region, target, options).regenerate();
}

@Override
public IChunkGet get(org.bukkit.World world, int chunkX, int chunkZ) {
public IChunkGet get(World world, int chunkX, int chunkZ) {
return new PaperweightGetBlocks(world, chunkX, chunkZ);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.StateHolder;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.GlobalPalette;
import net.minecraft.world.level.chunk.HashMapPalette;
Expand Down Expand Up @@ -101,8 +100,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
private static final Field fieldTickingBlockCount;
private static final Field fieldBiomes;

private static final Field fieldPropertiesCodec;

private static final MethodHandle methodGetVisibleChunk;

private static final Field fieldThreadingDetector;
Expand Down Expand Up @@ -157,9 +154,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
fieldBiomes = tmpFieldBiomes;
fieldBiomes.setAccessible(true);

fieldPropertiesCodec = StateHolder.class.getDeclaredField(Refraction.pickName("propertiesCodec", "f"));
fieldPropertiesCodec.setAccessible(true);

Method getVisibleChunkIfPresent = ChunkMap.class.getDeclaredMethod(Refraction.pickName(
"getVisibleChunkIfPresent",
"b"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_21_R1;

import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Holder;
Expand All @@ -10,15 +9,16 @@
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeManager;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.flag.FeatureFlagSet;
import net.minecraft.world.level.border.WorldBorder;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkSource;
import net.minecraft.world.level.chunk.status.ChunkStatus;
import net.minecraft.world.level.lighting.LevelLightEngine;
import net.minecraft.world.level.material.FluidState;
import org.bukkit.craftbukkit.util.BlockStateListPopulator;
import org.jetbrains.annotations.Nullable;

import javax.annotation.Nullable;

public class FaweBlockStateListPopulator extends BlockStateListPopulator {

Expand Down Expand Up @@ -69,6 +69,11 @@ public int getSeaLevel() {
return world.getSeaLevel();
}

@Override
public FeatureFlagSet enabledFeatures() {
return world.enabledFeatures();
}

@Override
public float getShade(final Direction direction, final boolean shaded) {
return world.getShade(direction, shaded);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_21_R1.PaperweightAdapter;
import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_21_R1.nbt.PaperweightLazyCompoundTag;
import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_21_R1.regen.PaperweightRegen;
import com.sk89q.worldedit.entity.BaseEntity;
Expand Down Expand Up @@ -139,7 +140,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
}
}

private final com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_21_R1.PaperweightAdapter parent;
private final PaperweightAdapter parent;
// ------------------------------------------------------------------------
// Code that may break between versions of Minecraft
// ------------------------------------------------------------------------
Expand All @@ -150,7 +151,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
private Map<String, List<Property<?>>> allBlockProperties = null;

public PaperweightFaweAdapter() throws NoSuchFieldException, NoSuchMethodException {
this.parent = new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_21_R1.PaperweightAdapter();
this.parent = new PaperweightAdapter();
}

public Function<BlockEntity, FaweCompoundTag> blockEntityToCompoundTag() {
Expand Down Expand Up @@ -320,7 +321,7 @@ public Set<SideEffect> getSupportedSideEffects() {
}

@Override
public WorldNativeAccess<?, ?, ?> createWorldNativeAccess(org.bukkit.World world) {
public WorldNativeAccess<?, ?, ?> createWorldNativeAccess(World world) {
return new PaperweightFaweWorldNativeAccess(this, new WeakReference<>(getServerLevel(world)));
}

Expand Down Expand Up @@ -465,7 +466,7 @@ public <B extends BlockStateHolder<B>> BlockData adapt(B state) {
}

@Override
public void sendFakeChunk(org.bukkit.World world, Player player, ChunkPacket chunkPacket) {
public void sendFakeChunk(World world, Player player, ChunkPacket chunkPacket) {
ServerLevel nmsWorld = getServerLevel(world);
ChunkHolder map = PaperweightPlatformAdapter.getPlayerChunk(nmsWorld, chunkPacket.getChunkX(), chunkPacket.getChunkZ());
if (map != null && wasAccessibleSinceLastSave(map)) {
Expand Down Expand Up @@ -500,7 +501,7 @@ public void sendFakeChunk(org.bukkit.World world, Player player, ChunkPacket chu
}

@Override
public boolean canPlaceAt(org.bukkit.World world, BlockVector3 blockVector3, BlockState blockState) {
public boolean canPlaceAt(World world, BlockVector3 blockVector3, BlockState blockState) {
int internalId = BlockStateIdAccess.getBlockStateId(blockState);
net.minecraft.world.level.block.state.BlockState blockState1 = Block.stateById(internalId);
return blockState1.hasPostProcess(
Expand Down Expand Up @@ -593,7 +594,6 @@ public boolean generateFeature(ConfiguredFeatureType feature, World world, EditS

@Override
public boolean generateStructure(StructureType type, World world, EditSession editSession, BlockVector3 pt) {
//FAWE start
ServerLevel serverLevel = ((CraftWorld) world).getHandle();
Structure k = serverLevel
.registryAccess()
Expand Down Expand Up @@ -743,12 +743,12 @@ public net.minecraft.nbt.Tag fromNative(Tag foreign) {
}

@Override
public boolean regenerate(org.bukkit.World bukkitWorld, Region region, Extent target, RegenOptions options) throws Exception {
public boolean regenerate(World bukkitWorld, Region region, Extent target, RegenOptions options) throws Exception {
return new PaperweightRegen(bukkitWorld, region, target, options).regenerate();
}

@Override
public IChunkGet get(org.bukkit.World world, int chunkX, int chunkZ) {
public IChunkGet get(World world, int chunkX, int chunkZ) {
return new PaperweightGetBlocks(world, chunkX, chunkZ);
}

Expand Down

0 comments on commit 2807219

Please sign in to comment.