Telesphoreo 2024-06-14 19:19:33 -05:00
commit 754b228d84
388 changed files with 4218 additions and 2761 deletions

View File

@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Label conflicting PRs - name: Label conflicting PRs
uses: eps1lon/actions-label-merge-conflict@v3.0.1 uses: eps1lon/actions-label-merge-conflict@v3.0.2
with: with:
dirtyLabel: "unresolved-merge-conflict" dirtyLabel: "unresolved-merge-conflict"
repoToken: "${{ secrets.GITHUB_TOKEN }}" repoToken: "${{ secrets.GITHUB_TOKEN }}"

View File

@ -14,7 +14,7 @@ mapmanager = "1.8.0-SNAPSHOT"
griefprevention = "17.0.0" griefprevention = "17.0.0"
griefdefender = "2.1.0-SNAPSHOT" griefdefender = "2.1.0-SNAPSHOT"
residence = "4.5._13.1" residence = "4.5._13.1"
towny = "0.100.2.9" towny = "0.100.2.14"
plotsquared = "7.3.8" plotsquared = "7.3.8"
# Third party # Third party
@ -22,7 +22,7 @@ bstats = "3.0.2"
sparsebitset = "1.3" sparsebitset = "1.3"
parallelgzip = "1.0.5" parallelgzip = "1.0.5"
adventure = "4.17.0" adventure = "4.17.0"
adventure-bukkit = "4.3.2" adventure-bukkit = "4.3.3"
checkerqual = "3.43.0" checkerqual = "3.43.0"
truezip = "6.8.4" truezip = "6.8.4"
auto-value = "1.10.4" auto-value = "1.10.4"
@ -35,7 +35,7 @@ jlibnoise = "1.0.0"
jchronic = "0.2.4a" jchronic = "0.2.4a"
lz4-java = "1.8.0" lz4-java = "1.8.0"
lz4-stream = "1.0.0" lz4-stream = "1.0.0"
commons-cli = "1.7.0" commons-cli = "1.8.0"
paperlib = "1.0.8" paperlib = "1.0.8"
paster = "1.1.6" paster = "1.1.6"
vault = "1.7.1" vault = "1.7.1"

View File

@ -27,7 +27,6 @@ import com.google.common.collect.Sets;
import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.Futures;
import com.mojang.datafixers.util.Either; import com.mojang.datafixers.util.Either;
import com.mojang.serialization.Lifecycle; import com.mojang.serialization.Lifecycle;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.NBTConstants; import com.sk89q.jnbt.NBTConstants;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.blocks.BaseItem;
@ -284,11 +283,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
private static Block getBlockFromType(BlockType blockType) { private static Block getBlockFromType(BlockType blockType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.getId())); return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.id()));
} }
private static Item getItemFromType(ItemType itemType) { private static Item getItemFromType(ItemType itemType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.getId())); return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.id()));
} }
@Override @Override
@ -441,7 +440,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
CraftWorld craftWorld = ((CraftWorld) location.getWorld()); CraftWorld craftWorld = ((CraftWorld) location.getWorld());
ServerLevel worldServer = craftWorld.getHandle(); ServerLevel worldServer = craftWorld.getHandle();
Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle()); Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());
if (createdEntity != null) { if (createdEntity != null) {
CompoundBinaryTag nativeTag = state.getNbt(); CompoundBinaryTag nativeTag = state.getNbt();
@ -531,7 +530,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
public void sendFakeNBT(Player player, BlockVector3 pos, CompoundBinaryTag nbtData) { public void sendFakeNBT(Player player, BlockVector3 pos, CompoundBinaryTag nbtData) {
((CraftPlayer) player).getHandle().connection.send(ClientboundBlockEntityDataPacket.create( ((CraftPlayer) player).getHandle().connection.send(ClientboundBlockEntityDataPacket.create(
new StructureBlockEntity( new StructureBlockEntity(
new BlockPos(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()), new BlockPos(pos.x(), pos.y(), pos.z()),
Blocks.STRUCTURE_BLOCK.defaultBlockState() Blocks.STRUCTURE_BLOCK.defaultBlockState()
), ),
__ -> (net.minecraft.nbt.CompoundTag) fromNativeBinary(nbtData) __ -> (net.minecraft.nbt.CompoundTag) fromNativeBinary(nbtData)
@ -548,7 +547,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
@Override @Override
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) { public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
ItemStack stack = new ItemStack( ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())), DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
item.getAmount() item.getAmount()
); );
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData()))); stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));
@ -581,10 +580,10 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
return false; return false;
} }
fakePlayer.setItemInHand(InteractionHand.MAIN_HAND, stack); fakePlayer.setItemInHand(InteractionHand.MAIN_HAND, stack);
fakePlayer.absMoveTo(position.getBlockX(), position.getBlockY(), position.getBlockZ(), fakePlayer.absMoveTo(position.x(), position.y(), position.z(),
(float) face.toVector().toYaw(), (float) face.toVector().toPitch()); (float) face.toVector().toYaw(), (float) face.toVector().toPitch());
final BlockPos blockPos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()); final BlockPos blockPos = new BlockPos(position.x(), position.y(), position.z());
final Vec3 blockVec = Vec3.atLowerCornerOf(blockPos); final Vec3 blockVec = Vec3.atLowerCornerOf(blockPos);
final net.minecraft.core.Direction enumFacing = adapt(face); final net.minecraft.core.Direction enumFacing = adapt(face);
BlockHitResult rayTrace = new BlockHitResult(blockVec, enumFacing, blockPos, false); BlockHitResult rayTrace = new BlockHitResult(blockVec, enumFacing, blockPos, false);
@ -605,7 +604,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
public boolean canPlaceAt(org.bukkit.World world, BlockVector3 position, BlockState blockState) { public boolean canPlaceAt(org.bukkit.World world, BlockVector3 position, BlockState blockState) {
int internalId = BlockStateIdAccess.getBlockStateId(blockState); int internalId = BlockStateIdAccess.getBlockStateId(blockState);
net.minecraft.world.level.block.state.BlockState blockData = Block.stateById(internalId); net.minecraft.world.level.block.state.BlockState blockData = Block.stateById(internalId);
return blockData.canSurvive(((CraftWorld) world).getHandle(), new BlockPos(position.getX(), position.getY(), position.getZ())); return blockData.canSurvive(((CraftWorld) world).getHandle(), new BlockPos(position.x(), position.y(), position.z()));
} }
@Override @Override
@ -725,7 +724,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
} }
for (BlockVector3 vec : region) { for (BlockVector3 vec : region) {
BlockPos pos = new BlockPos(vec.getBlockX(), vec.getBlockY(), vec.getBlockZ()); BlockPos pos = new BlockPos(vec.x(), vec.y(), vec.z());
ChunkAccess chunk = chunks.get(new ChunkPos(pos)); ChunkAccess chunk = chunks.get(new ChunkPos(pos));
final net.minecraft.world.level.block.state.BlockState blockData = chunk.getBlockState(pos); final net.minecraft.world.level.block.state.BlockState blockData = chunk.getBlockState(pos);
int internalId = Block.getId(blockData); int internalId = Block.getId(blockData);
@ -738,7 +737,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
} }
extent.setBlock(vec, state.toBaseBlock()); extent.setBlock(vec, state.toBaseBlock());
if (options.shouldRegenBiomes()) { if (options.shouldRegenBiomes()) {
Biome origBiome = chunk.getNoiseBiome(vec.getX(), vec.getY(), vec.getZ()).value(); Biome origBiome = chunk.getNoiseBiome(vec.x(), vec.y(), vec.z()).value();
BiomeType adaptedBiome = adapt(serverWorld, origBiome); BiomeType adaptedBiome = adapt(serverWorld, origBiome);
if (adaptedBiome != null) { if (adaptedBiome != null) {
extent.setBiome(vec, adaptedBiome); extent.setBiome(vec, adaptedBiome);
@ -757,7 +756,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
//noinspection unchecked //noinspection unchecked
chunkLoadings.add( chunkLoadings.add(
((CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>>) ((CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>>)
getChunkFutureMethod.invoke(chunkManager, chunk.getX(), chunk.getZ(), ChunkStatus.FEATURES, true)) getChunkFutureMethod.invoke(chunkManager, chunk.x(), chunk.z(), ChunkStatus.FEATURES, true))
.thenApply(either -> either.left().orElse(null)) .thenApply(either -> either.left().orElse(null))
); );
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
@ -797,7 +796,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
public boolean clearContainerBlockContents(org.bukkit.World world, BlockVector3 pt) { public boolean clearContainerBlockContents(org.bukkit.World world, BlockVector3 pt) {
ServerLevel originalWorld = ((CraftWorld) world).getHandle(); ServerLevel originalWorld = ((CraftWorld) world).getHandle();
BlockEntity entity = originalWorld.getBlockEntity(new BlockPos(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ())); BlockEntity entity = originalWorld.getBlockEntity(new BlockPos(pt.x(), pt.y(), pt.z()));
if (entity instanceof Clearable) { if (entity instanceof Clearable) {
((Clearable) entity).clearContent(); ((Clearable) entity).clearContent();
return true; return true;

View File

@ -472,7 +472,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
net.minecraft.world.level.block.state.BlockState blockState1 = Block.stateById(internalId); net.minecraft.world.level.block.state.BlockState blockState1 = Block.stateById(internalId);
return blockState1.hasPostProcess( return blockState1.hasPostProcess(
getServerLevel(world), getServerLevel(world),
new BlockPos(blockVector3.getX(), blockVector3.getY(), blockVector3.getZ()) new BlockPos(blockVector3.x(), blockVector3.y(), blockVector3.z())
); );
} }
@ -480,7 +480,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) { public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
ItemStack stack = new ItemStack( ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM) DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
.get(ResourceLocation.tryParse(baseItemStack.getType().getId())), .get(ResourceLocation.tryParse(baseItemStack.getType().id())),
baseItemStack.getAmount() baseItemStack.getAmount()
); );
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData()))); stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
@ -547,7 +547,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
.getServer() .getServer()
.registryAccess() .registryAccess()
.registryOrThrow(BIOME); .registryOrThrow(BIOME);
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId()); ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
Biome biome = registry.get(resourceLocation); Biome biome = registry.get(resourceLocation);
return registry.getId(biome); return registry.getId(biome);
} }

View File

@ -246,7 +246,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
return; return;
} }
for (IntPair chunk : toSend) { for (IntPair chunk : toSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false); PaperweightPlatformAdapter.sendChunk(chunk, getLevel().getWorld().getHandle(), chunk.x(), chunk.z());
} }
} }
}; };
@ -262,7 +262,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE) sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE)
)); ));
for (IntPair chunk : cachedChunksToSend) { for (IntPair chunk : cachedChunksToSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false); PaperweightPlatformAdapter.sendChunk(chunk, getLevel().getWorld().getHandle(), chunk.x(), chunk.z());
} }
} }
}; };

View File

@ -786,9 +786,9 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) { for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) {
final CompoundTag nativeTag = entry.getValue(); final CompoundTag nativeTag = entry.getValue();
final BlockVector3 blockHash = entry.getKey(); final BlockVector3 blockHash = entry.getKey();
final int x = blockHash.getX() + bx; final int x = blockHash.x() + bx;
final int y = blockHash.getY(); final int y = blockHash.y();
final int z = blockHash.getZ() + bz; final int z = blockHash.z() + bz;
final BlockPos pos = new BlockPos(x, y, z); final BlockPos pos = new BlockPos(x, y, z);
synchronized (nmsWorld) { synchronized (nmsWorld) {
@ -823,7 +823,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
nmsChunk.setUnsaved(true); nmsChunk.setUnsaved(true);
// send to player // send to player
if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) { if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) {
this.send(finalMask, finalLightUpdate); this.send();
} }
if (finalizer != null) { if (finalizer != null) {
finalizer.run(); finalizer.run();
@ -919,9 +919,9 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
} }
@Override @Override
public void send(int mask, boolean lighting) { public void send() {
synchronized (sendLock) { synchronized (sendLock) {
PaperweightPlatformAdapter.sendChunk(serverLevel, chunkX, chunkZ, lighting); PaperweightPlatformAdapter.sendChunk(this, serverLevel, chunkX, chunkZ);
} }
} }

View File

@ -26,6 +26,7 @@ import net.minecraft.core.Holder;
import net.minecraft.core.IdMap; import net.minecraft.core.IdMap;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ChunkHolder;
import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ChunkMap;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@ -318,7 +319,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void sendChunk(ServerLevel nmsWorld, int chunkX, int chunkZ, boolean lighting) { public static void sendChunk(Object chunk, ServerLevel nmsWorld, int chunkX, int chunkZ) {
ChunkHolder chunkHolder = getPlayerChunk(nmsWorld, chunkX, chunkZ); ChunkHolder chunkHolder = getPlayerChunk(nmsWorld, chunkX, chunkZ);
if (chunkHolder == null) { if (chunkHolder == null) {
return; return;
@ -339,9 +340,10 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
if (levelChunk == null) { if (levelChunk == null) {
return; return;
} }
TaskManager.taskManager().task(() -> { MinecraftServer.getServer().execute(() -> {
ClientboundLevelChunkWithLightPacket packet; ClientboundLevelChunkWithLightPacket packet;
if (PaperLib.isPaper()) { if (PaperLib.isPaper()) {
synchronized (chunk) {
packet = new ClientboundLevelChunkWithLightPacket( packet = new ClientboundLevelChunkWithLightPacket(
levelChunk, levelChunk,
nmsWorld.getChunkSource().getLightEngine(), nmsWorld.getChunkSource().getLightEngine(),
@ -350,7 +352,9 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
true, true,
false // last false is to not bother with x-ray false // last false is to not bother with x-ray
); );
}
} else { } else {
synchronized (chunk) {
// deprecated on paper - deprecation suppressed // deprecated on paper - deprecation suppressed
packet = new ClientboundLevelChunkWithLightPacket( packet = new ClientboundLevelChunkWithLightPacket(
levelChunk, levelChunk,
@ -360,6 +364,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
true true
); );
} }
}
nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet)); nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet));
}); });
} }

View File

@ -67,7 +67,7 @@ public class PaperweightStarlightRelighter extends StarlightRelighter<ServerLeve
int x = pos.x; int x = pos.x;
int z = pos.z; int z = pos.z;
if (delay) { // we still need to send the block changes of that chunk if (delay) { // we still need to send the block changes of that chunk
PaperweightPlatformAdapter.sendChunk(serverLevel, x, z, false); PaperweightPlatformAdapter.sendChunk(pos, serverLevel, x, z);
} }
serverLevel.getChunkSource().removeTicketAtLevel(FAWE_TICKET, pos, LIGHT_LEVEL, Unit.INSTANCE); serverLevel.getChunkSource().removeTicketAtLevel(FAWE_TICKET, pos, LIGHT_LEVEL, Unit.INSTANCE);
} }

View File

@ -284,11 +284,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
private static Block getBlockFromType(BlockType blockType) { private static Block getBlockFromType(BlockType blockType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.getId())); return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.id()));
} }
private static Item getItemFromType(ItemType itemType) { private static Item getItemFromType(ItemType itemType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.getId())); return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.id()));
} }
@Override @Override
@ -480,7 +480,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
CraftWorld craftWorld = ((CraftWorld) location.getWorld()); CraftWorld craftWorld = ((CraftWorld) location.getWorld());
ServerLevel worldServer = craftWorld.getHandle(); ServerLevel worldServer = craftWorld.getHandle();
Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle()); Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());
if (createdEntity != null) { if (createdEntity != null) {
CompoundBinaryTag nativeTag = state.getNbt(); CompoundBinaryTag nativeTag = state.getNbt();
@ -570,7 +570,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
public void sendFakeNBT(Player player, BlockVector3 pos, CompoundBinaryTag nbtData) { public void sendFakeNBT(Player player, BlockVector3 pos, CompoundBinaryTag nbtData) {
((CraftPlayer) player).getHandle().connection.send(ClientboundBlockEntityDataPacket.create( ((CraftPlayer) player).getHandle().connection.send(ClientboundBlockEntityDataPacket.create(
new StructureBlockEntity( new StructureBlockEntity(
new BlockPos(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()), new BlockPos(pos.x(), pos.y(), pos.z()),
Blocks.STRUCTURE_BLOCK.defaultBlockState() Blocks.STRUCTURE_BLOCK.defaultBlockState()
), ),
__ -> (net.minecraft.nbt.CompoundTag) fromNativeBinary(nbtData) __ -> (net.minecraft.nbt.CompoundTag) fromNativeBinary(nbtData)
@ -598,7 +598,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
@Override @Override
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) { public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
ItemStack stack = new ItemStack( ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())), DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
item.getAmount() item.getAmount()
); );
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData()))); stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));
@ -631,10 +631,10 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
return false; return false;
} }
fakePlayer.setItemInHand(InteractionHand.MAIN_HAND, stack); fakePlayer.setItemInHand(InteractionHand.MAIN_HAND, stack);
fakePlayer.absMoveTo(position.getBlockX(), position.getBlockY(), position.getBlockZ(), fakePlayer.absMoveTo(position.x(), position.y(), position.z(),
(float) face.toVector().toYaw(), (float) face.toVector().toPitch()); (float) face.toVector().toYaw(), (float) face.toVector().toPitch());
final BlockPos blockPos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()); final BlockPos blockPos = new BlockPos(position.x(), position.y(), position.z());
final Vec3 blockVec = Vec3.atLowerCornerOf(blockPos); final Vec3 blockVec = Vec3.atLowerCornerOf(blockPos);
final net.minecraft.core.Direction enumFacing = adapt(face); final net.minecraft.core.Direction enumFacing = adapt(face);
BlockHitResult rayTrace = new BlockHitResult(blockVec, enumFacing, blockPos, false); BlockHitResult rayTrace = new BlockHitResult(blockVec, enumFacing, blockPos, false);
@ -655,7 +655,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
public boolean canPlaceAt(org.bukkit.World world, BlockVector3 position, BlockState blockState) { public boolean canPlaceAt(org.bukkit.World world, BlockVector3 position, BlockState blockState) {
int internalId = BlockStateIdAccess.getBlockStateId(blockState); int internalId = BlockStateIdAccess.getBlockStateId(blockState);
net.minecraft.world.level.block.state.BlockState blockData = Block.stateById(internalId); net.minecraft.world.level.block.state.BlockState blockData = Block.stateById(internalId);
return blockData.canSurvive(((CraftWorld) world).getHandle(), new BlockPos(position.getX(), position.getY(), position.getZ())); return blockData.canSurvive(((CraftWorld) world).getHandle(), new BlockPos(position.x(), position.y(), position.z()));
} }
@Override @Override
@ -776,7 +776,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
} }
for (BlockVector3 vec : region) { for (BlockVector3 vec : region) {
BlockPos pos = new BlockPos(vec.getBlockX(), vec.getBlockY(), vec.getBlockZ()); BlockPos pos = new BlockPos(vec.x(), vec.y(), vec.z());
ChunkAccess chunk = chunks.get(new ChunkPos(pos)); ChunkAccess chunk = chunks.get(new ChunkPos(pos));
final net.minecraft.world.level.block.state.BlockState blockData = chunk.getBlockState(pos); final net.minecraft.world.level.block.state.BlockState blockData = chunk.getBlockState(pos);
int internalId = Block.getId(blockData); int internalId = Block.getId(blockData);
@ -789,7 +789,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
} }
extent.setBlock(vec, state.toBaseBlock()); extent.setBlock(vec, state.toBaseBlock());
if (options.shouldRegenBiomes()) { if (options.shouldRegenBiomes()) {
Biome origBiome = chunk.getNoiseBiome(vec.getX(), vec.getY(), vec.getZ()).value(); Biome origBiome = chunk.getNoiseBiome(vec.x(), vec.y(), vec.z()).value();
BiomeType adaptedBiome = adapt(serverWorld, origBiome); BiomeType adaptedBiome = adapt(serverWorld, origBiome);
if (adaptedBiome != null) { if (adaptedBiome != null) {
extent.setBiome(vec, adaptedBiome); extent.setBiome(vec, adaptedBiome);
@ -808,7 +808,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
//noinspection unchecked //noinspection unchecked
chunkLoadings.add( chunkLoadings.add(
((CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>>) ((CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>>)
getChunkFutureMethod.invoke(chunkManager, chunk.getX(), chunk.getZ(), ChunkStatus.FEATURES, true)) getChunkFutureMethod.invoke(chunkManager, chunk.x(), chunk.z(), ChunkStatus.FEATURES, true))
.thenApply(either -> either.left().orElse(null)) .thenApply(either -> either.left().orElse(null))
); );
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
@ -848,7 +848,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
public boolean clearContainerBlockContents(org.bukkit.World world, BlockVector3 pt) { public boolean clearContainerBlockContents(org.bukkit.World world, BlockVector3 pt) {
ServerLevel originalWorld = ((CraftWorld) world).getHandle(); ServerLevel originalWorld = ((CraftWorld) world).getHandle();
BlockEntity entity = originalWorld.getBlockEntity(new BlockPos(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ())); BlockEntity entity = originalWorld.getBlockEntity(new BlockPos(pt.x(), pt.y(), pt.z()));
if (entity instanceof Clearable) { if (entity instanceof Clearable) {
((Clearable) entity).clearContent(); ((Clearable) entity).clearContent();
return true; return true;

View File

@ -472,7 +472,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
net.minecraft.world.level.block.state.BlockState blockState1 = Block.stateById(internalId); net.minecraft.world.level.block.state.BlockState blockState1 = Block.stateById(internalId);
return blockState1.hasPostProcess( return blockState1.hasPostProcess(
getServerLevel(world), getServerLevel(world),
new BlockPos(blockVector3.getX(), blockVector3.getY(), blockVector3.getZ()) new BlockPos(blockVector3.x(), blockVector3.y(), blockVector3.z())
); );
} }
@ -480,7 +480,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) { public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
ItemStack stack = new ItemStack( ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM) DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
.get(ResourceLocation.tryParse(baseItemStack.getType().getId())), .get(ResourceLocation.tryParse(baseItemStack.getType().id())),
baseItemStack.getAmount() baseItemStack.getAmount()
); );
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData()))); stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
@ -547,7 +547,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
.getServer() .getServer()
.registryAccess() .registryAccess()
.registryOrThrow(BIOME); .registryOrThrow(BIOME);
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId()); ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
Biome biome = registry.get(resourceLocation); Biome biome = registry.get(resourceLocation);
return registry.getId(biome); return registry.getId(biome);
} }

View File

@ -247,7 +247,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
return; return;
} }
for (IntPair chunk : toSend) { for (IntPair chunk : toSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false); PaperweightPlatformAdapter.sendChunk(chunk, getLevel().getWorld().getHandle(), chunk.x(), chunk.z());
} }
} }
}; };
@ -263,7 +263,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE) sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE)
)); ));
for (IntPair chunk : cachedChunksToSend) { for (IntPair chunk : cachedChunksToSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false); PaperweightPlatformAdapter.sendChunk(chunk, getLevel().getWorld().getHandle(), chunk.x(), chunk.z());
} }
} }
}; };

View File

@ -784,9 +784,9 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) { for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) {
final CompoundTag nativeTag = entry.getValue(); final CompoundTag nativeTag = entry.getValue();
final BlockVector3 blockHash = entry.getKey(); final BlockVector3 blockHash = entry.getKey();
final int x = blockHash.getX() + bx; final int x = blockHash.x() + bx;
final int y = blockHash.getY(); final int y = blockHash.y();
final int z = blockHash.getZ() + bz; final int z = blockHash.z() + bz;
final BlockPos pos = new BlockPos(x, y, z); final BlockPos pos = new BlockPos(x, y, z);
synchronized (nmsWorld) { synchronized (nmsWorld) {
@ -821,7 +821,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
nmsChunk.setUnsaved(true); nmsChunk.setUnsaved(true);
// send to player // send to player
if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) { if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) {
this.send(finalMask, finalLightUpdate); this.send();
} }
if (finalizer != null) { if (finalizer != null) {
finalizer.run(); finalizer.run();
@ -917,9 +917,9 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
} }
@Override @Override
public void send(int mask, boolean lighting) { public void send() {
synchronized (sendLock) { synchronized (sendLock) {
PaperweightPlatformAdapter.sendChunk(serverLevel, chunkX, chunkZ, lighting); PaperweightPlatformAdapter.sendChunk(this, serverLevel, chunkX, chunkZ);
} }
} }

View File

@ -26,6 +26,7 @@ import net.minecraft.core.Holder;
import net.minecraft.core.IdMap; import net.minecraft.core.IdMap;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ChunkHolder;
import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ChunkMap;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@ -342,7 +343,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void sendChunk(ServerLevel nmsWorld, int chunkX, int chunkZ, boolean lighting) { public static void sendChunk(Object chunk, ServerLevel nmsWorld, int chunkX, int chunkZ) {
ChunkHolder chunkHolder = getPlayerChunk(nmsWorld, chunkX, chunkZ); ChunkHolder chunkHolder = getPlayerChunk(nmsWorld, chunkX, chunkZ);
if (chunkHolder == null) { if (chunkHolder == null) {
return; return;
@ -363,17 +364,20 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
if (levelChunk == null) { if (levelChunk == null) {
return; return;
} }
TaskManager.taskManager().task(() -> { MinecraftServer.getServer().execute(() -> {
ClientboundLevelChunkWithLightPacket packet; ClientboundLevelChunkWithLightPacket packet;
if (PaperLib.isPaper()) { if (PaperLib.isPaper()) {
synchronized (chunk) {
packet = new ClientboundLevelChunkWithLightPacket( packet = new ClientboundLevelChunkWithLightPacket(
levelChunk, levelChunk,
nmsWorld.getChunkSource().getLightEngine(), nmsWorld.getChunkSource().getLightEngine(),
null, null,
null null,
// last false is to not bother with x-ray false // last false is to not bother with x-ray
); );
}
} else { } else {
synchronized (chunk) {
// deprecated on paper - deprecation suppressed // deprecated on paper - deprecation suppressed
packet = new ClientboundLevelChunkWithLightPacket( packet = new ClientboundLevelChunkWithLightPacket(
levelChunk, levelChunk,
@ -382,6 +386,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
null null
); );
} }
}
nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet)); nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet));
}); });
} }

View File

@ -67,7 +67,7 @@ public class PaperweightStarlightRelighter extends StarlightRelighter<ServerLeve
int x = pos.x; int x = pos.x;
int z = pos.z; int z = pos.z;
if (delay) { // we still need to send the block changes of that chunk if (delay) { // we still need to send the block changes of that chunk
PaperweightPlatformAdapter.sendChunk(serverLevel, x, z, false); PaperweightPlatformAdapter.sendChunk(pos, serverLevel, x, z);
} }
serverLevel.getChunkSource().removeTicketAtLevel(FAWE_TICKET, pos, LIGHT_LEVEL, Unit.INSTANCE); serverLevel.getChunkSource().removeTicketAtLevel(FAWE_TICKET, pos, LIGHT_LEVEL, Unit.INSTANCE);
} }

View File

@ -281,11 +281,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
private static Block getBlockFromType(BlockType blockType) { private static Block getBlockFromType(BlockType blockType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.getId())); return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.id()));
} }
private static Item getItemFromType(ItemType itemType) { private static Item getItemFromType(ItemType itemType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.getId())); return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.id()));
} }
@Override @Override
@ -440,7 +440,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
CraftWorld craftWorld = ((CraftWorld) location.getWorld()); CraftWorld craftWorld = ((CraftWorld) location.getWorld());
ServerLevel worldServer = craftWorld.getHandle(); ServerLevel worldServer = craftWorld.getHandle();
Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle()); Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());
if (createdEntity != null) { if (createdEntity != null) {
CompoundBinaryTag nativeTag = state.getNbt(); CompoundBinaryTag nativeTag = state.getNbt();
@ -530,7 +530,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
public void sendFakeNBT(Player player, BlockVector3 pos, CompoundBinaryTag nbtData) { public void sendFakeNBT(Player player, BlockVector3 pos, CompoundBinaryTag nbtData) {
((CraftPlayer) player).getHandle().connection.send(ClientboundBlockEntityDataPacket.create( ((CraftPlayer) player).getHandle().connection.send(ClientboundBlockEntityDataPacket.create(
new StructureBlockEntity( new StructureBlockEntity(
new BlockPos(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()), new BlockPos(pos.x(), pos.y(), pos.z()),
Blocks.STRUCTURE_BLOCK.defaultBlockState() Blocks.STRUCTURE_BLOCK.defaultBlockState()
), ),
__ -> (net.minecraft.nbt.CompoundTag) fromNativeBinary(nbtData) __ -> (net.minecraft.nbt.CompoundTag) fromNativeBinary(nbtData)
@ -547,7 +547,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
@Override @Override
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) { public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
ItemStack stack = new ItemStack( ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())), DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
item.getAmount() item.getAmount()
); );
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData()))); stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));
@ -580,10 +580,10 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
return false; return false;
} }
fakePlayer.setItemInHand(InteractionHand.MAIN_HAND, stack); fakePlayer.setItemInHand(InteractionHand.MAIN_HAND, stack);
fakePlayer.absMoveTo(position.getBlockX(), position.getBlockY(), position.getBlockZ(), fakePlayer.absMoveTo(position.x(), position.y(), position.z(),
(float) face.toVector().toYaw(), (float) face.toVector().toPitch()); (float) face.toVector().toYaw(), (float) face.toVector().toPitch());
final BlockPos blockPos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()); final BlockPos blockPos = new BlockPos(position.x(), position.y(), position.z());
final Vec3 blockVec = Vec3.atLowerCornerOf(blockPos); final Vec3 blockVec = Vec3.atLowerCornerOf(blockPos);
final net.minecraft.core.Direction enumFacing = adapt(face); final net.minecraft.core.Direction enumFacing = adapt(face);
BlockHitResult rayTrace = new BlockHitResult(blockVec, enumFacing, blockPos, false); BlockHitResult rayTrace = new BlockHitResult(blockVec, enumFacing, blockPos, false);
@ -604,7 +604,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
public boolean canPlaceAt(org.bukkit.World world, BlockVector3 position, BlockState blockState) { public boolean canPlaceAt(org.bukkit.World world, BlockVector3 position, BlockState blockState) {
int internalId = BlockStateIdAccess.getBlockStateId(blockState); int internalId = BlockStateIdAccess.getBlockStateId(blockState);
net.minecraft.world.level.block.state.BlockState blockData = Block.stateById(internalId); net.minecraft.world.level.block.state.BlockState blockData = Block.stateById(internalId);
return blockData.canSurvive(((CraftWorld) world).getHandle(), new BlockPos(position.getX(), position.getY(), position.getZ())); return blockData.canSurvive(((CraftWorld) world).getHandle(), new BlockPos(position.x(), position.y(), position.z()));
} }
@Override @Override
@ -725,7 +725,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
} }
for (BlockVector3 vec : region) { for (BlockVector3 vec : region) {
BlockPos pos = new BlockPos(vec.getBlockX(), vec.getBlockY(), vec.getBlockZ()); BlockPos pos = new BlockPos(vec.x(), vec.y(), vec.z());
ChunkAccess chunk = chunks.get(new ChunkPos(pos)); ChunkAccess chunk = chunks.get(new ChunkPos(pos));
final net.minecraft.world.level.block.state.BlockState blockData = chunk.getBlockState(pos); final net.minecraft.world.level.block.state.BlockState blockData = chunk.getBlockState(pos);
int internalId = Block.getId(blockData); int internalId = Block.getId(blockData);
@ -738,7 +738,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
} }
extent.setBlock(vec, state.toBaseBlock()); extent.setBlock(vec, state.toBaseBlock());
if (options.shouldRegenBiomes()) { if (options.shouldRegenBiomes()) {
Biome origBiome = chunk.getNoiseBiome(vec.getX(), vec.getY(), vec.getZ()).value(); Biome origBiome = chunk.getNoiseBiome(vec.x(), vec.y(), vec.z()).value();
BiomeType adaptedBiome = adapt(serverWorld, origBiome); BiomeType adaptedBiome = adapt(serverWorld, origBiome);
if (adaptedBiome != null) { if (adaptedBiome != null) {
extent.setBiome(vec, adaptedBiome); extent.setBiome(vec, adaptedBiome);
@ -757,7 +757,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
//noinspection unchecked //noinspection unchecked
chunkLoadings.add( chunkLoadings.add(
((CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>>) ((CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>>)
getChunkFutureMethod.invoke(chunkManager, chunk.getX(), chunk.getZ(), ChunkStatus.FEATURES, true)) getChunkFutureMethod.invoke(chunkManager, chunk.x(), chunk.z(), ChunkStatus.FEATURES, true))
.thenApply(either -> either.left().orElse(null)) .thenApply(either -> either.left().orElse(null))
); );
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
@ -797,7 +797,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
public boolean clearContainerBlockContents(org.bukkit.World world, BlockVector3 pt) { public boolean clearContainerBlockContents(org.bukkit.World world, BlockVector3 pt) {
ServerLevel originalWorld = ((CraftWorld) world).getHandle(); ServerLevel originalWorld = ((CraftWorld) world).getHandle();
BlockEntity entity = originalWorld.getBlockEntity(new BlockPos(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ())); BlockEntity entity = originalWorld.getBlockEntity(new BlockPos(pt.x(), pt.y(), pt.z()));
if (entity instanceof Clearable) { if (entity instanceof Clearable) {
((Clearable) entity).clearContent(); ((Clearable) entity).clearContent();
return true; return true;

View File

@ -475,7 +475,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
net.minecraft.world.level.block.state.BlockState blockState1 = Block.stateById(internalId); net.minecraft.world.level.block.state.BlockState blockState1 = Block.stateById(internalId);
return blockState1.hasPostProcess( return blockState1.hasPostProcess(
getServerLevel(world), getServerLevel(world),
new BlockPos(blockVector3.getX(), blockVector3.getY(), blockVector3.getZ()) new BlockPos(blockVector3.x(), blockVector3.y(), blockVector3.z())
); );
} }
@ -483,7 +483,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) { public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
ItemStack stack = new ItemStack( ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM) DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
.get(ResourceLocation.tryParse(baseItemStack.getType().getId())), .get(ResourceLocation.tryParse(baseItemStack.getType().id())),
baseItemStack.getAmount() baseItemStack.getAmount()
); );
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData()))); stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
@ -550,7 +550,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
.getServer() .getServer()
.registryAccess() .registryAccess()
.registryOrThrow(BIOME); .registryOrThrow(BIOME);
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId()); ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
Biome biome = registry.get(resourceLocation); Biome biome = registry.get(resourceLocation);
return registry.getId(biome); return registry.getId(biome);
} }

View File

@ -247,7 +247,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
return; return;
} }
for (IntPair chunk : toSend) { for (IntPair chunk : toSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false); PaperweightPlatformAdapter.sendChunk(chunk, getLevel().getWorld().getHandle(), chunk.x(), chunk.z());
} }
} }
}; };
@ -263,7 +263,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE) sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE)
)); ));
for (IntPair chunk : cachedChunksToSend) { for (IntPair chunk : cachedChunksToSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false); PaperweightPlatformAdapter.sendChunk(chunk, getLevel().getWorld().getHandle(), chunk.x(), chunk.z());
} }
} }
}; };

View File

@ -771,9 +771,9 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) { for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) {
final CompoundTag nativeTag = entry.getValue(); final CompoundTag nativeTag = entry.getValue();
final BlockVector3 blockHash = entry.getKey(); final BlockVector3 blockHash = entry.getKey();
final int x = blockHash.getX() + bx; final int x = blockHash.x() + bx;
final int y = blockHash.getY(); final int y = blockHash.y();
final int z = blockHash.getZ() + bz; final int z = blockHash.z() + bz;
final BlockPos pos = new BlockPos(x, y, z); final BlockPos pos = new BlockPos(x, y, z);
synchronized (nmsWorld) { synchronized (nmsWorld) {
@ -808,7 +808,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
nmsChunk.setUnsaved(true); nmsChunk.setUnsaved(true);
// send to player // send to player
if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) { if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) {
this.send(finalMask, finalLightUpdate); this.send();
} }
if (finalizer != null) { if (finalizer != null) {
finalizer.run(); finalizer.run();
@ -904,9 +904,9 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
} }
@Override @Override
public void send(int mask, boolean lighting) { public void send() {
synchronized (sendLock) { synchronized (sendLock) {
PaperweightPlatformAdapter.sendChunk(serverLevel, chunkX, chunkZ, lighting); PaperweightPlatformAdapter.sendChunk(this, serverLevel, chunkX, chunkZ);
} }
} }

View File

@ -26,6 +26,7 @@ import net.minecraft.core.Holder;
import net.minecraft.core.IdMap; import net.minecraft.core.IdMap;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ChunkHolder;
import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ChunkMap;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@ -333,7 +334,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void sendChunk(ServerLevel nmsWorld, int chunkX, int chunkZ, boolean lighting) { public static void sendChunk(Object chunk, ServerLevel nmsWorld, int chunkX, int chunkZ) {
ChunkHolder chunkHolder = getPlayerChunk(nmsWorld, chunkX, chunkZ); ChunkHolder chunkHolder = getPlayerChunk(nmsWorld, chunkX, chunkZ);
if (chunkHolder == null) { if (chunkHolder == null) {
return; return;
@ -354,17 +355,20 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
if (levelChunk == null) { if (levelChunk == null) {
return; return;
} }
TaskManager.taskManager().task(() -> { MinecraftServer.getServer().execute(() -> {
ClientboundLevelChunkWithLightPacket packet; ClientboundLevelChunkWithLightPacket packet;
if (PaperLib.isPaper()) { if (PaperLib.isPaper()) {
synchronized (chunk) {
packet = new ClientboundLevelChunkWithLightPacket( packet = new ClientboundLevelChunkWithLightPacket(
levelChunk, levelChunk,
nmsWorld.getChunkSource().getLightEngine(), nmsWorld.getChunkSource().getLightEngine(),
null, null,
null null,
// last false is to not bother with x-ray false // last false is to not bother with x-ray
); );
}
} else { } else {
synchronized (chunk) {
// deprecated on paper - deprecation suppressed // deprecated on paper - deprecation suppressed
packet = new ClientboundLevelChunkWithLightPacket( packet = new ClientboundLevelChunkWithLightPacket(
levelChunk, levelChunk,
@ -373,6 +377,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
null null
); );
} }
}
nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet)); nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet));
}); });
} }

View File

@ -67,7 +67,7 @@ public class PaperweightStarlightRelighter extends StarlightRelighter<ServerLeve
int x = pos.x; int x = pos.x;
int z = pos.z; int z = pos.z;
if (delay) { // we still need to send the block changes of that chunk if (delay) { // we still need to send the block changes of that chunk
PaperweightPlatformAdapter.sendChunk(serverLevel, x, z, false); PaperweightPlatformAdapter.sendChunk(pos, serverLevel, x, z);
} }
serverLevel.getChunkSource().removeTicketAtLevel(FAWE_TICKET, pos, LIGHT_LEVEL, Unit.INSTANCE); serverLevel.getChunkSource().removeTicketAtLevel(FAWE_TICKET, pos, LIGHT_LEVEL, Unit.INSTANCE);
} }

View File

@ -12,6 +12,6 @@ repositories {
dependencies { dependencies {
// url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.4-R0.1-SNAPSHOT
the<PaperweightUserDependenciesExtension>().paperDevBundle("1.20.4-R0.1-20240424.165410-174") the<PaperweightUserDependenciesExtension>().paperDevBundle("1.20.4-R0.1-20240528.102248-175")
compileOnly(libs.paperlib) compileOnly(libs.paperlib)
} }

View File

@ -281,11 +281,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
private static Block getBlockFromType(BlockType blockType) { private static Block getBlockFromType(BlockType blockType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.getId())); return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.id()));
} }
private static Item getItemFromType(ItemType itemType) { private static Item getItemFromType(ItemType itemType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.getId())); return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.id()));
} }
@Override @Override
@ -440,7 +440,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
CraftWorld craftWorld = ((CraftWorld) location.getWorld()); CraftWorld craftWorld = ((CraftWorld) location.getWorld());
ServerLevel worldServer = craftWorld.getHandle(); ServerLevel worldServer = craftWorld.getHandle();
Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle()); Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());
if (createdEntity != null) { if (createdEntity != null) {
CompoundBinaryTag nativeTag = state.getNbt(); CompoundBinaryTag nativeTag = state.getNbt();
@ -530,7 +530,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
public void sendFakeNBT(Player player, BlockVector3 pos, CompoundBinaryTag nbtData) { public void sendFakeNBT(Player player, BlockVector3 pos, CompoundBinaryTag nbtData) {
((CraftPlayer) player).getHandle().connection.send(ClientboundBlockEntityDataPacket.create( ((CraftPlayer) player).getHandle().connection.send(ClientboundBlockEntityDataPacket.create(
new StructureBlockEntity( new StructureBlockEntity(
new BlockPos(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()), new BlockPos(pos.x(), pos.y(), pos.z()),
Blocks.STRUCTURE_BLOCK.defaultBlockState() Blocks.STRUCTURE_BLOCK.defaultBlockState()
), ),
__ -> (net.minecraft.nbt.CompoundTag) fromNativeBinary(nbtData) __ -> (net.minecraft.nbt.CompoundTag) fromNativeBinary(nbtData)
@ -547,7 +547,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
@Override @Override
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) { public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
ItemStack stack = new ItemStack( ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())), DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
item.getAmount() item.getAmount()
); );
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData()))); stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));
@ -580,10 +580,10 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
return false; return false;
} }
fakePlayer.setItemInHand(InteractionHand.MAIN_HAND, stack); fakePlayer.setItemInHand(InteractionHand.MAIN_HAND, stack);
fakePlayer.absMoveTo(position.getBlockX(), position.getBlockY(), position.getBlockZ(), fakePlayer.absMoveTo(position.x(), position.y(), position.z(),
(float) face.toVector().toYaw(), (float) face.toVector().toPitch()); (float) face.toVector().toYaw(), (float) face.toVector().toPitch());
final BlockPos blockPos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()); final BlockPos blockPos = new BlockPos(position.x(), position.y(), position.z());
final Vec3 blockVec = Vec3.atLowerCornerOf(blockPos); final Vec3 blockVec = Vec3.atLowerCornerOf(blockPos);
final net.minecraft.core.Direction enumFacing = adapt(face); final net.minecraft.core.Direction enumFacing = adapt(face);
BlockHitResult rayTrace = new BlockHitResult(blockVec, enumFacing, blockPos, false); BlockHitResult rayTrace = new BlockHitResult(blockVec, enumFacing, blockPos, false);
@ -604,7 +604,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
public boolean canPlaceAt(org.bukkit.World world, BlockVector3 position, BlockState blockState) { public boolean canPlaceAt(org.bukkit.World world, BlockVector3 position, BlockState blockState) {
int internalId = BlockStateIdAccess.getBlockStateId(blockState); int internalId = BlockStateIdAccess.getBlockStateId(blockState);
net.minecraft.world.level.block.state.BlockState blockData = Block.stateById(internalId); net.minecraft.world.level.block.state.BlockState blockData = Block.stateById(internalId);
return blockData.canSurvive(((CraftWorld) world).getHandle(), new BlockPos(position.getX(), position.getY(), position.getZ())); return blockData.canSurvive(((CraftWorld) world).getHandle(), new BlockPos(position.x(), position.y(), position.z()));
} }
@Override @Override
@ -725,7 +725,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
} }
for (BlockVector3 vec : region) { for (BlockVector3 vec : region) {
BlockPos pos = new BlockPos(vec.getBlockX(), vec.getBlockY(), vec.getBlockZ()); BlockPos pos = new BlockPos(vec.x(), vec.y(), vec.z());
ChunkAccess chunk = chunks.get(new ChunkPos(pos)); ChunkAccess chunk = chunks.get(new ChunkPos(pos));
final net.minecraft.world.level.block.state.BlockState blockData = chunk.getBlockState(pos); final net.minecraft.world.level.block.state.BlockState blockData = chunk.getBlockState(pos);
int internalId = Block.getId(blockData); int internalId = Block.getId(blockData);
@ -738,7 +738,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
} }
extent.setBlock(vec, state.toBaseBlock()); extent.setBlock(vec, state.toBaseBlock());
if (options.shouldRegenBiomes()) { if (options.shouldRegenBiomes()) {
Biome origBiome = chunk.getNoiseBiome(vec.getX(), vec.getY(), vec.getZ()).value(); Biome origBiome = chunk.getNoiseBiome(vec.x(), vec.y(), vec.z()).value();
BiomeType adaptedBiome = adapt(serverWorld, origBiome); BiomeType adaptedBiome = adapt(serverWorld, origBiome);
if (adaptedBiome != null) { if (adaptedBiome != null) {
extent.setBiome(vec, adaptedBiome); extent.setBiome(vec, adaptedBiome);
@ -757,7 +757,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
//noinspection unchecked //noinspection unchecked
chunkLoadings.add( chunkLoadings.add(
((CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>>) ((CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>>)
getChunkFutureMethod.invoke(chunkManager, chunk.getX(), chunk.getZ(), ChunkStatus.FEATURES, true)) getChunkFutureMethod.invoke(chunkManager, chunk.x(), chunk.z(), ChunkStatus.FEATURES, true))
.thenApply(either -> either.left().orElse(null)) .thenApply(either -> either.left().orElse(null))
); );
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
@ -797,7 +797,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
public boolean clearContainerBlockContents(org.bukkit.World world, BlockVector3 pt) { public boolean clearContainerBlockContents(org.bukkit.World world, BlockVector3 pt) {
ServerLevel originalWorld = ((CraftWorld) world).getHandle(); ServerLevel originalWorld = ((CraftWorld) world).getHandle();
BlockEntity entity = originalWorld.getBlockEntity(new BlockPos(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ())); BlockEntity entity = originalWorld.getBlockEntity(new BlockPos(pt.x(), pt.y(), pt.z()));
if (entity instanceof Clearable) { if (entity instanceof Clearable) {
((Clearable) entity).clearContent(); ((Clearable) entity).clearContent();
return true; return true;

View File

@ -475,7 +475,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
net.minecraft.world.level.block.state.BlockState blockState1 = Block.stateById(internalId); net.minecraft.world.level.block.state.BlockState blockState1 = Block.stateById(internalId);
return blockState1.hasPostProcess( return blockState1.hasPostProcess(
getServerLevel(world), getServerLevel(world),
new BlockPos(blockVector3.getX(), blockVector3.getY(), blockVector3.getZ()) new BlockPos(blockVector3.x(), blockVector3.y(), blockVector3.z())
); );
} }
@ -483,7 +483,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) { public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
ItemStack stack = new ItemStack( ItemStack stack = new ItemStack(
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM) DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
.get(ResourceLocation.tryParse(baseItemStack.getType().getId())), .get(ResourceLocation.tryParse(baseItemStack.getType().id())),
baseItemStack.getAmount() baseItemStack.getAmount()
); );
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData()))); stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
@ -550,7 +550,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
.getServer() .getServer()
.registryAccess() .registryAccess()
.registryOrThrow(BIOME); .registryOrThrow(BIOME);
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId()); ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
Biome biome = registry.get(resourceLocation); Biome biome = registry.get(resourceLocation);
return registry.getId(biome); return registry.getId(biome);
} }

View File

@ -246,7 +246,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
return; return;
} }
for (IntPair chunk : toSend) { for (IntPair chunk : toSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false); PaperweightPlatformAdapter.sendChunk(chunk, getLevel().getWorld().getHandle(), chunk.x(), chunk.z());
} }
} }
}; };
@ -262,7 +262,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE) sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE)
)); ));
for (IntPair chunk : cachedChunksToSend) { for (IntPair chunk : cachedChunksToSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false); PaperweightPlatformAdapter.sendChunk(chunk, getLevel().getWorld().getHandle(), chunk.x(), chunk.z());
} }
} }
}; };

View File

@ -87,7 +87,6 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
private final Registry<Biome> biomeRegistry; private final Registry<Biome> biomeRegistry;
private final IdMap<Holder<Biome>> biomeHolderIdMap; private final IdMap<Holder<Biome>> biomeHolderIdMap;
private final ConcurrentHashMap<Integer, PaperweightGetBlocks_Copy> copies = new ConcurrentHashMap<>(); private final ConcurrentHashMap<Integer, PaperweightGetBlocks_Copy> copies = new ConcurrentHashMap<>();
private final Object sendLock = new Object();
private LevelChunkSection[] sections; private LevelChunkSection[] sections;
private LevelChunk levelChunk; private LevelChunk levelChunk;
private DataLayer[] blockLight; private DataLayer[] blockLight;
@ -771,9 +770,9 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) { for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) {
final CompoundTag nativeTag = entry.getValue(); final CompoundTag nativeTag = entry.getValue();
final BlockVector3 blockHash = entry.getKey(); final BlockVector3 blockHash = entry.getKey();
final int x = blockHash.getX() + bx; final int x = blockHash.x() + bx;
final int y = blockHash.getY(); final int y = blockHash.y();
final int z = blockHash.getZ() + bz; final int z = blockHash.z() + bz;
final BlockPos pos = new BlockPos(x, y, z); final BlockPos pos = new BlockPos(x, y, z);
synchronized (nmsWorld) { synchronized (nmsWorld) {
@ -808,7 +807,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
nmsChunk.setUnsaved(true); nmsChunk.setUnsaved(true);
// send to player // send to player
if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) { if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) {
this.send(finalMask, finalLightUpdate); this.send();
} }
if (finalizer != null) { if (finalizer != null) {
finalizer.run(); finalizer.run();
@ -904,10 +903,8 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
} }
@Override @Override
public void send(int mask, boolean lighting) { public void send() {
synchronized (sendLock) { PaperweightPlatformAdapter.sendChunk(this, serverLevel, chunkX, chunkZ);
PaperweightPlatformAdapter.sendChunk(serverLevel, chunkX, chunkZ, lighting);
}
} }
/** /**

View File

@ -26,6 +26,7 @@ import net.minecraft.core.Holder;
import net.minecraft.core.IdMap; import net.minecraft.core.IdMap;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ChunkHolder;
import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ChunkMap;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@ -332,7 +333,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void sendChunk(ServerLevel nmsWorld, int chunkX, int chunkZ, boolean lighting) { public static void sendChunk(Object chunk, ServerLevel nmsWorld, int chunkX, int chunkZ) {
ChunkHolder chunkHolder = getPlayerChunk(nmsWorld, chunkX, chunkZ); ChunkHolder chunkHolder = getPlayerChunk(nmsWorld, chunkX, chunkZ);
if (chunkHolder == null) { if (chunkHolder == null) {
return; return;
@ -353,17 +354,20 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
if (levelChunk == null) { if (levelChunk == null) {
return; return;
} }
TaskManager.taskManager().task(() -> { MinecraftServer.getServer().execute(() -> {
ClientboundLevelChunkWithLightPacket packet; ClientboundLevelChunkWithLightPacket packet;
if (PaperLib.isPaper()) { if (PaperLib.isPaper()) {
synchronized (chunk) {
packet = new ClientboundLevelChunkWithLightPacket( packet = new ClientboundLevelChunkWithLightPacket(
levelChunk, levelChunk,
nmsWorld.getChunkSource().getLightEngine(), nmsWorld.getChunkSource().getLightEngine(),
null, null,
null null,
// last false is to not bother with x-ray false // last false is to not bother with x-ray
); );
}
} else { } else {
synchronized (chunk) {
// deprecated on paper - deprecation suppressed // deprecated on paper - deprecation suppressed
packet = new ClientboundLevelChunkWithLightPacket( packet = new ClientboundLevelChunkWithLightPacket(
levelChunk, levelChunk,
@ -372,6 +376,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
null null
); );
} }
}
nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet)); nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet));
}); });
} }

View File

@ -67,7 +67,7 @@ public class PaperweightStarlightRelighter extends StarlightRelighter<ServerLeve
int x = pos.x; int x = pos.x;
int z = pos.z; int z = pos.z;
if (delay) { // we still need to send the block changes of that chunk if (delay) { // we still need to send the block changes of that chunk
PaperweightPlatformAdapter.sendChunk(serverLevel, x, z, false); PaperweightPlatformAdapter.sendChunk(pos, serverLevel, x, z);
} }
serverLevel.getChunkSource().removeTicketAtLevel(FAWE_TICKET, pos, LIGHT_LEVEL, Unit.INSTANCE); serverLevel.getChunkSource().removeTicketAtLevel(FAWE_TICKET, pos, LIGHT_LEVEL, Unit.INSTANCE);
} }

View File

@ -12,6 +12,6 @@ repositories {
dependencies { dependencies {
// url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.6-R0.1-SNAPSHOT/ // url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.20.6-R0.1-SNAPSHOT/
the<PaperweightUserDependenciesExtension>().paperDevBundle("1.20.6-R0.1-20240520.005421-60") the<PaperweightUserDependenciesExtension>().paperDevBundle("1.20.6-R0.1-20240604.210637-112")
compileOnly(libs.paperlib) compileOnly(libs.paperlib)
} }

View File

@ -291,12 +291,12 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
private static Block getBlockFromType(BlockType blockType) { private static Block getBlockFromType(BlockType blockType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse( return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(
blockType.getId())); blockType.id()));
} }
private static Item getItemFromType(ItemType itemType) { private static Item getItemFromType(ItemType itemType) {
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse( return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(
itemType.getId())); itemType.id()));
} }
@Override @Override
@ -470,7 +470,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
CraftWorld craftWorld = ((CraftWorld) location.getWorld()); CraftWorld craftWorld = ((CraftWorld) location.getWorld());
ServerLevel worldServer = craftWorld.getHandle(); ServerLevel worldServer = craftWorld.getHandle();
Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle()); Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());
if (createdEntity != null) { if (createdEntity != null) {
CompoundBinaryTag nativeTag = state.getNbt(); CompoundBinaryTag nativeTag = state.getNbt();
@ -577,7 +577,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
@Override @Override
public void sendFakeNBT(Player player, BlockVector3 pos, CompoundBinaryTag nbtData) { public void sendFakeNBT(Player player, BlockVector3 pos, CompoundBinaryTag nbtData) {
var structureBlock = new StructureBlockEntity( var structureBlock = new StructureBlockEntity(
new BlockPos(pos.getX(), pos.getY(), pos.getZ()), new BlockPos(pos.x(), pos.y(), pos.z()),
Blocks.STRUCTURE_BLOCK.defaultBlockState() Blocks.STRUCTURE_BLOCK.defaultBlockState()
); );
structureBlock.setLevel(((CraftPlayer) player).getHandle().level()); structureBlock.setLevel(((CraftPlayer) player).getHandle().level());
@ -598,7 +598,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) { public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
final RegistryAccess.Frozen registryAccess = DedicatedServer.getServer().registryAccess(); final RegistryAccess.Frozen registryAccess = DedicatedServer.getServer().registryAccess();
ItemStack stack = new ItemStack( ItemStack stack = new ItemStack(
registryAccess.registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())), registryAccess.registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
item.getAmount() item.getAmount()
); );
final CompoundTag nbt = (net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData()); final CompoundTag nbt = (net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData());
@ -644,11 +644,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
return false; return false;
} }
fakePlayer.setItemInHand(InteractionHand.MAIN_HAND, stack); fakePlayer.setItemInHand(InteractionHand.MAIN_HAND, stack);
fakePlayer.absMoveTo(position.getX(), position.getY(), position.getZ(), fakePlayer.absMoveTo(position.x(), position.y(), position.z(),
(float) face.toVector().toYaw(), (float) face.toVector().toPitch() (float) face.toVector().toYaw(), (float) face.toVector().toPitch()
); );
final BlockPos blockPos = new BlockPos(position.getX(), position.getY(), position.getZ()); final BlockPos blockPos = new BlockPos(position.x(), position.y(), position.z());
final Vec3 blockVec = Vec3.atLowerCornerOf(blockPos); final Vec3 blockVec = Vec3.atLowerCornerOf(blockPos);
final net.minecraft.core.Direction enumFacing = adapt(face); final net.minecraft.core.Direction enumFacing = adapt(face);
BlockHitResult rayTrace = new BlockHitResult(blockVec, enumFacing, blockPos, false); BlockHitResult rayTrace = new BlockHitResult(blockVec, enumFacing, blockPos, false);
@ -674,7 +674,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
net.minecraft.world.level.block.state.BlockState blockData = Block.stateById(internalId); net.minecraft.world.level.block.state.BlockState blockData = Block.stateById(internalId);
return blockData.canSurvive( return blockData.canSurvive(
((CraftWorld) world).getHandle(), ((CraftWorld) world).getHandle(),
new BlockPos(position.getX(), position.getY(), position.getZ()) new BlockPos(position.x(), position.y(), position.z())
); );
} }
@ -802,7 +802,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
} }
for (BlockVector3 vec : region) { for (BlockVector3 vec : region) {
BlockPos pos = new BlockPos(vec.getBlockX(), vec.getBlockY(), vec.getBlockZ()); BlockPos pos = new BlockPos(vec.x(), vec.y(), vec.z());
ChunkAccess chunk = chunks.get(new ChunkPos(pos)); ChunkAccess chunk = chunks.get(new ChunkPos(pos));
final net.minecraft.world.level.block.state.BlockState blockData = chunk.getBlockState(pos); final net.minecraft.world.level.block.state.BlockState blockData = chunk.getBlockState(pos);
int internalId = Block.getId(blockData); int internalId = Block.getId(blockData);
@ -815,7 +815,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
} }
extent.setBlock(vec, state.toBaseBlock()); extent.setBlock(vec, state.toBaseBlock());
if (options.shouldRegenBiomes()) { if (options.shouldRegenBiomes()) {
Biome origBiome = chunk.getNoiseBiome(vec.getX(), vec.getY(), vec.getZ()).value(); Biome origBiome = chunk.getNoiseBiome(vec.x(), vec.y(), vec.z()).value();
BiomeType adaptedBiome = adapt(serverWorld, origBiome); BiomeType adaptedBiome = adapt(serverWorld, origBiome);
if (adaptedBiome != null) { if (adaptedBiome != null) {
extent.setBiome(vec, adaptedBiome); extent.setBiome(vec, adaptedBiome);
@ -834,7 +834,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
//noinspection unchecked //noinspection unchecked
chunkLoadings.add( chunkLoadings.add(
((CompletableFuture<ChunkResult<ChunkAccess>>) ((CompletableFuture<ChunkResult<ChunkAccess>>)
getChunkFutureMethod.invoke(chunkManager, chunk.getX(), chunk.getZ(), ChunkStatus.FEATURES, true)) getChunkFutureMethod.invoke(chunkManager, chunk.x(), chunk.z(), ChunkStatus.FEATURES, true))
.thenApply(either -> either.orElse(null)) .thenApply(either -> either.orElse(null))
); );
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
@ -874,7 +874,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
public boolean clearContainerBlockContents(org.bukkit.World world, BlockVector3 pt) { public boolean clearContainerBlockContents(org.bukkit.World world, BlockVector3 pt) {
ServerLevel originalWorld = ((CraftWorld) world).getHandle(); ServerLevel originalWorld = ((CraftWorld) world).getHandle();
BlockEntity entity = originalWorld.getBlockEntity(new BlockPos(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ())); BlockEntity entity = originalWorld.getBlockEntity(new BlockPos(pt.x(), pt.y(), pt.z()));
if (entity instanceof Clearable) { if (entity instanceof Clearable) {
((Clearable) entity).clearContent(); ((Clearable) entity).clearContent();
return true; return true;

View File

@ -484,7 +484,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
net.minecraft.world.level.block.state.BlockState blockState1 = Block.stateById(internalId); net.minecraft.world.level.block.state.BlockState blockState1 = Block.stateById(internalId);
return blockState1.hasPostProcess( return blockState1.hasPostProcess(
getServerLevel(world), getServerLevel(world),
new BlockPos(blockVector3.getX(), blockVector3.getY(), blockVector3.getZ()) new BlockPos(blockVector3.x(), blockVector3.y(), blockVector3.z())
); );
} }
@ -492,7 +492,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) { public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
final RegistryAccess.Frozen registryAccess = DedicatedServer.getServer().registryAccess(); final RegistryAccess.Frozen registryAccess = DedicatedServer.getServer().registryAccess();
ItemStack stack = new ItemStack( ItemStack stack = new ItemStack(
registryAccess.registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(baseItemStack.getType().getId())), registryAccess.registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(baseItemStack.getType().id())),
baseItemStack.getAmount() baseItemStack.getAmount()
); );
final CompoundTag nbt = (net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData()); final CompoundTag nbt = (net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData());
@ -572,7 +572,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
.getServer() .getServer()
.registryAccess() .registryAccess()
.registryOrThrow(BIOME); .registryOrThrow(BIOME);
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId()); ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
Biome biome = registry.get(resourceLocation); Biome biome = registry.get(resourceLocation);
return registry.getId(biome); return registry.getId(biome);
} }

View File

@ -247,7 +247,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
return; return;
} }
for (IntPair chunk : toSend) { for (IntPair chunk : toSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false); PaperweightPlatformAdapter.sendChunk(chunk, getLevel().getWorld().getHandle(), chunk.x(), chunk.z());
} }
} }
}; };
@ -263,7 +263,7 @@ public class PaperweightFaweWorldNativeAccess implements WorldNativeAccess<Level
sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE) sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE)
)); ));
for (IntPair chunk : cachedChunksToSend) { for (IntPair chunk : cachedChunksToSend) {
PaperweightPlatformAdapter.sendChunk(getLevel().getWorld().getHandle(), chunk.x(), chunk.z(), false); PaperweightPlatformAdapter.sendChunk(chunk, getLevel().getWorld().getHandle(), chunk.x(), chunk.z());
} }
} }
}; };

View File

@ -773,9 +773,9 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) { for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) {
final CompoundTag nativeTag = entry.getValue(); final CompoundTag nativeTag = entry.getValue();
final BlockVector3 blockHash = entry.getKey(); final BlockVector3 blockHash = entry.getKey();
final int x = blockHash.getX() + bx; final int x = blockHash.x() + bx;
final int y = blockHash.getY(); final int y = blockHash.y();
final int z = blockHash.getZ() + bz; final int z = blockHash.z() + bz;
final BlockPos pos = new BlockPos(x, y, z); final BlockPos pos = new BlockPos(x, y, z);
synchronized (nmsWorld) { synchronized (nmsWorld) {
@ -810,7 +810,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
nmsChunk.setUnsaved(true); nmsChunk.setUnsaved(true);
// send to player // send to player
if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) { if (Settings.settings().LIGHTING.MODE == 0 || !Settings.settings().LIGHTING.DELAY_PACKET_SENDING) {
this.send(finalMask, finalLightUpdate); this.send();
} }
if (finalizer != null) { if (finalizer != null) {
finalizer.run(); finalizer.run();
@ -906,9 +906,9 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc
} }
@Override @Override
public void send(int mask, boolean lighting) { public void send() {
synchronized (sendLock) { synchronized (sendLock) {
PaperweightPlatformAdapter.sendChunk(serverLevel, chunkX, chunkZ, lighting); PaperweightPlatformAdapter.sendChunk(this, serverLevel, chunkX, chunkZ);
} }
} }

View File

@ -26,6 +26,7 @@ import net.minecraft.core.Holder;
import net.minecraft.core.IdMap; import net.minecraft.core.IdMap;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ChunkHolder;
import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ChunkMap;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@ -332,7 +333,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void sendChunk(ServerLevel nmsWorld, int chunkX, int chunkZ, boolean lighting) { public static void sendChunk(Object chunk, ServerLevel nmsWorld, int chunkX, int chunkZ) {
ChunkHolder chunkHolder = getPlayerChunk(nmsWorld, chunkX, chunkZ); ChunkHolder chunkHolder = getPlayerChunk(nmsWorld, chunkX, chunkZ);
if (chunkHolder == null) { if (chunkHolder == null) {
return; return;
@ -345,25 +346,26 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
.getChunkSource() .getChunkSource()
.getChunkAtIfLoadedImmediately(chunkX, chunkZ); .getChunkAtIfLoadedImmediately(chunkX, chunkZ);
} else { } else {
levelChunk = ((Optional<LevelChunk>) ((Either) chunkHolder levelChunk = chunkHolder.getTickingChunkFuture()
.getTickingChunkFuture() // method is not present with new paper chunk system .getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK).orElse(null);
.getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK)).left())
.orElse(null);
} }
if (levelChunk == null) { if (levelChunk == null) {
return; return;
} }
TaskManager.taskManager().task(() -> { MinecraftServer.getServer().execute(() -> {
ClientboundLevelChunkWithLightPacket packet; ClientboundLevelChunkWithLightPacket packet;
if (PaperLib.isPaper()) { if (PaperLib.isPaper()) {
synchronized (chunk) {
packet = new ClientboundLevelChunkWithLightPacket( packet = new ClientboundLevelChunkWithLightPacket(
levelChunk, levelChunk,
nmsWorld.getChunkSource().getLightEngine(), nmsWorld.getChunkSource().getLightEngine(),
null, null,
null null,
// last false is to not bother with x-ray false // last false is to not bother with x-ray
); );
}
} else { } else {
synchronized (chunk) {
// deprecated on paper - deprecation suppressed // deprecated on paper - deprecation suppressed
packet = new ClientboundLevelChunkWithLightPacket( packet = new ClientboundLevelChunkWithLightPacket(
levelChunk, levelChunk,
@ -372,6 +374,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
null null
); );
} }
}
nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet)); nearbyPlayers(nmsWorld, coordIntPair).forEach(p -> p.connection.send(packet));
}); });
} }

View File

@ -67,7 +67,7 @@ public class PaperweightStarlightRelighter extends StarlightRelighter<ServerLeve
int x = pos.x; int x = pos.x;
int z = pos.z; int z = pos.z;
if (delay) { // we still need to send the block changes of that chunk if (delay) { // we still need to send the block changes of that chunk
PaperweightPlatformAdapter.sendChunk(serverLevel, x, z, false); PaperweightPlatformAdapter.sendChunk(pos, serverLevel, x, z);
} }
serverLevel.getChunkSource().removeTicketAtLevel(FAWE_TICKET, pos, LIGHT_LEVEL, Unit.INSTANCE); serverLevel.getChunkSource().removeTicketAtLevel(FAWE_TICKET, pos, LIGHT_LEVEL, Unit.INSTANCE);
} }

View File

@ -2,6 +2,6 @@ package com.fastasyncworldedit.bukkit.adapter;
public interface BukkitGetBlocks { public interface BukkitGetBlocks {
void send(int mask, boolean lighting); void send();
} }

View File

@ -99,7 +99,7 @@ public interface IBukkitAdapter {
checkNotNull(position); checkNotNull(position);
return new org.bukkit.Location( return new org.bukkit.Location(
world, world,
position.getX(), position.getY(), position.getZ() position.x(), position.y(), position.z()
); );
} }
@ -119,7 +119,7 @@ public interface IBukkitAdapter {
checkNotNull(location); checkNotNull(location);
return new org.bukkit.Location( return new org.bukkit.Location(
world, world,
location.getX(), location.getY(), location.getZ(), location.x(), location.y(), location.z(),
location.getYaw(), location.getYaw(),
location.getPitch() location.getPitch()
); );
@ -166,10 +166,10 @@ public interface IBukkitAdapter {
*/ */
default Material adapt(ItemType itemType) { default Material adapt(ItemType itemType) {
checkNotNull(itemType); checkNotNull(itemType);
if (!itemType.getId().startsWith("minecraft:")) { if (!itemType.id().startsWith("minecraft:")) {
throw new IllegalArgumentException("Bukkit only supports Minecraft items"); throw new IllegalArgumentException("Bukkit only supports Minecraft items");
} }
return Material.getMaterial(itemType.getId().substring(10).toUpperCase(Locale.ROOT)); return Material.getMaterial(itemType.id().substring(10).toUpperCase(Locale.ROOT));
} }
/** /**
@ -180,10 +180,10 @@ public interface IBukkitAdapter {
*/ */
default Material adapt(BlockType blockType) { default Material adapt(BlockType blockType) {
checkNotNull(blockType); checkNotNull(blockType);
if (!blockType.getId().startsWith("minecraft:")) { if (!blockType.id().startsWith("minecraft:")) {
throw new IllegalArgumentException("Bukkit only supports Minecraft blocks"); throw new IllegalArgumentException("Bukkit only supports Minecraft blocks");
} }
String id = blockType.getId().substring(10).toUpperCase(Locale.ROOT); String id = blockType.id().substring(10).toUpperCase(Locale.ROOT);
return Material.getMaterial(id); return Material.getMaterial(id);
} }
@ -293,11 +293,11 @@ public interface IBukkitAdapter {
} }
default Biome adapt(BiomeType biomeType) { default Biome adapt(BiomeType biomeType) {
if (!biomeType.getId().startsWith("minecraft:")) { if (!biomeType.id().startsWith("minecraft:")) {
throw new IllegalArgumentException("Bukkit only supports vanilla biomes"); throw new IllegalArgumentException("Bukkit only supports vanilla biomes");
} }
try { try {
return Biome.valueOf(biomeType.getId().substring(10).toUpperCase(Locale.ROOT)); return Biome.valueOf(biomeType.id().substring(10).toUpperCase(Locale.ROOT));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return null; return null;
} }

View File

@ -137,7 +137,7 @@ public class NMSAdapter implements FAWEPlatformAdapterImpl {
if (!(chunk instanceof BukkitGetBlocks)) { if (!(chunk instanceof BukkitGetBlocks)) {
throw new IllegalArgumentException("(IChunkGet) chunk not of type BukkitGetBlocks"); throw new IllegalArgumentException("(IChunkGet) chunk not of type BukkitGetBlocks");
} }
((BukkitGetBlocks) chunk).send(mask, lighting); ((BukkitGetBlocks) chunk).send();
} }
} }

View File

@ -354,7 +354,7 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
@Override @Override
public boolean apply(final Extent extent, final BlockVector3 get, final BlockVector3 set) throws WorldEditException { public boolean apply(final Extent extent, final BlockVector3 get, final BlockVector3 set) throws WorldEditException {
return extent.setBlock(set.getX(), set.getY(), set.getZ(), source.getFullBlock(get.getX(), get.getY(), get.getZ())); return extent.setBlock(set.x(), set.y(), set.z(), source.getFullBlock(get.x(), get.y(), get.z()));
} }
} }
@ -374,8 +374,8 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
@Override @Override
public boolean apply(final Extent extent, final BlockVector3 get, final BlockVector3 set) throws WorldEditException { public boolean apply(final Extent extent, final BlockVector3 get, final BlockVector3 set) throws WorldEditException {
return extent.setBlock(set.getX(), set.getY(), set.getZ(), source.getFullBlock(get.getX(), get.getY(), get.getZ())) return extent.setBlock(set.x(), set.y(), set.z(), source.getFullBlock(get.x(), get.y(), get.z()))
&& extent.setBiome(set.getX(), set.getY(), set.getZ(), biomeGetter.apply(get)); && extent.setBiome(set.x(), set.y(), set.z(), biomeGetter.apply(get));
} }
} }
@ -468,22 +468,22 @@ public abstract class Regenerator<IChunkAccess, ProtoChunk extends IChunkAccess,
private long[] getChunkCoordsRegen(Region region, int border) { //needs to be square num of chunks private long[] getChunkCoordsRegen(Region region, int border) { //needs to be square num of chunks
BlockVector3 oldMin = region.getMinimumPoint(); BlockVector3 oldMin = region.getMinimumPoint();
BlockVector3 newMin = BlockVector3.at( BlockVector3 newMin = BlockVector3.at(
(oldMin.getX() >> 4 << 4) - border * 16, (oldMin.x() >> 4 << 4) - border * 16,
oldMin.getY(), oldMin.y(),
(oldMin.getZ() >> 4 << 4) - border * 16 (oldMin.z() >> 4 << 4) - border * 16
); );
BlockVector3 oldMax = region.getMaximumPoint(); BlockVector3 oldMax = region.getMaximumPoint();
BlockVector3 newMax = BlockVector3.at( BlockVector3 newMax = BlockVector3.at(
(oldMax.getX() >> 4 << 4) + (border + 1) * 16 - 1, (oldMax.x() >> 4 << 4) + (border + 1) * 16 - 1,
oldMax.getY(), oldMax.y(),
(oldMax.getZ() >> 4 << 4) + (border + 1) * 16 - 1 (oldMax.z() >> 4 << 4) + (border + 1) * 16 - 1
); );
Region adjustedRegion = new CuboidRegion(newMin, newMax); Region adjustedRegion = new CuboidRegion(newMin, newMax);
return adjustedRegion.getChunks().stream() return adjustedRegion.getChunks().stream()
.sorted(Comparator .sorted(Comparator
.comparingInt(BlockVector2::getZ) .comparingInt(BlockVector2::z)
.thenComparingInt(BlockVector2::getX)) //needed for RegionLimitedWorldAccess .thenComparingInt(BlockVector2::x)) //needed for RegionLimitedWorldAccess
.mapToLong(c -> MathMan.pairInt(c.getX(), c.getZ())) .mapToLong(c -> MathMan.pairInt(c.x(), c.z()))
.toArray(); .toArray();
} }

View File

@ -56,7 +56,7 @@ public class WorldGuardFeature extends BukkitMaskManager implements Listener {
if (region instanceof ProtectedPolygonalRegion casted) { if (region instanceof ProtectedPolygonalRegion casted) {
BlockVector3 max = region.getMaximumPoint(); BlockVector3 max = region.getMaximumPoint();
BlockVector3 min = region.getMinimumPoint(); BlockVector3 min = region.getMinimumPoint();
return new Polygonal2DRegion(null, casted.getPoints(), min.getBlockY(), max.getBlockY()); return new Polygonal2DRegion(null, casted.getPoints(), min.y(), max.y());
} }
return new AdaptedRegion(region); return new AdaptedRegion(region);
} }

View File

@ -94,15 +94,15 @@ public class FaweDelegateSchematicHandler {
return; return;
} }
BlockVector3 dimension = schematic.getClipboard().getDimensions(); BlockVector3 dimension = schematic.getClipboard().getDimensions();
final int WIDTH = dimension.getX(); final int WIDTH = dimension.x();
final int LENGTH = dimension.getZ(); final int LENGTH = dimension.z();
final int HEIGHT = dimension.getY(); final int HEIGHT = dimension.y();
final int worldHeight = plot.getArea().getMaxGenHeight() - plot.getArea().getMinGenHeight() + 1; final int worldHeight = plot.getArea().getMaxGenHeight() - plot.getArea().getMinGenHeight() + 1;
// Validate dimensions // Validate dimensions
CuboidRegion region = plot.getLargestRegion(); CuboidRegion region = plot.getLargestRegion();
boolean sizeMismatch = boolean sizeMismatch =
((region.getMaximumPoint().getX() - region.getMinimumPoint().getX() + xOffset + 1) < WIDTH) || ( ((region.getMaximumPoint().x() - region.getMinimumPoint().x() + xOffset + 1) < WIDTH) || (
(region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ() + zOffset + 1) < LENGTH) || (HEIGHT (region.getMaximumPoint().z() - region.getMinimumPoint().z() + zOffset + 1) < LENGTH) || (HEIGHT
> worldHeight); > worldHeight);
if (!Settings.Schematics.PASTE_MISMATCHES && sizeMismatch) { if (!Settings.Schematics.PASTE_MISMATCHES && sizeMismatch) {
if (actor != null) { if (actor != null) {
@ -111,8 +111,8 @@ public class FaweDelegateSchematicHandler {
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
return; return;
} }
if (((region.getMaximumPoint().getX() - region.getMinimumPoint().getX() + xOffset + 1) < WIDTH) || ( if (((region.getMaximumPoint().x() - region.getMinimumPoint().x() + xOffset + 1) < WIDTH) || (
(region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ() + zOffset + 1) < LENGTH) || (HEIGHT (region.getMaximumPoint().z() - region.getMinimumPoint().z() + zOffset + 1) < LENGTH) || (HEIGHT
> worldHeight)) { > worldHeight)) {
if (whenDone != null) { if (whenDone != null) {
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
@ -141,7 +141,7 @@ public class FaweDelegateSchematicHandler {
} else { } else {
y_offset_actual = yOffset + pw.getMinBuildHeight() + editSession.getHighestTerrainBlock(region y_offset_actual = yOffset + pw.getMinBuildHeight() + editSession.getHighestTerrainBlock(region
.getMinimumPoint() .getMinimumPoint()
.getX() + 1, region.getMinimumPoint().getZ() + 1, pw.getMinGenHeight(), pw.getMaxGenHeight() .x() + 1, region.getMinimumPoint().z() + 1, pw.getMinGenHeight(), pw.getMaxGenHeight()
); );
} }
} }
@ -150,7 +150,7 @@ public class FaweDelegateSchematicHandler {
} }
final BlockVector3 to = BlockVector3 final BlockVector3 to = BlockVector3
.at(region.getMinimumPoint().getX() + xOffset, y_offset_actual, region.getMinimumPoint().getZ() + zOffset); .at(region.getMinimumPoint().x() + xOffset, y_offset_actual, region.getMinimumPoint().z() + zOffset);
final Clipboard clipboard = schematic.getClipboard(); final Clipboard clipboard = schematic.getClipboard();
clipboard.setOrigin(clipboard.getRegion().getMinimumPoint()); clipboard.setOrigin(clipboard.getRegion().getMinimumPoint());
clipboard.paste(editSession, to, true, false, true); clipboard.paste(editSession, to, true, false, true);

View File

@ -1,6 +1,5 @@
package com.fastasyncworldedit.bukkit.regions.plotsquared; package com.fastasyncworldedit.bukkit.regions.plotsquared;
import com.fastasyncworldedit.core.FaweAPI;
import com.fastasyncworldedit.core.configuration.Caption; import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.regions.FaweMask; import com.fastasyncworldedit.core.regions.FaweMask;
import com.fastasyncworldedit.core.regions.FaweMaskManager; import com.fastasyncworldedit.core.regions.FaweMaskManager;
@ -159,8 +158,8 @@ public class PlotSquaredFeature extends FaweMaskManager {
regions = WEManager.getMask(pp); regions = WEManager.getMask(pp);
if (regions.size() == 1) { if (regions.size() == 1) {
CuboidRegion region = regions.iterator().next(); CuboidRegion region = regions.iterator().next();
if (region.getMinimumPoint().getX() == Integer.MIN_VALUE if (region.getMinimumPoint().x() == Integer.MIN_VALUE
&& region.getMaximumPoint().getX() == Integer.MAX_VALUE) { && region.getMaximumPoint().x() == Integer.MAX_VALUE) {
regions.clear(); regions.clear();
} }
} }
@ -174,22 +173,21 @@ public class PlotSquaredFeature extends FaweMaskManager {
return null; return null;
} }
Region maskedRegion;
if (regions.size() == 1) {
final World world = player.getWorld(); final World world = player.getWorld();
int min = area != null ? area.getMinBuildHeight() : world.getMinY(); int min = area != null ? area.getMinBuildHeight() : world.getMinY();
// PlotSquared uses exclusive max height, WorldEdit uses inclusive max height -> subtract 1 // PlotSquared uses exclusive max height, WorldEdit uses inclusive max height -> subtract 1
int max = area != null ? Math.min(world.getMaxY(), area.getMaxBuildHeight() - 1) : world.getMaxY(); int max = area != null ? Math.min(world.getMaxY(), area.getMaxBuildHeight() - 1) : world.getMaxY();
Region maskedRegion;
if (regions.size() == 1) {
final CuboidRegion region = regions.iterator().next(); final CuboidRegion region = regions.iterator().next();
final BlockVector3 pos1 = BlockVector3.at(region.getMinimumX(), min, region.getMinimumZ()); final BlockVector3 pos1 = BlockVector3.at(region.getMinimumX(), min, region.getMinimumZ());
final BlockVector3 pos2 = BlockVector3.at(region.getMaximumX(), max, region.getMaximumZ()); final BlockVector3 pos2 = BlockVector3.at(region.getMaximumX(), max, region.getMaximumZ());
maskedRegion = new CuboidRegion(pos1, pos2); maskedRegion = new CuboidRegion(pos1, pos2);
} else { } else {
World world = FaweAPI.getWorld(area.getWorldName());
List<Region> weRegions = regions.stream().map( List<Region> weRegions = regions.stream().map(
r -> new CuboidRegion(world, BlockVector3.at(r.getMinimumX(), r.getMinimumY(), r.getMinimumZ()), r -> new CuboidRegion(world, BlockVector3.at(r.getMinimumX(), min, r.getMinimumZ()),
BlockVector3.at(r.getMaximumX(), r.getMaximumY(), r.getMaximumZ()) BlockVector3.at(r.getMaximumX(), max, r.getMaximumZ())
)).collect(Collectors.toList()); )).collect(Collectors.toList());
maskedRegion = new RegionIntersection(world, weRegions); maskedRegion = new RegionIntersection(world, weRegions);
} }

View File

@ -240,7 +240,7 @@ public enum BukkitAdapter {
Vector3 position = location; Vector3 position = location;
return new org.bukkit.Location( return new org.bukkit.Location(
adapt((World) location.getExtent()), adapt((World) location.getExtent()),
position.getX(), position.getY(), position.getZ(), position.x(), position.y(), position.z(),
location.getYaw(), location.getYaw(),
location.getPitch() location.getPitch()
); );
@ -258,7 +258,7 @@ public enum BukkitAdapter {
checkNotNull(position); checkNotNull(position);
return new org.bukkit.Location( return new org.bukkit.Location(
world, world,
position.getX(), position.getY(), position.getZ() position.x(), position.y(), position.z()
); );
} }
@ -274,7 +274,7 @@ public enum BukkitAdapter {
checkNotNull(position); checkNotNull(position);
return new org.bukkit.Location( return new org.bukkit.Location(
world, world,
position.getX(), position.getY(), position.getZ() position.x(), position.y(), position.z()
); );
} }
@ -290,7 +290,7 @@ public enum BukkitAdapter {
checkNotNull(location); checkNotNull(location);
return new org.bukkit.Location( return new org.bukkit.Location(
world, world,
location.getX(), location.getY(), location.getZ(), location.x(), location.y(), location.z(),
location.getYaw(), location.getYaw(),
location.getPitch() location.getPitch()
); );

View File

@ -40,7 +40,7 @@ class BukkitBiomeRegistry implements BiomeRegistry {
@Override @Override
public Component getRichName(BiomeType biomeType) { public Component getRichName(BiomeType biomeType) {
return TranslatableComponent.of( return TranslatableComponent.of(
TranslationManager.makeTranslationKey("biome", biomeType.getId()) TranslationManager.makeTranslationKey("biome", biomeType.id())
); );
} }

View File

@ -162,7 +162,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
final PlayerInventory inv = player.getInventory(); final PlayerInventory inv = player.getInventory();
ItemStack newItem = BukkitAdapter.adapt(itemStack); ItemStack newItem = BukkitAdapter.adapt(itemStack);
TaskManager.taskManager().sync(() -> { TaskManager.taskManager().sync(() -> {
if (itemStack.getType().getId().equalsIgnoreCase(WorldEdit.getInstance().getConfiguration().wandItem)) { if (itemStack.getType().id().equalsIgnoreCase(WorldEdit.getInstance().getConfiguration().wandItem)) {
inv.remove(newItem); inv.remove(newItem);
} }
final ItemStack item = player.getInventory().getItemInMainHand(); final ItemStack item = player.getInventory().getItemInMainHand();
@ -242,9 +242,9 @@ public class BukkitPlayer extends AbstractPlayerActor {
//FAWE end //FAWE end
return TaskManager.taskManager().sync(() -> player.teleport(new Location( return TaskManager.taskManager().sync(() -> player.teleport(new Location(
finalWorld, finalWorld,
pos.getX(), pos.x(),
pos.getY(), pos.y(),
pos.getZ(), pos.z(),
yaw, yaw,
pitch pitch
))); )));
@ -267,7 +267,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
@Override @Override
public void setGameMode(GameMode gameMode) { public void setGameMode(GameMode gameMode) {
player.setGameMode(org.bukkit.GameMode.valueOf(gameMode.getId().toUpperCase(Locale.ROOT))); player.setGameMode(org.bukkit.GameMode.valueOf(gameMode.id().toUpperCase(Locale.ROOT)));
} }
@Override @Override
@ -422,7 +422,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
@Override @Override
public <B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, B block) { public <B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, B block) {
Location loc = new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ()); Location loc = new Location(player.getWorld(), pos.x(), pos.y(), pos.z());
if (block == null) { if (block == null) {
player.sendBlockChange(loc, player.getWorld().getBlockAt(loc).getBlockData()); player.sendBlockChange(loc, player.getWorld().getBlockAt(loc).getBlockData());
} else { } else {

View File

@ -192,6 +192,9 @@ public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag
@Override @Override
public BaseItem getItem(int slot) { public BaseItem getItem(int slot) {
loadInventory(); loadInventory();
if (items[slot] == null) {
return null;
}
return BukkitAdapter.adapt(items[slot]); return BukkitAdapter.adapt(items[slot]);
} }

View File

@ -230,7 +230,7 @@ public class BukkitServerInterface extends AbstractPlatform implements MultiUser
//FAWE start //FAWE start
@Override @Override
public String getId() { public String id() {
return "intellectualsites:bukkit"; return "intellectualsites:bukkit";
} }
//FAWE end //FAWE end

View File

@ -224,7 +224,7 @@ public class BukkitWorld extends AbstractWorld {
//FAWE end //FAWE end
@Override @Override
public String getId() { public String id() {
return getWorld().getName().replace(" ", "_").toLowerCase(Locale.ROOT); return getWorld().getName().replace(" ", "_").toLowerCase(Locale.ROOT);
} }
@ -247,7 +247,7 @@ public class BukkitWorld extends AbstractWorld {
//FAWE start - safe edit region //FAWE start - safe edit region
testCoords(pt); testCoords(pt);
//FAWE end //FAWE end
return getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getLightLevel(); return getWorld().getBlockAt(pt.x(), pt.y(), pt.z()).getLightLevel();
} }
@Override @Override
@ -284,7 +284,7 @@ public class BukkitWorld extends AbstractWorld {
return false; return false;
} }
Block block = getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); Block block = getWorld().getBlockAt(pt.x(), pt.y(), pt.z());
BlockState state = PaperLib.getBlockState(block, false).getState(); BlockState state = PaperLib.getBlockState(block, false).getState();
if (!(state instanceof InventoryHolder)) { if (!(state instanceof InventoryHolder)) {
return false; return false;
@ -363,8 +363,8 @@ public class BukkitWorld extends AbstractWorld {
//FAWE end //FAWE end
World world = getWorld(); World world = getWorld();
//FAWE start //FAWE start
int X = pt.getBlockX() >> 4; int X = pt.x() >> 4;
int Z = pt.getBlockZ() >> 4; int Z = pt.z() >> 4;
if (Fawe.isMainThread()) { if (Fawe.isMainThread()) {
world.getChunkAt(X, Z); world.getChunkAt(X, Z);
} else if (PaperLib.isPaper()) { } else if (PaperLib.isPaper()) {
@ -413,7 +413,7 @@ public class BukkitWorld extends AbstractWorld {
public void fixAfterFastMode(Iterable<BlockVector2> chunks) { public void fixAfterFastMode(Iterable<BlockVector2> chunks) {
World world = getWorld(); World world = getWorld();
for (BlockVector2 chunkPos : chunks) { for (BlockVector2 chunkPos : chunks) {
world.refreshChunk(chunkPos.getBlockX(), chunkPos.getBlockZ()); world.refreshChunk(chunkPos.x(), chunkPos.z());
} }
} }
@ -495,13 +495,13 @@ public class BukkitWorld extends AbstractWorld {
//FAWE start - safe edit region //FAWE start - safe edit region
testCoords(pt); testCoords(pt);
//FAWE end //FAWE end
getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).breakNaturally(); getWorld().getBlockAt(pt.x(), pt.y(), pt.z()).breakNaturally();
} }
//FAWE start //FAWE start
@Override @Override
public Collection<BaseItemStack> getBlockDrops(BlockVector3 position) { public Collection<BaseItemStack> getBlockDrops(BlockVector3 position) {
return getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ()).getDrops().stream() return getWorld().getBlockAt(position.x(), position.y(), position.z()).getDrops().stream()
.map(BukkitAdapter::adapt).collect(Collectors.toList()); .map(BukkitAdapter::adapt).collect(Collectors.toList());
} }
//FAWE end //FAWE end
@ -538,7 +538,7 @@ public class BukkitWorld extends AbstractWorld {
} }
} }
if (WorldEditPlugin.getInstance().getLocalConfiguration().unsupportedVersionEditing) { if (WorldEditPlugin.getInstance().getLocalConfiguration().unsupportedVersionEditing) {
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ()); Block bukkitBlock = getWorld().getBlockAt(position.x(), position.y(), position.z());
return BukkitAdapter.adapt(bukkitBlock.getBlockData()); return BukkitAdapter.adapt(bukkitBlock.getBlockData());
} else { } else {
throw new RuntimeException(new UnsupportedVersionEditException()); throw new RuntimeException(new UnsupportedVersionEditException());
@ -562,7 +562,7 @@ public class BukkitWorld extends AbstractWorld {
} }
} }
} }
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ()); Block bukkitBlock = getWorld().getBlockAt(position.x(), position.y(), position.z());
bukkitBlock.setBlockData(BukkitAdapter.adapt(block), sideEffects.doesApplyAny()); bukkitBlock.setBlockData(BukkitAdapter.adapt(block), sideEffects.doesApplyAny());
return true; return true;
} }
@ -584,8 +584,8 @@ public class BukkitWorld extends AbstractWorld {
if (!Settings.settings().REGION_RESTRICTIONS_OPTIONS.RESTRICT_TO_SAFE_RANGE) { if (!Settings.settings().REGION_RESTRICTIONS_OPTIONS.RESTRICT_TO_SAFE_RANGE) {
return; return;
} }
int x = position.getX(); int x = position.x();
int z = position.getZ(); int z = position.z();
if (x > 30000000 || z > 30000000 || x < -30000000 || z < -30000000) { if (x > 30000000 || z > 30000000 || x < -30000000 || z < -30000000) {
throw FaweCache.OUTSIDE_SAFE_REGION; throw FaweCache.OUTSIDE_SAFE_REGION;
} }
@ -636,9 +636,9 @@ public class BukkitWorld extends AbstractWorld {
testCoords(position); testCoords(position);
//FAWE end //FAWE end
if (HAS_3D_BIOMES) { if (HAS_3D_BIOMES) {
return BukkitAdapter.adapt(getWorld().getBiome(position.getBlockX(), position.getBlockY(), position.getBlockZ())); return BukkitAdapter.adapt(getWorld().getBiome(position.x(), position.y(), position.z()));
} else { } else {
return BukkitAdapter.adapt(getWorld().getBiome(position.getBlockX(), position.getBlockZ())); return BukkitAdapter.adapt(getWorld().getBiome(position.x(), position.z()));
} }
} }
@ -649,9 +649,9 @@ public class BukkitWorld extends AbstractWorld {
testCoords(position); testCoords(position);
//FAWE end //FAWE end
if (HAS_3D_BIOMES) { if (HAS_3D_BIOMES) {
getWorld().setBiome(position.getBlockX(), position.getBlockY(), position.getBlockZ(), BukkitAdapter.adapt(biome)); getWorld().setBiome(position.x(), position.y(), position.z(), BukkitAdapter.adapt(biome));
} else { } else {
getWorld().setBiome(position.getBlockX(), position.getBlockZ(), BukkitAdapter.adapt(biome)); getWorld().setBiome(position.x(), position.z(), BukkitAdapter.adapt(biome));
} }
return true; return true;
} }

View File

@ -120,7 +120,6 @@ public class WorldEditPlugin extends JavaPlugin {
public void onLoad() { public void onLoad() {
//FAWE start //FAWE start
this.bukkitConsoleCommandSender = new BukkitCommandSender(this, Bukkit.getConsoleSender());
// This is already covered by Spigot, however, a more pesky warning with a proper explanation over "Ambiguous plugin name..." can't hurt. // This is already covered by Spigot, however, a more pesky warning with a proper explanation over "Ambiguous plugin name..." can't hurt.
Plugin[] plugins = Bukkit.getServer().getPluginManager().getPlugins(); Plugin[] plugins = Bukkit.getServer().getPluginManager().getPlugins();
for (Plugin p : plugins) { for (Plugin p : plugins) {
@ -138,24 +137,32 @@ public class WorldEditPlugin extends JavaPlugin {
//noinspection ResultOfMethodCallIgnored //noinspection ResultOfMethodCallIgnored
getDataFolder().mkdirs(); getDataFolder().mkdirs();
WorldEdit worldEdit = WorldEdit.getInstance();
// Setup platform
platform = new BukkitServerInterface(this, getServer());
worldEdit.getPlatformManager().register(platform);
//FAWE start - Migrate from config-legacy to worldedit-config //FAWE start - Migrate from config-legacy to worldedit-config
migrateLegacyConfig(); migrateLegacyConfig();
//FAWE end //FAWE end
//FAWE start - Modify WorldEdit config name //FAWE start - Modify WorldEdit config name
config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "worldedit-config.yml"), true), this); config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "worldedit-config.yml"), true), this);
// Load config before we say we've loaded platforms as it is used in listeners of the event
// Load config in onLoad to ensure it is loaded before FAWE settings to allow (inelegant) copying of values across
// where needed
config.load();
//FAWE end //FAWE end
WorldEdit worldEdit = WorldEdit.getInstance();
// Setup platform
platform = new BukkitServerInterface(this, getServer());
worldEdit.getPlatformManager().register(platform);
//FAWE start - Setup permission attachments //FAWE start - Setup permission attachments
permissionAttachmentManager = new BukkitPermissionAttachmentManager(this); permissionAttachmentManager = new BukkitPermissionAttachmentManager(this);
//FAWE end //FAWE end
//FAWE start - initialise bukkitConsoleCommandSender later
this.bukkitConsoleCommandSender = new BukkitCommandSender(this, Bukkit.getConsoleSender());
//FAWE end
Path delChunks = Paths.get(getDataFolder().getPath(), DELCHUNKS_FILE_NAME); Path delChunks = Paths.get(getDataFolder().getPath(), DELCHUNKS_FILE_NAME);
if (Files.exists(delChunks)) { if (Files.exists(delChunks)) {
ChunkDeleter.runFromFile(delChunks, true); ChunkDeleter.runFromFile(delChunks, true);
@ -189,8 +196,6 @@ public class WorldEditPlugin extends JavaPlugin {
new FaweBukkit(this); new FaweBukkit(this);
//FAWE end //FAWE end
config.load(); // Load config before we say we've loaded platforms as it is used in listeners of the event
WorldEdit.getInstance().getEventBus().post(new PlatformsRegisteredEvent()); WorldEdit.getInstance().getEventBus().post(new PlatformsRegisteredEvent());
PermissionsResolverManager.initialize(this); // Setup permission resolver PermissionsResolverManager.initialize(this); // Setup permission resolver

View File

@ -24,11 +24,13 @@ limits:
max-polygonal-points: max-polygonal-points:
default: -1 default: -1
maximum: 20 maximum: 20
# radius, superpickaxe, brush radius are ignored, use FAWE config limits
max-radius: -1 max-radius: -1
max-super-pickaxe-size: 5 max-super-pickaxe-size: 5
max-brush-radius: 100 max-brush-radius: 100
butcher-radius: butcher-radius:
default: -1 default: -1
# Ignored, use FAWE config limits
maximum: -1 maximum: -1
disallowed-blocks: disallowed-blocks:
- "minecraft:wheat" - "minecraft:wheat"

View File

@ -68,7 +68,7 @@ public class CLIBlockRegistry extends BundledBlockRegistry {
@Override @Override
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) { public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
Map<String, FileRegistries.BlockProperty> properties = Map<String, FileRegistries.BlockProperty> properties =
CLIWorldEdit.inst.getFileRegistries().getDataFile().blocks.get(blockType.getId()).properties; CLIWorldEdit.inst.getFileRegistries().getDataFile().blocks.get(blockType.id()).properties;
Maps.EntryTransformer<String, FileRegistries.BlockProperty, Property<?>> entryTransform = Maps.EntryTransformer<String, FileRegistries.BlockProperty, Property<?>> entryTransform =
(key, value) -> createProperty(value.type, key, value.values); (key, value) -> createProperty(value.type, key, value.values);
return ImmutableMap.copyOf(Maps.transformEntries(properties, entryTransform)); return ImmutableMap.copyOf(Maps.transformEntries(properties, entryTransform));

View File

@ -115,7 +115,7 @@ class CLIPlatform extends AbstractPlatform {
@Override @Override
public World matchWorld(World world) { public World matchWorld(World world) {
return this.worlds.stream() return this.worlds.stream()
.filter(w -> w.getId().equals(world.getId())) .filter(w -> w.id().equals(world.id()))
.findAny() .findAny()
.orElse(null); .orElse(null);
} }

View File

@ -85,7 +85,7 @@ public class ClipboardWorld extends AbstractWorld implements Clipboard, CLIWorld
//FAWE end //FAWE end
@Override @Override
public String getId() { public String id() {
return getName().replace(" ", "_").toLowerCase(Locale.ROOT); return getName().replace(" ", "_").toLowerCase(Locale.ROOT);
} }

View File

@ -339,11 +339,11 @@ public class FaweAPI {
final BlockVector3 bot = selection.getMinimumPoint(); final BlockVector3 bot = selection.getMinimumPoint();
final BlockVector3 top = selection.getMaximumPoint(); final BlockVector3 top = selection.getMaximumPoint();
final int minX = bot.getBlockX() >> 4; final int minX = bot.x() >> 4;
final int minZ = bot.getBlockZ() >> 4; final int minZ = bot.z() >> 4;
final int maxX = top.getBlockX() >> 4; final int maxX = top.x() >> 4;
final int maxZ = top.getBlockZ() >> 4; final int maxZ = top.z() >> 4;
int count = 0; int count = 0;

View File

@ -50,9 +50,9 @@ public class BlendBall implements Brush {
final int outsetSize = (int) (size + 1); final int outsetSize = (int) (size + 1);
double brushSizeSquared = size * size; double brushSizeSquared = size * size;
int tx = position.getBlockX(); int tx = position.x();
int ty = position.getBlockY(); int ty = position.y();
int tz = position.getBlockZ(); int tz = position.z();
int[] frequency = new int[BlockTypes.size()]; int[] frequency = new int[BlockTypes.size()];

View File

@ -81,9 +81,9 @@ public class CatenaryBrush implements Brush, ResettableTool {
return pos1.add(pos2).divide(2).toBlockPoint(); return pos1.add(pos2).divide(2).toBlockPoint();
} }
double curveLen = pos1.distance(pos2) * lenPercent; double curveLen = pos1.distance(pos2) * lenPercent;
double dy = pos2.getY() - pos1.getY(); double dy = pos2.y() - pos1.y();
double dx = pos2.getX() - pos1.getX(); double dx = pos2.x() - pos1.x();
double dz = pos2.getZ() - pos1.getZ(); double dz = pos2.z() - pos1.z();
double dh = Math.sqrt(dx * dx + dz * dz); double dh = Math.sqrt(dx * dx + dz * dz);
double g = Math.sqrt(curveLen * curveLen - dy * dy) / 2; double g = Math.sqrt(curveLen * curveLen - dy * dy) / 2;
double a = 0.00001; double a = 0.00001;

View File

@ -54,9 +54,9 @@ public class CommandBrush implements Brush {
position.subtract(radius, radius, radius), position.subtract(radius, radius, radius),
position.add(radius, radius, radius) position.add(radius, radius, radius)
); );
String replaced = command.replace("{x}", Integer.toString(position.getBlockX())) String replaced = command.replace("{x}", Integer.toString(position.x()))
.replace("{y}", Integer.toString(position.getBlockY())) .replace("{y}", Integer.toString(position.y()))
.replace("{z}", Integer.toString(position.getBlockZ())) .replace("{z}", Integer.toString(position.z()))
.replace("{world}", editSession.getWorld().getName()) .replace("{world}", editSession.getWorld().getName())
.replace("{size}", Integer.toString(radius)); .replace("{size}", Integer.toString(radius));

View File

@ -65,11 +65,11 @@ public class CopyPastaBrush implements Brush, ResettableTool {
mask = Masks.alwaysTrue(); mask = Masks.alwaysTrue();
} }
final ResizableClipboardBuilder builder = new ResizableClipboardBuilder(editSession.getWorld()); final ResizableClipboardBuilder builder = new ResizableClipboardBuilder(editSession.getWorld());
final int minY = position.getBlockY(); final int minY = position.y();
mask = new AbstractDelegateMask(mask) { mask = new AbstractDelegateMask(mask) {
@Override @Override
public boolean test(BlockVector3 vector) { public boolean test(BlockVector3 vector) {
if (super.test(vector) && vector.getBlockY() >= minY) { if (super.test(vector) && vector.y() >= minY) {
BaseBlock block = editSession.getFullBlock(vector); BaseBlock block = editSession.getFullBlock(vector);
if (!block.getBlockType().getMaterial().isAir()) { if (!block.getBlockType().getMaterial().isAir()) {
builder.add(vector, BlockTypes.AIR.getDefaultState().toBaseBlock(), block); builder.add(vector, BlockTypes.AIR.getDefaultState().toBaseBlock(), block);

View File

@ -63,9 +63,9 @@ public class ErodeBrush implements Brush {
Clipboard buffer1 = new CPUOptimizedClipboard(region); Clipboard buffer1 = new CPUOptimizedClipboard(region);
Clipboard buffer2 = new CPUOptimizedClipboard(region); Clipboard buffer2 = new CPUOptimizedClipboard(region);
final int bx = target.getBlockX(); final int bx = target.x();
final int by = target.getBlockY(); final int by = target.y();
final int bz = target.getBlockZ(); final int bz = target.z();
for (int x = -brushSize, relx = 0; x <= brushSize && relx < buffer1.getWidth(); x++, relx++) { for (int x = -brushSize, relx = 0; x <= brushSize && relx < buffer1.getWidth(); x++, relx++) {
int x0 = x + bx; int x0 = x + bx;
@ -106,7 +106,7 @@ public class ErodeBrush implements Brush {
for (BlockVector3 pos : finalBuffer) { for (BlockVector3 pos : finalBuffer) {
BlockState block = pos.getBlock(finalBuffer); BlockState block = pos.getBlock(finalBuffer);
es.setBlock(pos.getX() + bx - brushSize, pos.getY() + by - brushSize, pos.getZ() + bz - brushSize, block); es.setBlock(pos.x() + bx - brushSize, pos.y() + by - brushSize, pos.z() + bz - brushSize, block);
} }
} }
@ -139,9 +139,9 @@ public class ErodeBrush implements Brush {
int highest = 1; int highest = 1;
for (BlockVector3 offs : FACES_TO_CHECK) { for (BlockVector3 offs : FACES_TO_CHECK) {
BaseBlock next = current.getFullBlock( BaseBlock next = current.getFullBlock(
relx + offs.getBlockX(), relx + offs.x(),
rely + offs.getBlockY(), rely + offs.y(),
relz + offs.getBlockZ() relz + offs.z()
); );
if (!next.getBlockType().getMaterial().isMovementBlocker()) { if (!next.getBlockType().getMaterial().isMovementBlocker()) {
continue; continue;
@ -190,9 +190,9 @@ public class ErodeBrush implements Brush {
int total = 0; int total = 0;
for (BlockVector3 offs : FACES_TO_CHECK) { for (BlockVector3 offs : FACES_TO_CHECK) {
BaseBlock next = current.getFullBlock( BaseBlock next = current.getFullBlock(
relx + offs.getBlockX(), relx + offs.x(),
rely + offs.getBlockY(), rely + offs.y(),
relz + offs.getBlockZ() relz + offs.z()
); );
if (next.getMaterial().isMovementBlocker()) { if (next.getMaterial().isMovementBlocker()) {
continue; continue;

View File

@ -12,9 +12,9 @@ public class FallingSphere implements Brush {
@Override @Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws
MaxChangedBlocksException { MaxChangedBlocksException {
int px = position.getBlockX(); int px = position.x();
int py = position.getBlockY(); int py = position.y();
int pz = position.getBlockZ(); int pz = position.z();
int maxY = editSession.getMaxY(); int maxY = editSession.getMaxY();
int minY = editSession.getMinY(); int minY = editSession.getMinY();

View File

@ -14,7 +14,6 @@ import com.sk89q.worldedit.command.tool.BrushTool;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
@ -25,7 +24,6 @@ import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor; import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import org.apache.logging.log4j.Logger;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator; import java.util.Iterator;
@ -80,9 +78,9 @@ public class InspectBrush extends BrushTool {
return true; return true;
} }
BlockVector3 target = targetVector.toBlockPoint(); BlockVector3 target = targetVector.toBlockPoint();
final int x = target.getBlockX(); final int x = target.x();
final int y = target.getBlockY(); final int y = target.y();
final int z = target.getBlockZ(); final int z = target.z();
World world = player.getWorld(); World world = player.getWorld();
RollbackDatabase db = DBHandler.dbHandler().getDatabase(world); RollbackDatabase db = DBHandler.dbHandler().getDatabase(world);
int count = 0; int count = 0;

View File

@ -35,7 +35,7 @@ public record RecurseBrush(boolean dfs) implements Brush {
DFSRecursiveVisitor visitor = new DFSRecursiveVisitor(mask, replace, Integer.MAX_VALUE, Integer.MAX_VALUE) { DFSRecursiveVisitor visitor = new DFSRecursiveVisitor(mask, replace, Integer.MAX_VALUE, Integer.MAX_VALUE) {
@Override @Override
public boolean isVisitable(BlockVector3 from, BlockVector3 to) { public boolean isVisitable(BlockVector3 from, BlockVector3 to) {
int y = to.getBlockY(); int y = to.y();
return y < maxY && radMask.test(to) && super.isVisitable(from, to); return y < maxY && radMask.test(to) && super.isVisitable(from, to);
} }
}; };
@ -45,7 +45,7 @@ public record RecurseBrush(boolean dfs) implements Brush {
RecursiveVisitor visitor = new RecursiveVisitor(mask, replace, radius, editSession.getMinY(), editSession.getMaxY()) { RecursiveVisitor visitor = new RecursiveVisitor(mask, replace, radius, editSession.getMinY(), editSession.getMaxY()) {
@Override @Override
public boolean isVisitable(BlockVector3 from, BlockVector3 to) { public boolean isVisitable(BlockVector3 from, BlockVector3 to) {
int y = to.getBlockY(); int y = to.y();
return y < maxY && super.isVisitable(from, to); return y < maxY && super.isVisitable(from, to);
} }
}; };

View File

@ -19,15 +19,15 @@ public record RockBrush(double amplitude, double frequency, Vector3 radius) impl
double seedY = ThreadLocalRandom.current().nextDouble(); double seedY = ThreadLocalRandom.current().nextDouble();
double seedZ = ThreadLocalRandom.current().nextDouble(); double seedZ = ThreadLocalRandom.current().nextDouble();
int px = position.getBlockX(); int px = position.x();
int py = position.getBlockY(); int py = position.y();
int pz = position.getBlockZ(); int pz = position.z();
double distort = this.frequency / size; double distort = this.frequency / size;
double modX = 1D / radius.getX(); double modX = 1D / radius.x();
double modY = 1D / radius.getY(); double modY = 1D / radius.y();
double modZ = 1D / radius.getZ(); double modZ = 1D / radius.z();
int radiusSqr = (int) (size * size); int radiusSqr = (int) (size * size);
int sizeInt = (int) size * 2; int sizeInt = (int) size * 2;

View File

@ -67,15 +67,15 @@ public class ScatterBrush implements Brush {
} }
BlockVector3 patternSize = pattern.size(); BlockVector3 patternSize = pattern.size();
BlockVector3Set placed = BlockVector3Set.getAppropriateVectorSet(patternSize.add(distance, distance, distance)); BlockVector3Set placed = BlockVector3Set.getAppropriateVectorSet(patternSize.add(distance, distance, distance));
placed.setOffset(position.getX(), position.getY(), position.getZ()); placed.setOffset(position.x(), position.y(), position.z());
int maxFails = 1000; int maxFails = 1000;
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
int index = ThreadLocalRandom.current().nextInt(length); int index = ThreadLocalRandom.current().nextInt(length);
BlockVector3 pos = visited.get(index); BlockVector3 pos = visited.get(index);
if (pos != null && canApply(pos)) { if (pos != null && canApply(pos)) {
int x = pos.getBlockX(); int x = pos.x();
int y = pos.getBlockY(); int y = pos.y();
int z = pos.getBlockZ(); int z = pos.z();
if (placed.containsRadius(x, y, z, distance)) { if (placed.containsRadius(x, y, z, distance)) {
if (maxFails-- <= 0) { if (maxFails-- <= 0) {
break; break;

View File

@ -45,9 +45,9 @@ public class ScatterCommand extends ScatterBrush {
position.subtract(radius, radius, radius), position.subtract(radius, radius, radius),
position.add(radius, radius, radius) position.add(radius, radius, radius)
); );
String replaced = command.replace("{x}", Integer.toString(position.getBlockX())) String replaced = command.replace("{x}", Integer.toString(position.x()))
.replace("{y}", Integer.toString(position.getBlockY())) .replace("{y}", Integer.toString(position.y()))
.replace("{z}", Integer.toString(position.getBlockZ())) .replace("{z}", Integer.toString(position.z()))
.replace("{world}", editSession.getWorld().getName()) .replace("{world}", editSession.getWorld().getName())
.replace("{size}", Integer.toString(radius)); .replace("{size}", Integer.toString(radius));

View File

@ -16,9 +16,9 @@ public class ScatterOverlayBrush extends ScatterBrush {
@Override @Override
public void apply(EditSession editSession, LocalBlockVectorSet placed, BlockVector3 pt, Pattern p, double size) throws public void apply(EditSession editSession, LocalBlockVectorSet placed, BlockVector3 pt, Pattern p, double size) throws
MaxChangedBlocksException { MaxChangedBlocksException {
final int x = pt.getBlockX(); final int x = pt.x();
final int y = pt.getBlockY(); final int y = pt.y();
final int z = pt.getBlockZ(); final int z = pt.z();
BlockVector3 dir = getDirection(pt); BlockVector3 dir = getDirection(pt);
if (dir == null) { if (dir == null) {
getDir: getDir:
@ -37,7 +37,7 @@ public class ScatterOverlayBrush extends ScatterBrush {
return; return;
} }
} }
editSession.setBlock(x + dir.getBlockX(), y + dir.getBlockY(), z + dir.getBlockZ(), p); editSession.setBlock(x + dir.x(), y + dir.y(), z + dir.z(), p);
} }
} }

View File

@ -80,13 +80,13 @@ public class ShatterBrush extends ScatterBrush {
} }
for (int i1 = 0; i1 < BreadthFirstSearch.DIAGONAL_DIRECTIONS.length; i1++) { for (int i1 = 0; i1 < BreadthFirstSearch.DIAGONAL_DIRECTIONS.length; i1++) {
BlockVector3 direction = BreadthFirstSearch.DIAGONAL_DIRECTIONS[i1]; BlockVector3 direction = BreadthFirstSearch.DIAGONAL_DIRECTIONS[i1];
int x2 = x + direction.getBlockX(); int x2 = x + direction.x();
int y2 = y + direction.getBlockY(); int y2 = y + direction.y();
int z2 = z + direction.getBlockZ(); int z2 = z + direction.z();
// Check boundary // Check boundary
int dx = position.getBlockX() - x2; int dx = position.x() - x2;
int dy = position.getBlockY() - y2; int dy = position.y() - y2;
int dz = position.getBlockZ() - z2; int dz = position.z() - z2;
int dSqr = (dx * dx) + (dy * dy) + (dz * dz); int dSqr = (dx * dx) + (dy * dy) + (dz * dz);
if (dSqr <= radius2) { if (dSqr <= radius2) {
BlockVector3 bv = mutable.setComponents(x2, y2, z2); BlockVector3 bv = mutable.setComponents(x2, y2, z2);

View File

@ -130,9 +130,9 @@ public class SplineBrush implements Brush, ResettableTool {
private Vector3 getCentroid(Collection<BlockVector3> points) { private Vector3 getCentroid(Collection<BlockVector3> points) {
MutableVector3 sum = new MutableVector3(); MutableVector3 sum = new MutableVector3();
for (BlockVector3 p : points) { for (BlockVector3 p : points) {
sum.mutX(sum.getX() + p.getX()); sum.mutX(sum.x() + p.x());
sum.mutY(sum.getY() + p.getY()); sum.mutY(sum.y() + p.y());
sum.mutZ(sum.getZ() + p.getZ()); sum.mutZ(sum.z() + p.z());
} }
return sum.multiply(1.0 / points.size()); return sum.multiply(1.0 / points.size());
} }

View File

@ -38,16 +38,16 @@ public class SurfaceSpline implements Brush {
int minY = editSession.getMinY(); int minY = editSession.getMinY();
if (path.isEmpty() || !pos.equals(path.get(path.size() - 1))) { if (path.isEmpty() || !pos.equals(path.get(path.size() - 1))) {
int max = editSession.getNearestSurfaceTerrainBlock( int max = editSession.getNearestSurfaceTerrainBlock(
pos.getBlockX(), pos.x(),
pos.getBlockZ(), pos.z(),
pos.getBlockY(), pos.y(),
minY, minY,
maxY maxY
); );
if (max == -1) { if (max == -1) {
return; return;
} }
path.add(BlockVector3.at(pos.getBlockX(), max, pos.getBlockZ())); path.add(BlockVector3.at(pos.x(), max, pos.z()));
if (editSession.getActor() != null) { if (editSession.getActor() != null) {
editSession.getActor().print(Caption.of("fawe.worldedit.brush.spline.primary.2")); editSession.getActor().print(Caption.of("fawe.worldedit.brush.spline.primary.2"));
} }
@ -69,9 +69,9 @@ public class SurfaceSpline implements Brush {
LocalBlockVectorSet vset = new LocalBlockVectorSet(); LocalBlockVectorSet vset = new LocalBlockVectorSet();
for (double loop = 0; loop <= 1; loop += 1D / splinelength / quality) { for (double loop = 0; loop <= 1; loop += 1D / splinelength / quality) {
final Vector3 tipv = interpol.getPosition(loop); final Vector3 tipv = interpol.getPosition(loop);
final int tipx = MathMan.roundInt(tipv.getX()); final int tipx = MathMan.roundInt(tipv.x());
final int tipz = (int) tipv.getZ(); final int tipz = (int) tipv.z();
int tipy = MathMan.roundInt(tipv.getY()); int tipy = MathMan.roundInt(tipv.y());
tipy = editSession.getNearestSurfaceTerrainBlock(tipx, tipz, tipy, minY, maxY, Integer.MIN_VALUE, Integer.MAX_VALUE); tipy = editSession.getNearestSurfaceTerrainBlock(tipx, tipz, tipy, minY, maxY, Integer.MIN_VALUE, Integer.MAX_VALUE);
if (tipy == Integer.MIN_VALUE || tipy == Integer.MAX_VALUE) { if (tipy == Integer.MIN_VALUE || tipy == Integer.MAX_VALUE) {
continue; continue;
@ -88,15 +88,15 @@ public class SurfaceSpline implements Brush {
LocalBlockVectorSet newSet = new LocalBlockVectorSet(); LocalBlockVectorSet newSet = new LocalBlockVectorSet();
final int ceilrad = (int) Math.ceil(radius); final int ceilrad = (int) Math.ceil(radius);
for (BlockVector3 v : vset) { for (BlockVector3 v : vset) {
final int tipx = v.getBlockX(); final int tipx = v.x();
final int tipz = v.getBlockZ(); final int tipz = v.z();
for (int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) { for (int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) {
for (int loopz = tipz - ceilrad; loopz <= tipz + ceilrad; loopz++) { for (int loopz = tipz - ceilrad; loopz <= tipz + ceilrad; loopz++) {
if (MathMan.hypot2(loopx - tipx, 0, loopz - tipz) <= radius2) { if (MathMan.hypot2(loopx - tipx, 0, loopz - tipz) <= radius2) {
int y = editSession.getNearestSurfaceTerrainBlock( int y = editSession.getNearestSurfaceTerrainBlock(
loopx, loopx,
loopz, loopz,
v.getBlockY(), v.y(),
minY, minY,
maxY, maxY,
Integer.MIN_VALUE, Integer.MIN_VALUE,

View File

@ -13,7 +13,7 @@ public class ScrollRange extends Scroll {
@Override @Override
public boolean increment(Player player, int amount) { public boolean increment(Player player, int amount) {
int max = WorldEdit.getInstance().getConfiguration().maxBrushRadius; int max = player.getLimit().MAX_BRUSH_RADIUS;
int newSize = MathMan.wrap(getTool().getRange() + amount, (int) (getTool().getSize() + 1), max); int newSize = MathMan.wrap(getTool().getRange() + amount, (int) (getTool().getSize() + 1), max);
getTool().setRange(newSize); getTool().setRange(newSize);
return true; return true;

View File

@ -12,7 +12,7 @@ public class ScrollSize extends Scroll {
@Override @Override
public boolean increment(Player player, int amount) { public boolean increment(Player player, int amount) {
int max = WorldEdit.getInstance().getConfiguration().maxRadius; int max = player.getLimit().MAX_RADIUS;
double newSize = Math.max(0, Math.min(max == -1 ? 4095 : max, getTool().getSize() + amount)); double newSize = Math.max(0, Math.min(max == -1 ? 4095 : max, getTool().getSize() + amount));
getTool().setSize(newSize); getTool().setSize(newSize);
return true; return true;

View File

@ -83,7 +83,7 @@ public class ClipboardSpline extends Spline {
Region region = clipboard.getRegion(); Region region = clipboard.getRegion();
BlockVector3 origin = clipboard.getOrigin(); BlockVector3 origin = clipboard.getOrigin();
// center = region.getCenter().setY(origin.getY() - 1); // center = region.getCenter().setY(origin.getY() - 1);
center = region.getCenter().withY(origin.getY() - 1).toBlockPoint(); center = region.getCenter().withY(origin.y() - 1).toBlockPoint();
this.centerOffset = center.subtract(center.round()); this.centerOffset = center.subtract(center.round());
this.center = center.subtract(centerOffset); this.center = center.subtract(centerOffset);
this.transform = transform; this.transform = transform;
@ -108,15 +108,15 @@ public class ClipboardSpline extends Spline {
clipboardHolder.setTransform(transform); clipboardHolder.setTransform(transform);
BlockVector3 functionOffset = target.subtract(clipboard.getOrigin()); BlockVector3 functionOffset = target.subtract(clipboard.getOrigin());
final int offX = functionOffset.getBlockX(); final int offX = functionOffset.x();
final int offY = functionOffset.getBlockY(); final int offY = functionOffset.y();
final int offZ = functionOffset.getBlockZ(); final int offZ = functionOffset.z();
Operation operation = clipboardHolder Operation operation = clipboardHolder
.createPaste(editSession) .createPaste(editSession)
.to(target) .to(target)
.ignoreAirBlocks(true) .ignoreAirBlocks(true)
.filter(v -> buffer.add(v.getBlockX() + offX, v.getBlockY() + offY, v.getBlockZ() + offZ)) .filter(v -> buffer.add(v.x() + offX, v.y() + offY, v.z() + offZ))
.build(); .build();
Operations.completeLegacy(operation); Operations.completeLegacy(operation);

View File

@ -121,7 +121,7 @@ public abstract class Spline {
* 2 dimensional "cross" product. cross2D(v1, v2) = |v1|*|v2|*sin(theta) or v1 X v2 taking Y to be 0 * 2 dimensional "cross" product. cross2D(v1, v2) = |v1|*|v2|*sin(theta) or v1 X v2 taking Y to be 0
*/ */
private double cross2D(Vector2 v1, Vector2 v2) { private double cross2D(Vector2 v1, Vector2 v2) {
return v1.getX() * v2.getZ() - v2.getX() * v1.getZ(); return v1.x() * v2.z() - v2.x() * v1.z();
} }
/** /**
@ -144,7 +144,7 @@ public abstract class Spline {
// Calculate rotation from spline // Calculate rotation from spline
Vector3 deriv = interpolation.get1stDerivative(position); Vector3 deriv = interpolation.get1stDerivative(position);
Vector2 deriv2D = Vector2.at(deriv.getX(), deriv.getZ()).normalize(); Vector2 deriv2D = Vector2.at(deriv.x(), deriv.z()).normalize();
double angle = Math.toDegrees( double angle = Math.toDegrees(
-Math.atan2(cross2D(direction, deriv2D), direction.dot(deriv2D)) -Math.atan2(cross2D(direction, deriv2D), direction.dot(deriv2D))
); );

View File

@ -79,13 +79,13 @@ public class SweepBrush implements Brush, ResettableTool {
Clipboard clipboard = holder.getClipboard(); Clipboard clipboard = holder.getClipboard();
BlockVector3 dimensions = clipboard.getDimensions(); BlockVector3 dimensions = clipboard.getDimensions();
double quality = Math.max(dimensions.getBlockX(), dimensions.getBlockZ()); double quality = Math.max(dimensions.x(), dimensions.z());
AffineTransform transform = new AffineTransform(); AffineTransform transform = new AffineTransform();
ClipboardSpline spline = new ClipboardSpline(editSession, holder, interpol, transform, nodes.size()); ClipboardSpline spline = new ClipboardSpline(editSession, holder, interpol, transform, nodes.size());
if (dimensions.getBlockX() > dimensions.getBlockZ()) { if (dimensions.x() > dimensions.z()) {
spline.setDirection(Vector2.at(0, 1)); spline.setDirection(Vector2.at(0, 1));
} }

View File

@ -100,6 +100,9 @@ public class Config {
} }
public boolean load(File file) { public boolean load(File file) {
if (!file.exists()) {
return false;
}
existingMigrateNodes = new ArrayList<>(); existingMigrateNodes = new ArrayList<>();
YamlConfiguration yml = YamlConfiguration.loadConfiguration(file); YamlConfiguration yml = YamlConfiguration.loadConfiguration(file);
for (String key : yml.getKeys(true)) { for (String key : yml.getKeys(true)) {

View File

@ -2,6 +2,7 @@ package com.fastasyncworldedit.core.configuration;
import com.fastasyncworldedit.core.limit.FaweLimit; import com.fastasyncworldedit.core.limit.FaweLimit;
import com.fastasyncworldedit.core.limit.PropertyRemap; import com.fastasyncworldedit.core.limit.PropertyRemap;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.block.BlockTypesCache; import com.sk89q.worldedit.world.block.BlockTypesCache;
@ -140,8 +141,22 @@ public class Settings extends Config {
); );
limit.MAX_FAILS = Math.max(limit.MAX_FAILS, newLimit.MAX_FAILS != -1 ? newLimit.MAX_FAILS : Integer.MAX_VALUE); limit.MAX_FAILS = Math.max(limit.MAX_FAILS, newLimit.MAX_FAILS != -1 ? newLimit.MAX_FAILS : Integer.MAX_VALUE);
limit.MAX_ITERATIONS = Math.max( limit.MAX_ITERATIONS = Math.max(
limit.MAX_ITERATIONS, limit.MAX_ITERATIONS, newLimit.MAX_ITERATIONS != -1 ? newLimit.MAX_ITERATIONS : Integer.MAX_VALUE);
newLimit.MAX_ITERATIONS != -1 ? newLimit.MAX_ITERATIONS : Integer.MAX_VALUE limit.MAX_RADIUS = Math.max(
limit.MAX_RADIUS,
newLimit.MAX_RADIUS != -1 ? newLimit.MAX_RADIUS : Integer.MAX_VALUE
);
limit.MAX_SUPER_PICKAXE_SIZE = Math.max(
limit.MAX_SUPER_PICKAXE_SIZE,
newLimit.MAX_SUPER_PICKAXE_SIZE != -1 ? newLimit.MAX_SUPER_PICKAXE_SIZE : Integer.MAX_VALUE
);
limit.MAX_BRUSH_RADIUS = Math.max(
limit.MAX_BRUSH_RADIUS,
newLimit.MAX_BRUSH_RADIUS != -1 ? newLimit.MAX_BRUSH_RADIUS : Integer.MAX_VALUE
);
limit.MAX_BUTCHER_RADIUS = Math.max(
limit.MAX_BUTCHER_RADIUS,
newLimit.MAX_BUTCHER_RADIUS != -1 ? newLimit.MAX_BUTCHER_RADIUS : Integer.MAX_VALUE
); );
limit.MAX_HISTORY = Math.max( limit.MAX_HISTORY = Math.max(
limit.MAX_HISTORY, limit.MAX_HISTORY,
@ -352,6 +367,14 @@ public class Settings extends Config {
public int MAX_ITERATIONS = 1000; public int MAX_ITERATIONS = 1000;
@Comment("Max allowed entities (e.g. cows)") @Comment("Max allowed entities (e.g. cows)")
public int MAX_ENTITIES = 1337; public int MAX_ENTITIES = 1337;
@Comment("Max allowed radius (e.g. for //sphere)")
public int MAX_RADIUS = LocalConfiguration.MAX_RADIUS;
@Comment("Max allowed superpickaxe size")
public int MAX_SUPER_PICKAXE_SIZE = LocalConfiguration.MAX_SUPER_RADIUS;
@Comment("Max allowed brush radius")
public int MAX_BRUSH_RADIUS = LocalConfiguration.MAX_BRUSH_RADIUS;
@Comment("Max allowed butcher radius")
public int MAX_BUTCHER_RADIUS = LocalConfiguration.MAX_BUTCHER_RADIUS;
@Comment({ @Comment({
"Blockstates include Banner, Beacon, BrewingStand, Chest, CommandBlock, ", "Blockstates include Banner, Beacon, BrewingStand, Chest, CommandBlock, ",
"CreatureSpawner, Dispenser, Dropper, EndGateway, Furnace, Hopper, Jukebox, ", "CreatureSpawner, Dispenser, Dropper, EndGateway, Furnace, Hopper, Jukebox, ",
@ -645,6 +668,13 @@ public class Settings extends Config {
@Comment({"The web interface for clipboards", " - All schematics are anonymous and private", " - Downloads can be deleted by the user", " - Supports clipboard uploads, downloads and saves",}) @Comment({"The web interface for clipboards", " - All schematics are anonymous and private", " - Downloads can be deleted by the user", " - Supports clipboard uploads, downloads and saves",})
public String URL = "https://schem.intellectualsites.com/fawe/"; public String URL = "https://schem.intellectualsites.com/fawe/";
@Comment({"The url of the backend server (Arkitektonika)"})
public String ARKITEKTONIKA_BACKEND_URL = "https://api.schematic.cloud/";
@Comment({"The url used to generate a download link from.", "{key} will be replaced with the generated key"})
public String ARKITEKTONIKA_DOWNLOAD_URL = "https://schematic.cloud/download/{key}";
@Comment({"The url used to generate a deletion link from.", "{key} will be replaced with the generated key"})
public String ARKITEKTONIKA_DELETE_URL = "https://schematic.cloud/delete/{key}";
@Comment("The maximum amount of time in seconds the plugin can attempt to load images for.") @Comment("The maximum amount of time in seconds the plugin can attempt to load images for.")
public int MAX_IMAGE_LOAD_TIME = 5; public int MAX_IMAGE_LOAD_TIME = 5;

View File

@ -68,6 +68,7 @@ public class YamlConfiguration extends FileConfiguration {
LOGGER.error("Could not read {}\n" + "Renamed to {}", file, dest.getAbsolutePath(), ex); LOGGER.error("Could not read {}\n" + "Renamed to {}", file, dest.getAbsolutePath(), ex);
} catch (final IOException e) { } catch (final IOException e) {
e.printStackTrace(); e.printStackTrace();
ex.printStackTrace();
} }
} }

View File

@ -179,13 +179,13 @@ public class RollbackDatabase extends AsyncNotifyQueue {
} }
try (PreparedStatement stmt = connection.prepareStatement(stmtStr.formatted(this.prefix))) { try (PreparedStatement stmt = connection.prepareStatement(stmtStr.formatted(this.prefix))) {
stmt.setInt(1, (int) (minTime / 1000)); stmt.setInt(1, (int) (minTime / 1000));
stmt.setInt(2, pos1.getBlockX()); stmt.setInt(2, pos1.x());
stmt.setInt(3, pos2.getBlockX()); stmt.setInt(3, pos2.x());
stmt.setInt(4, pos1.getBlockZ()); stmt.setInt(4, pos1.z());
stmt.setInt(5, pos2.getBlockZ()); stmt.setInt(5, pos2.z());
// Keep 128 offset for backwards-compatibility // Keep 128 offset for backwards-compatibility
stmt.setInt(6, pos1.getBlockY() - 128); stmt.setInt(6, pos1.y() - 128);
stmt.setInt(7, pos2.getBlockY() - 128); stmt.setInt(7, pos2.y() - 128);
if (uuid != null) { if (uuid != null) {
byte[] uuidBytes = toBytes(uuid); byte[] uuidBytes = toBytes(uuid);
stmt.setBytes(8, uuidBytes); stmt.setBytes(8, uuidBytes);
@ -210,13 +210,13 @@ public class RollbackDatabase extends AsyncNotifyQueue {
.array(); .array();
stmt.setBytes(1, uuidBytes); stmt.setBytes(1, uuidBytes);
stmt.setInt(2, (int) (minTime / 1000)); stmt.setInt(2, (int) (minTime / 1000));
stmt.setInt(3, pos1.getBlockX()); stmt.setInt(3, pos1.x());
stmt.setInt(4, pos2.getBlockX()); stmt.setInt(4, pos2.x());
stmt.setInt(5, pos1.getBlockZ()); stmt.setInt(5, pos1.z());
stmt.setInt(6, pos2.getBlockZ()); stmt.setInt(6, pos2.z());
// Keep 128 offset for backwards-compatibility // Keep 128 offset for backwards-compatibility
stmt.setInt(7, pos1.getBlockY() - 128); stmt.setInt(7, pos1.y() - 128);
stmt.setInt(8, pos2.getBlockY() - 128); stmt.setInt(8, pos2.y() - 128);
} }
} }
return count; return count;
@ -262,13 +262,13 @@ public class RollbackDatabase extends AsyncNotifyQueue {
BlockVector3 pos1 = change.getMinimumPoint(); BlockVector3 pos1 = change.getMinimumPoint();
BlockVector3 pos2 = change.getMaximumPoint(); BlockVector3 pos2 = change.getMaximumPoint();
stmt.setInt(4, pos1.getX()); stmt.setInt(4, pos1.x());
stmt.setInt(5, pos2.getX()); stmt.setInt(5, pos2.x());
stmt.setInt(6, pos1.getZ()); stmt.setInt(6, pos1.z());
stmt.setInt(7, pos2.getZ()); stmt.setInt(7, pos2.z());
// Keep 128 offset for backwards-compatibility // Keep 128 offset for backwards-compatibility
stmt.setInt(8, pos1.getY() - 128); stmt.setInt(8, pos1.y() - 128);
stmt.setInt(9, pos2.getY() - 128); stmt.setInt(9, pos2.y() - 128);
stmt.setString(10, change.getCommand()); stmt.setString(10, change.getCommand());
stmt.setInt(11, change.size()); stmt.setInt(11, change.size());
stmt.executeUpdate(); stmt.executeUpdate();

View File

@ -0,0 +1,30 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.fastasyncworldedit.core.exception;
/**
* Thrown when a maximum radius for a brush is reached.
*/
public class BrushRadiusLimitException extends RadiusLimitException {
public BrushRadiusLimitException(int maxBrushRadius) {
super(maxBrushRadius);
}
}

View File

@ -0,0 +1,41 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.fastasyncworldedit.core.exception;
import com.sk89q.worldedit.WorldEditException;
/**
* Thrown when a maximum radius is reached, such as, for example,
* in the case of a sphere command.
*/
public class RadiusLimitException extends WorldEditException {
private final int maxRadius;
public RadiusLimitException(int maxRadius) {
this.maxRadius = maxRadius;
}
public int getMaxRadius() {
return maxRadius;
}
//FAWE end
}

View File

@ -0,0 +1,72 @@
package com.fastasyncworldedit.core.extension.factory.parser.common;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.extent.inventory.SlottableBlockBag;
import com.fastasyncworldedit.core.limit.FaweLimit;
import com.google.common.collect.ImmutableList;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.input.DisallowedUsageException;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.internal.registry.SimpleInputParser;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.world.block.BlockType;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public abstract class HotbarParser<T> extends SimpleInputParser<T> {
private final List<String> aliases = ImmutableList.of("#hotbar");
protected HotbarParser(final WorldEdit worldEdit) {
super(worldEdit);
}
@Override
public List<String> getMatchedAliases() {
return aliases;
}
protected List<BlockType> getBlockTypes(ParserContext context) {
Player player = context.requirePlayer();
BlockBag bag = player.getInventoryBlockBag();
if (!(bag instanceof final SlottableBlockBag slottable)) {
// Matches DefaultBlockParser
throw new InputParseException(Caption.of("fawe.error.unsupported"));
}
List<BlockType> types = new ArrayList<>();
FaweLimit limit = player.getLimit();
boolean anyBlock = player.hasPermission("worldedit.anyblock");
for (int slot = 0; slot < 9; slot++) {
BaseItem item = slottable.getItem(slot);
if (item != null && item.getType().hasBlockType()) {
BlockType type = item.getType().getBlockType();
if (!anyBlock && worldEdit.getConfiguration().disallowedBlocks.contains(type.id().toLowerCase(Locale.ROOT))) {
throw new DisallowedUsageException(Caption.of(
"worldedit.error.disallowed-block",
TextComponent.of(type.getId())
));
}
if (!limit.isUnlimited()) {
if (limit.DISALLOWED_BLOCKS.contains(type.id().toLowerCase(Locale.ROOT))) {
throw new DisallowedUsageException(Caption.of(
"fawe.error.limit.disallowed-block",
TextComponent.of(type.getId())
));
}
}
types.add(type);
}
}
if (types.isEmpty()) {
throw new InputParseException(Caption.of("fawe.error.no-valid-on-hotbar"));
}
return types;
}
}

View File

@ -0,0 +1,20 @@
package com.fastasyncworldedit.core.extension.factory.parser.mask;
import com.fastasyncworldedit.core.extension.factory.parser.common.HotbarParser;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.BlockTypeMask;
import com.sk89q.worldedit.function.mask.Mask;
public class HotbarMaskParser extends HotbarParser<Mask> {
public HotbarMaskParser(WorldEdit worldEdit) {
super(worldEdit);
}
@Override
public Mask parseFromSimpleInput(String input, ParserContext context) {
return new BlockTypeMask(context.getExtent(), getBlockTypes(context));
}
}

View File

@ -0,0 +1,26 @@
package com.fastasyncworldedit.core.extension.factory.parser.pattern;
import com.fastasyncworldedit.core.extension.factory.parser.common.HotbarParser;
import com.fastasyncworldedit.core.math.random.TrueRandom;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.pattern.RandomPattern;
import com.sk89q.worldedit.world.block.BlockType;
public class HotbarPatternParser extends HotbarParser<Pattern> {
public HotbarPatternParser(WorldEdit worldEdit) {
super(worldEdit);
}
@Override
public Pattern parseFromSimpleInput(String input, ParserContext context) {
RandomPattern random = new RandomPattern(new TrueRandom());
for (BlockType type : getBlockTypes(context)) {
random.add(type, 1);
}
return random;
}
}

View File

@ -24,7 +24,7 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
@Override @Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException { public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
return getExtent().setBlock(location.getX() + dx, location.getY() + dy, location.getZ() + dz, block); return getExtent().setBlock(location.x() + dx, location.y() + dy, location.z() + dz, block);
} }
@Override @Override
@ -49,7 +49,7 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
@Override @Override
public BlockState getBlock(BlockVector3 location) { public BlockState getBlock(BlockVector3 location) {
return getBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ()); return getBlock(location.x(), location.y(), location.z());
} }
@Override @Override

View File

@ -101,7 +101,7 @@ public class DisallowedBlocksExtent extends AbstractDelegateExtent implements IB
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private <B extends BlockStateHolder<B>> B checkBlock(B block) { private <B extends BlockStateHolder<B>> B checkBlock(B block) {
if (blockedBlocks != null) { if (blockedBlocks != null) {
if (blockedBlocks.contains(block.getBlockType().getId())) { if (blockedBlocks.contains(block.getBlockType().id())) {
return (B) (block instanceof BlockState ? RESERVED : RESERVED.toBaseBlock()); // set to reserved/empty return (B) (block instanceof BlockState ? RESERVED : RESERVED.toBaseBlock()); // set to reserved/empty
} }
} }
@ -140,7 +140,7 @@ public class DisallowedBlocksExtent extends AbstractDelegateExtent implements IB
} }
BlockState state = BlockTypesCache.states[block]; BlockState state = BlockTypesCache.states[block];
if (blockedBlocks != null) { if (blockedBlocks != null) {
if (blockedBlocks.contains(state.getBlockType().getId())) { if (blockedBlocks.contains(state.getBlockType().id())) {
blocks[i] = BlockTypesCache.ReservedIDs.__RESERVED__; blocks[i] = BlockTypesCache.ReservedIDs.__RESERVED__;
continue; continue;
} }

View File

@ -64,11 +64,11 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
@Override @Override
public final boolean contains(BlockVector3 p) { public final boolean contains(BlockVector3 p) {
return contains(p.getBlockX(), p.getBlockY(), p.getBlockZ()); return contains(p.x(), p.y(), p.z());
} }
public final boolean contains(BlockVector2 p) { public final boolean contains(BlockVector2 p) {
return contains(p.getBlockX(), p.getBlockZ()); return contains(p.x(), p.z());
} }
@Override @Override
@ -96,7 +96,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
@Override @Override
public BiomeType getBiome(BlockVector3 position) { public BiomeType getBiome(BlockVector3 position) {
return getBiomeType(position.getX(), position.getY(), position.getZ()); return getBiomeType(position.x(), position.y(), position.z());
} }
@Override @Override
@ -112,7 +112,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
@Override @Override
public BaseBlock getFullBlock(BlockVector3 position) { public BaseBlock getFullBlock(BlockVector3 position) {
return getFullBlock(position.getX(), position.getY(), position.getZ()); return getFullBlock(position.x(), position.y(), position.z());
} }
@Override @Override
@ -128,7 +128,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
@Override @Override
public BlockState getBlock(BlockVector3 position) { public BlockState getBlock(BlockVector3 position) {
return getBlock(position.getX(), position.getY(), position.getZ()); return getBlock(position.x(), position.y(), position.z());
} }
@Override @Override

View File

@ -66,7 +66,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
@Override @Override
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException { public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
return setBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block); return setBlock(location.x(), location.y(), location.z(), block);
} }
@Nullable @Nullable
@ -110,8 +110,8 @@ public class HistoryExtent extends AbstractDelegateExtent {
@Override @Override
public boolean setBiome(BlockVector3 position, BiomeType newBiome) { public boolean setBiome(BlockVector3 position, BiomeType newBiome) {
BiomeType oldBiome = this.getBiome(position); BiomeType oldBiome = this.getBiome(position);
if (!oldBiome.getId().equals(newBiome.getId())) { if (!oldBiome.id().equals(newBiome.id())) {
this.changeSet.addBiomeChange(position.getBlockX(), position.getBlockY(), position.getBlockZ(), oldBiome, newBiome); this.changeSet.addBiomeChange(position.x(), position.y(), position.z(), oldBiome, newBiome);
return getExtent().setBiome(position, newBiome); return getExtent().setBiome(position, newBiome);
} else { } else {
return false; return false;
@ -121,7 +121,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
@Override @Override
public boolean setBiome(int x, int y, int z, BiomeType newBiome) { public boolean setBiome(int x, int y, int z, BiomeType newBiome) {
BiomeType oldBiome = this.getBiome(mutable.setComponents(x, y, z)); BiomeType oldBiome = this.getBiome(mutable.setComponents(x, y, z));
if (!oldBiome.getId().equals(newBiome.getId())) { if (!oldBiome.id().equals(newBiome.id())) {
this.changeSet.addBiomeChange(x, y, z, oldBiome, newBiome); this.changeSet.addBiomeChange(x, y, z, oldBiome, newBiome);
return getExtent().setBiome(x, y, z, newBiome); return getExtent().setBiome(x, y, z, newBiome);
} else { } else {

View File

@ -373,12 +373,12 @@ public class LimitExtent extends AbstractDelegateExtent {
size = ((Collection<BlockVector3>) positions).size(); size = ((Collection<BlockVector3>) positions).size();
} else if (positions instanceof Region) { } else if (positions instanceof Region) {
BlockVector3 dim = ((Region) positions).getDimensions(); BlockVector3 dim = ((Region) positions).getDimensions();
size = dim.getX() * dim.getY() * dim.getZ(); size = dim.x() * dim.y() * dim.z();
} else if (positions instanceof Extent) { } else if (positions instanceof Extent) {
BlockVector3 min = ((Extent) positions).getMinimumPoint(); BlockVector3 min = ((Extent) positions).getMinimumPoint();
BlockVector3 max = ((Extent) positions).getMinimumPoint(); BlockVector3 max = ((Extent) positions).getMinimumPoint();
BlockVector3 dim = max.subtract(min).add(BlockVector3.ONE); BlockVector3 dim = max.subtract(min).add(BlockVector3.ONE);
size = dim.getX() * dim.getY() * dim.getZ(); size = dim.x() * dim.y() * dim.z();
} else { } else {
ExtentFilterBlock block = new ExtentFilterBlock(this); ExtentFilterBlock block = new ExtentFilterBlock(this);
for (BlockVector3 pos : positions) { for (BlockVector3 pos : positions) {

View File

@ -38,9 +38,9 @@ public class PositionTransformExtent extends ResettableExtent {
if (min == null) { if (min == null) {
min = pos; min = pos;
} }
mutable.mutX(pos.getX() - min.getX()); mutable.mutX(pos.x() - min.x());
mutable.mutY(pos.getY() - min.getY()); mutable.mutY(pos.y() - min.y());
mutable.mutZ(pos.getZ() - min.getZ()); mutable.mutZ(pos.z() - min.z());
MutableVector3 tmp = new MutableVector3(transform.apply(mutable.toVector3())); MutableVector3 tmp = new MutableVector3(transform.apply(mutable.toVector3()));
return min.add(tmp.roundHalfUp().toBlockPoint()); return min.add(tmp.roundHalfUp().toBlockPoint());
} }
@ -49,9 +49,9 @@ public class PositionTransformExtent extends ResettableExtent {
if (min == null) { if (min == null) {
min = BlockVector3.at(x, y, z); min = BlockVector3.at(x, y, z);
} }
mutable.mutX(x - min.getX()); mutable.mutX(x - min.x());
mutable.mutY(y - min.getY()); mutable.mutY(y - min.y());
mutable.mutZ(z - min.getZ()); mutable.mutZ(z - min.z());
MutableVector3 tmp = new MutableVector3(transform.apply(mutable.toVector3())); MutableVector3 tmp = new MutableVector3(transform.apply(mutable.toVector3()));
return min.add(tmp.roundHalfUp().toBlockPoint()); return min.add(tmp.roundHalfUp().toBlockPoint());
} }
@ -73,10 +73,10 @@ public class PositionTransformExtent extends ResettableExtent {
@Override @Override
public BiomeType getBiome(BlockVector3 position) { public BiomeType getBiome(BlockVector3 position) {
mutable.mutX(position.getBlockX()); mutable.mutX(position.x());
mutable.mutZ(position.getBlockZ()); mutable.mutZ(position.z());
mutable.mutY(position.getBlockY()); mutable.mutY(position.y());
return super.getBiome(getPos(mutable.getX(), mutable.getY(), mutable.getZ())); return super.getBiome(getPos(mutable.x(), mutable.y(), mutable.z()));
} }
@Override @Override
@ -92,10 +92,10 @@ public class PositionTransformExtent extends ResettableExtent {
@Override @Override
public boolean setBiome(BlockVector3 position, BiomeType biome) { public boolean setBiome(BlockVector3 position, BiomeType biome) {
mutable.mutX(position.getBlockX()); mutable.mutX(position.x());
mutable.mutZ(position.getBlockZ()); mutable.mutZ(position.z());
mutable.mutY(position.getBlockY()); mutable.mutY(position.y());
return super.setBiome(getPos(mutable.getX(), mutable.getY(), mutable.getZ()), biome); return super.setBiome(getPos(mutable.x(), mutable.y(), mutable.z()), biome);
} }
public void setTransform(Transform transform) { public void setTransform(Transform transform) {

View File

@ -80,12 +80,12 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
@Override @Override
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block)
throws WorldEditException { throws WorldEditException {
return setBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block); return setBlock(location.x(), location.y(), location.z(), block);
} }
@Override @Override
public BlockState getBlock(BlockVector3 location) { public BlockState getBlock(BlockVector3 location) {
return getBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ()); return getBlock(location.x(), location.y(), location.z());
} }
@Override @Override

View File

@ -41,8 +41,8 @@ public class SourceMaskExtent extends TemporalExtent {
@Override @Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException { public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
set(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block); set(location.x(), location.y(), location.z(), block);
return mask.test(location) && super.setBlock(location.getX(), location.getY(), location.getZ(), block); return mask.test(location) && super.setBlock(location.x(), location.y(), location.z(), block);
} }
@Override @Override

View File

@ -44,7 +44,7 @@ public class TemporalExtent extends PassthroughExtent {
@Override @Override
public BlockState getBlock(BlockVector3 position) { public BlockState getBlock(BlockVector3 position) {
if (position.getX() == x && position.getY() == y && position.getZ() == z) { if (position.x() == x && position.y() == y && position.z() == z) {
return block.toImmutableState(); return block.toImmutableState();
} }
return super.getBlock(position); return super.getBlock(position);
@ -60,7 +60,7 @@ public class TemporalExtent extends PassthroughExtent {
@Override @Override
public BaseBlock getFullBlock(BlockVector3 position) { public BaseBlock getFullBlock(BlockVector3 position) {
if (position.getX() == x && position.getY() == y && position.getZ() == z) { if (position.x() == x && position.y() == y && position.z() == z) {
if (block instanceof BaseBlock) { if (block instanceof BaseBlock) {
return (BaseBlock) block; return (BaseBlock) block;
} else { } else {
@ -72,7 +72,7 @@ public class TemporalExtent extends PassthroughExtent {
@Override @Override
public BiomeType getBiome(BlockVector3 position) { public BiomeType getBiome(BlockVector3 position) {
if (position.getX() == bx && position.getZ() == bz) { if (position.x() == bx && position.z() == bz) {
return biome; return biome;
} }
return super.getBiome(position); return super.getBiome(position);

View File

@ -55,13 +55,13 @@ public class TransformExtent extends BlockTransformExtent {
if (min == null) { if (min == null) {
min = pos; min = pos;
} }
mutable1.mutX(pos.getX() - min.getX()); mutable1.mutX(pos.x() - min.x());
mutable1.mutY(pos.getY() - min.getY()); mutable1.mutY(pos.y() - min.y());
mutable1.mutZ(pos.getZ() - min.getZ()); mutable1.mutZ(pos.z() - min.z());
Vector3 tmp = getTransform().apply(mutable1); Vector3 tmp = getTransform().apply(mutable1);
mutable2.mutX(tmp.getX() + min.getX()); mutable2.mutX(tmp.x() + min.x());
mutable2.mutY(tmp.getY() + min.getY()); mutable2.mutY(tmp.y() + min.y());
mutable2.mutZ(tmp.getZ() + min.getZ()); mutable2.mutZ(tmp.z() + min.z());
return mutable2; return mutable2;
} }
@ -69,20 +69,20 @@ public class TransformExtent extends BlockTransformExtent {
if (min == null) { if (min == null) {
min = BlockVector3.at(x, y, z); min = BlockVector3.at(x, y, z);
} }
mutable1.mutX(x - min.getX()); mutable1.mutX(x - min.x());
mutable1.mutY(y - min.getY()); mutable1.mutY(y - min.y());
mutable1.mutZ(z - min.getZ()); mutable1.mutZ(z - min.z());
Vector3 tmp = getTransform().apply(mutable1); Vector3 tmp = getTransform().apply(mutable1);
mutable2.mutX(tmp.getX() + min.getX()); mutable2.mutX(tmp.x() + min.x());
mutable2.mutY(tmp.getY() + min.getY()); mutable2.mutY(tmp.y() + min.y());
mutable2.mutZ(tmp.getZ() + min.getZ()); mutable2.mutZ(tmp.z() + min.z());
return tmp.toBlockPoint(); return tmp.toBlockPoint();
} }
@Override @Override
public BlockState getBlock(int x, int y, int z) { public BlockState getBlock(int x, int y, int z) {
BlockVector3 p = getPos(x, y, z); BlockVector3 p = getPos(x, y, z);
return transform(super.getBlock(p.getX(), p.getY(), p.getZ())); return transform(super.getBlock(p.x(), p.y(), p.z()));
} }
@Override @Override
@ -93,7 +93,7 @@ public class TransformExtent extends BlockTransformExtent {
@Override @Override
public BiomeType getBiomeType(int x, int y, int z) { public BiomeType getBiomeType(int x, int y, int z) {
BlockVector3 p = getPos(x, y, z); BlockVector3 p = getPos(x, y, z);
return super.getBiomeType(p.getX(), y, p.getZ()); return super.getBiomeType(p.x(), y, p.z());
} }
@Override @Override
@ -114,7 +114,7 @@ public class TransformExtent extends BlockTransformExtent {
@Override @Override
public boolean setBiome(int x, int y, int z, BiomeType biome) { public boolean setBiome(int x, int y, int z, BiomeType biome) {
BlockVector3 p = getPos(x, y, z); BlockVector3 p = getPos(x, y, z);
return super.setBiome(p.getX(), p.getY(), p.getZ(), biome); return super.setBiome(p.x(), p.y(), p.z(), biome);
} }
} }

View File

@ -41,7 +41,7 @@ public class CPUOptimizedClipboard extends LinearClipboard {
@Override @Override
public boolean setBiome(BlockVector3 position, BiomeType biome) { public boolean setBiome(BlockVector3 position, BiomeType biome) {
return setBiome(position.getX(), position.getY(), position.getZ(), biome); return setBiome(position.x(), position.y(), position.z(), biome);
} }
@Override @Override
@ -92,7 +92,7 @@ public class CPUOptimizedClipboard extends LinearClipboard {
@Override @Override
public BiomeType getBiome(BlockVector3 position) { public BiomeType getBiome(BlockVector3 position) {
return getBiome(getBiomeIndex(position.getX(), position.getY(), position.getZ())); return getBiome(getBiomeIndex(position.x(), position.y(), position.z()));
} }
public void convertTilesToIndex() { public void convertTilesToIndex() {

View File

@ -359,7 +359,7 @@ public class DiskOptimizedClipboard extends LinearClipboard {
@Override @Override
public boolean setBiome(BlockVector3 position, BiomeType biome) { public boolean setBiome(BlockVector3 position, BiomeType biome) {
return setBiome(position.getX(), position.getY(), position.getZ(), biome); return setBiome(position.x(), position.y(), position.z(), biome);
} }
@Override @Override
@ -417,7 +417,7 @@ public class DiskOptimizedClipboard extends LinearClipboard {
@Override @Override
public BiomeType getBiome(BlockVector3 position) { public BiomeType getBiome(BlockVector3 position) {
return getBiome(getBiomeIndex(position.getX(), position.getY(), position.getZ())); return getBiome(getBiomeIndex(position.x(), position.y(), position.z()));
} }
public BlockArrayClipboard toClipboard() { public BlockArrayClipboard toClipboard() {
@ -438,9 +438,9 @@ public class DiskOptimizedClipboard extends LinearClipboard {
super.setOrigin(origin); super.setOrigin(origin);
origin = origin.subtract(offset); origin = origin.subtract(offset);
try { try {
byteBuffer.putShort(10, (short) origin.getBlockX()); byteBuffer.putShort(10, (short) origin.x());
byteBuffer.putShort(12, (short) origin.getBlockY()); byteBuffer.putShort(12, (short) origin.y());
byteBuffer.putShort(14, (short) origin.getBlockZ()); byteBuffer.putShort(14, (short) origin.z());
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -450,9 +450,9 @@ public class DiskOptimizedClipboard extends LinearClipboard {
protected void setOffset(BlockVector3 offset) { protected void setOffset(BlockVector3 offset) {
super.setOffset(offset); super.setOffset(offset);
try { try {
byteBuffer.putShort(16, (short) offset.getBlockX()); byteBuffer.putShort(16, (short) offset.x());
byteBuffer.putShort(18, (short) offset.getBlockY()); byteBuffer.putShort(18, (short) offset.y());
byteBuffer.putShort(20, (short) offset.getBlockZ()); byteBuffer.putShort(20, (short) offset.z());
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -588,9 +588,9 @@ public class DiskOptimizedClipboard extends LinearClipboard {
CompoundTag data = entity.getState().getNbtData(); CompoundTag data = entity.getState().getNbtData();
HashMap<String, Tag> value = new HashMap<>(data.getValue()); HashMap<String, Tag> value = new HashMap<>(data.getValue());
List<DoubleTag> pos = new ArrayList<>(3); List<DoubleTag> pos = new ArrayList<>(3);
pos.add(new DoubleTag(entity.getLocation().getX())); pos.add(new DoubleTag(entity.getLocation().x()));
pos.add(new DoubleTag(entity.getLocation().getX())); pos.add(new DoubleTag(entity.getLocation().x()));
pos.add(new DoubleTag(entity.getLocation().getX())); pos.add(new DoubleTag(entity.getLocation().x()));
value.put("Pos", new ListTag(DoubleTag.class, pos)); value.put("Pos", new ListTag(DoubleTag.class, pos));
nbtOS.writeTag(new CompoundTag(value)); nbtOS.writeTag(new CompoundTag(value));
} }

View File

@ -64,7 +64,7 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
@Override @Override
public boolean setBiome(BlockVector3 position, BiomeType biome) { public boolean setBiome(BlockVector3 position, BiomeType biome) {
return setBiome(position.getX(), position.getY(), position.getZ(), biome); return setBiome(position.x(), position.y(), position.z(), biome);
} }
@Override @Override
@ -115,7 +115,7 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
@Override @Override
public BiomeType getBiome(BlockVector3 position) { public BiomeType getBiome(BlockVector3 position) {
return getBiome(getBiomeIndex(position.getX(), position.getY(), position.getZ())); return getBiome(getBiomeIndex(position.x(), position.y(), position.z()));
} }
private int getOrdinal(int index) { private int getOrdinal(int index) {

View File

@ -70,17 +70,17 @@ public abstract class SimpleClipboard implements Clipboard {
@Override @Override
public final int getWidth() { public final int getWidth() {
return size.getBlockX(); return size.x();
} }
@Override @Override
public final int getHeight() { public final int getHeight() {
return size.getBlockY(); return size.y();
} }
@Override @Override
public final int getLength() { public final int getLength() {
return size.getBlockZ(); return size.z();
} }
@Override @Override

View File

@ -56,7 +56,7 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
@Override @Override
public BiomeType getBiome(BlockVector3 position) { public BiomeType getBiome(BlockVector3 position) {
return getExtent().getBiomeType(position.getX(), position.getY(), position.getZ()); return getExtent().getBiomeType(position.x(), position.y(), position.z());
} }
@Override @Override

View File

@ -396,8 +396,8 @@ public class FastSchematicReader extends NBTSchematicReader {
int locY = loc.getBlockY(); int locY = loc.getBlockY();
int locZ = loc.getBlockZ(); int locZ = loc.getBlockZ();
BlockVector3 max = min.add(dimensions).subtract(BlockVector3.ONE); BlockVector3 max = min.add(dimensions).subtract(BlockVector3.ONE);
if (locX < min.getX() || locY < min.getY() || locZ < min.getZ() if (locX < min.x() || locY < min.y() || locZ < min.z()
|| locX > max.getX() || locY > max.getY() || locZ > max.getZ()) { || locX > max.x() || locY > max.y() || locZ > max.z()) {
for (Entity e : clipboard.getEntities()) { for (Entity e : clipboard.getEntities()) {
clipboard.removeEntity(e); clipboard.removeEntity(e);
} }

View File

@ -114,15 +114,15 @@ public class FastSchematicWriter implements ClipboardWriter {
// The Sponge format Offset refers to the 'min' points location in the world. That's our 'Origin' // The Sponge format Offset refers to the 'min' points location in the world. That's our 'Origin'
out.writeNamedTag("Offset", new int[]{ out.writeNamedTag("Offset", new int[]{
min.getBlockX(), min.x(),
min.getBlockY(), min.y(),
min.getBlockZ(), min.z(),
}); });
out.writeLazyCompoundTag("Metadata", out1 -> { out.writeLazyCompoundTag("Metadata", out1 -> {
out1.writeNamedTag("WEOffsetX", offset.getBlockX()); out1.writeNamedTag("WEOffsetX", offset.x());
out1.writeNamedTag("WEOffsetY", offset.getBlockY()); out1.writeNamedTag("WEOffsetY", offset.y());
out1.writeNamedTag("WEOffsetZ", offset.getBlockZ()); out1.writeNamedTag("WEOffsetZ", offset.z());
out1.writeNamedTag("FAWEVersion", Fawe.instance().getVersion().build); out1.writeNamedTag("FAWEVersion", Fawe.instance().getVersion().build);
}); });
@ -162,9 +162,9 @@ public class FastSchematicWriter implements ClipboardWriter {
// Dum. // Dum.
values.remove("id"); values.remove("id");
values.put("Pos", new IntArrayTag(new int[]{ values.put("Pos", new IntArrayTag(new int[]{
pos.getX(), pos.x(),
pos.getY(), pos.y(),
pos.getZ() pos.z()
})); }));
numTiles++; numTiles++;
@ -237,7 +237,7 @@ public class FastSchematicWriter implements ClipboardWriter {
if (!brokenEntities) { if (!brokenEntities) {
loc = loc.setPosition(loc.add(min.toVector3())); loc = loc.setPosition(loc.add(min.toVector3()));
} }
values.put("Id", new StringTag(state.getType().getId())); values.put("Id", new StringTag(state.getType().id()));
values.put("Pos", writeVector(loc)); values.put("Pos", writeVector(loc));
values.put("Rotation", writeRotation(entity.getLocation())); values.put("Rotation", writeRotation(entity.getLocation()));
@ -282,10 +282,10 @@ public class FastSchematicWriter implements ClipboardWriter {
int length = clipboard.getRegion().getLength(); int length = clipboard.getRegion().getLength();
MutableBlockVector3 mutable = new MutableBlockVector3(); MutableBlockVector3 mutable = new MutableBlockVector3();
for (int z = 0, i = 0; z < length; z++) { for (int z = 0, i = 0; z < length; z++) {
int z0 = min.getBlockZ() + z; int z0 = min.z() + z;
for (int x = 0; x < width; x++, i++) { for (int x = 0; x < width; x++, i++) {
int x0 = min.getBlockX() + x; int x0 = min.x() + x;
BiomeType biome = clipboard.getBiome(mutable.setComponents(x0, min.getY(), z0)); BiomeType biome = clipboard.getBiome(mutable.setComponents(x0, min.y(), z0));
task.applyInt(i, biome.getInternalId()); task.applyInt(i, biome.getInternalId());
} }
} }
@ -297,7 +297,7 @@ public class FastSchematicWriter implements ClipboardWriter {
for (int i = 0; i < paletteList.size(); i++) { for (int i = 0; i < paletteList.size(); i++) {
int ordinal = paletteList.get(i); int ordinal = paletteList.get(i);
BiomeType state = BiomeTypes.get(ordinal); BiomeType state = BiomeTypes.get(ordinal);
out12.writeNamedTag(state.getId(), i); out12.writeNamedTag(state.id(), i);
} }
}); });

View File

@ -183,7 +183,7 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
indexes.put(combined, (Integer) palette.size()); indexes.put(combined, (Integer) palette.size());
HashMap<String, Object> paletteEntry = new HashMap<>(); HashMap<String, Object> paletteEntry = new HashMap<>();
paletteEntry.put("Name", type.getId()); paletteEntry.put("Name", type.id());
if (block.getInternalId() != type.getInternalId()) { if (block.getInternalId() != type.getInternalId()) {
Map<String, Object> properties = null; Map<String, Object> properties = null;
for (AbstractProperty property : (List<AbstractProperty<?>>) type.getProperties()) { for (AbstractProperty property : (List<AbstractProperty<?>>) type.getProperties()) {
@ -213,8 +213,8 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
if (block.getBlockType() != BlockTypes.STRUCTURE_VOID) { if (block.getBlockType() != BlockTypes.STRUCTURE_VOID) {
int combined = block.getInternalId(); int combined = block.getInternalId();
int index = indexes.get(combined); int index = indexes.get(combined);
List<Integer> pos = Arrays.asList(point.getX() - min.getX(), List<Integer> pos = Arrays.asList(point.x() - min.x(),
point.getY() - min.getY(), point.getZ() - min.getZ() point.y() - min.y(), point.z() - min.z()
); );
if (!block.hasNbtData()) { if (!block.hasNbtData()) {
blocks.add(FaweCache.INSTANCE.asMap("state", index, "pos", pos)); blocks.add(FaweCache.INSTANCE.asMap("state", index, "pos", pos));
@ -231,16 +231,16 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
ArrayList<Map<String, Object>> entities = new ArrayList<>(); ArrayList<Map<String, Object>> entities = new ArrayList<>();
for (Entity entity : clipboard.getEntities()) { for (Entity entity : clipboard.getEntities()) {
Location loc = entity.getLocation(); Location loc = entity.getLocation();
List<Double> pos = Arrays.asList(loc.getX(), loc.getY(), loc.getZ()); List<Double> pos = Arrays.asList(loc.x(), loc.y(), loc.z());
List<Integer> blockPos = Arrays.asList(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); List<Integer> blockPos = Arrays.asList(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
BaseEntity state = entity.getState(); BaseEntity state = entity.getState();
if (state != null) { if (state != null) {
CompoundTag nbt = state.getNbtData(); CompoundTag nbt = state.getNbtData();
Map<String, Tag> nbtMap = nbt.getValue(); Map<String, Tag> nbtMap = new HashMap<>(nbt.getValue());
// Replace rotation data // Replace rotation data
nbtMap.put("Rotation", writeRotation(entity.getLocation())); nbtMap.put("Rotation", writeRotation(entity.getLocation()));
nbtMap.put("id", new StringTag(state.getType().getId())); nbtMap.put("id", new StringTag(state.getType().id()));
Map<String, Object> entityMap = FaweCache.INSTANCE.asMap("pos", pos, "blockPos", blockPos, "nbt", nbt); Map<String, Object> entityMap = FaweCache.INSTANCE.asMap("pos", pos, "blockPos", blockPos, "nbt", new CompoundTag(nbtMap));
entities.add(entityMap); entities.add(entityMap);
} }
} }

Some files were not shown because too many files have changed in this diff Show More