From c4c5a6c9ed473d09493f57bd9da1a6a0f6a0593b Mon Sep 17 00:00:00 2001 From: Octavia Togami Date: Mon, 18 Sep 2023 21:20:56 -0700 Subject: [PATCH] [Fabric] 1.20.2-rc2, remove many mixins in favor of AW --- gradle.properties | 2 +- worldedit-fabric/build.gradle.kts | 45 +++---------------- .../sk89q/worldedit/fabric/FabricPlayer.java | 10 ++--- .../sk89q/worldedit/fabric/FabricWorld.java | 32 ++++++------- .../worldedit/fabric/WorldEditFakePlayer.java | 5 ++- ...essorClientboundBlockEntityDataPacket.java | 35 --------------- .../mixin/AccessorDerivedLevelData.java | 32 ------------- .../mixin/AccessorPrimaryLevelData.java | 36 --------------- .../mixin/AccessorServerChunkCache.java | 42 ----------------- .../mixin/AccessorServerPlayerGameMode.java | 31 ------------- .../mixin/MixinLevelChunkSetBlockHook.java | 3 ++ .../fabric/mixin/MixinMinecraftServer.java | 3 ++ .../MixinServerGamePacketListenerImpl.java | 4 +- .../resources/worldedit-fabric.mixins.json | 5 --- .../main/resources/worldedit.accesswidener | 14 +++++- 15 files changed, 56 insertions(+), 243 deletions(-) delete mode 100644 worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorClientboundBlockEntityDataPacket.java delete mode 100644 worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorDerivedLevelData.java delete mode 100644 worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorPrimaryLevelData.java delete mode 100644 worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorServerChunkCache.java delete mode 100644 worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorServerPlayerGameMode.java diff --git a/gradle.properties b/gradle.properties index 48bcfc079d..ca1eb94b3c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,5 +4,5 @@ version=7.2.16-SNAPSHOT org.gradle.jvmargs=-Xmx2G org.gradle.parallel=true -loom.version=1.2.7 +loom.version=1.3.9 mixin.version=0.12.5+mixin.0.8.5 diff --git a/worldedit-fabric/build.gradle.kts b/worldedit-fabric/build.gradle.kts index 1f8c9958ef..93c3140bf5 100644 --- a/worldedit-fabric/build.gradle.kts +++ b/worldedit-fabric/build.gradle.kts @@ -1,5 +1,6 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import net.fabricmc.loom.api.LoomGradleExtensionAPI +import net.fabricmc.loom.configuration.FabricApiExtension import net.fabricmc.loom.task.RemapJarTask buildscript { @@ -21,7 +22,7 @@ applyShadowConfiguration() apply(plugin = "fabric-loom") apply(plugin = "java-library") -val minecraftVersion = "1.20.2-rc1" +val minecraftVersion = "1.20.2-rc2" val loaderVersion = "0.14.22" val fabricApiConfiguration: Configuration = configurations.create("fabricApi") @@ -52,52 +53,20 @@ dependencies { "mappings"(project.the().officialMojangMappings()) "modImplementation"("net.fabricmc:fabric-loader:$loaderVersion") - // [1] declare fabric-api dependency... - "fabricApi"("net.fabricmc.fabric-api:fabric-api:0.88.5+1.20.2") - // [2] Load the API dependencies from the fabric mod json... + // [1] Load the API dependencies from the fabric mod json... @Suppress("UNCHECKED_CAST") val fabricModJson = file("src/main/resources/fabric.mod.json").bufferedReader().use { groovy.json.JsonSlurper().parse(it) as Map> } val wantedDependencies = (fabricModJson["depends"] ?: error("no depends in fabric.mod.json")).keys .filter { it == "fabric-api-base" || it.contains(Regex("v\\d$")) } - .map { "net.fabricmc.fabric-api:$it" } .toSet() - logger.lifecycle("Looking for these dependencies:") + // [2] Request the matching dependency from fabric-loom for (wantedDependency in wantedDependencies) { - logger.lifecycle(wantedDependency) - } - // [3] and now we resolve it to pick out what we want :D - val fabricApiDependencies = fabricApiConfiguration.incoming.resolutionResult.allDependencies - .onEach { - if (it is UnresolvedDependencyResult) { - throw kotlin.IllegalStateException("Failed to resolve Fabric API", it.failure) - } - } - .filterIsInstance() - // pick out transitive dependencies - .flatMap { - it.selected.dependencies - } - // grab the requested versions - .map { it.requested } - .filterIsInstance() - // map to standard notation - .associateByTo( - mutableMapOf(), - keySelector = { "${it.group}:${it.module}" }, - valueTransform = { "${it.group}:${it.module}:${it.version}" } - ) - fabricApiDependencies.keys.retainAll(wantedDependencies) - // sanity check - for (wantedDep in wantedDependencies) { - check(wantedDep in fabricApiDependencies) { "Fabric API library $wantedDep is missing!" } - } - - fabricApiDependencies.values.forEach { - "include"(it) - "modImplementation"(it) + val dep = project.the().module(wantedDependency, "0.89.0+1.20.2") + "include"(dep) + "modImplementation"(dep) } // No need for this at runtime diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java index 1472d396e1..244283bd7d 100644 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java +++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java @@ -26,7 +26,6 @@ import com.sk89q.worldedit.extension.platform.AbstractPlayerActor; import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.fabric.internal.NBTConverter; -import com.sk89q.worldedit.fabric.mixin.AccessorClientboundBlockEntityDataPacket; import com.sk89q.worldedit.fabric.net.handler.WECUIPacketHandler; import com.sk89q.worldedit.internal.cui.CUIEvent; import com.sk89q.worldedit.math.BlockVector3; @@ -48,6 +47,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -243,10 +243,10 @@ public > void sendFakeBlock(BlockVector3 pos, B bl if (block instanceof BaseBlock && block.getBlockType().equals(BlockTypes.STRUCTURE_BLOCK)) { final CompoundTag nbtData = ((BaseBlock) block).getNbtData(); if (nbtData != null) { - player.connection.send(AccessorClientboundBlockEntityDataPacket.construct( - new BlockPos(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()), - BlockEntityType.STRUCTURE_BLOCK, - NBTConverter.toNative(nbtData)) + player.connection.send(new ClientboundBlockEntityDataPacket( + new BlockPos(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()), + BlockEntityType.STRUCTURE_BLOCK, + NBTConverter.toNative(nbtData)) ); } } diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricWorld.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricWorld.java index 10b4826704..babed05a44 100644 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricWorld.java +++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricWorld.java @@ -38,9 +38,6 @@ import com.sk89q.worldedit.fabric.internal.ExtendedMinecraftServer; import com.sk89q.worldedit.fabric.internal.FabricWorldNativeAccess; import com.sk89q.worldedit.fabric.internal.NBTConverter; -import com.sk89q.worldedit.fabric.mixin.AccessorDerivedLevelData; -import com.sk89q.worldedit.fabric.mixin.AccessorPrimaryLevelData; -import com.sk89q.worldedit.fabric.mixin.AccessorServerChunkCache; import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask2D; @@ -96,8 +93,10 @@ import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.levelgen.WorldOptions; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import net.minecraft.world.level.storage.DerivedLevelData; import net.minecraft.world.level.storage.LevelData; import net.minecraft.world.level.storage.LevelStorageSource; +import net.minecraft.world.level.storage.PrimaryLevelData; import net.minecraft.world.level.storage.ServerLevelData; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.BlockHitResult; @@ -323,20 +322,14 @@ private void doRegen(Region region, Extent extent, RegenOptions options) throws LevelStorageSource levelStorage = LevelStorageSource.createDefault(tempDir); try (LevelStorageSource.LevelStorageAccess session = levelStorage.createAccess("WorldEditTempGen")) { ServerLevel originalWorld = (ServerLevel) getWorld(); - AccessorPrimaryLevelData levelProperties; - if (originalWorld.getLevelData() instanceof AccessorDerivedLevelData derivedLevelData) { - levelProperties = (AccessorPrimaryLevelData) derivedLevelData.getWrapped(); - } else { - levelProperties = (AccessorPrimaryLevelData) originalWorld.getLevelData(); - } + PrimaryLevelData levelProperties = getPrimaryLevelData(originalWorld.getLevelData()); WorldOptions originalOpts = levelProperties.worldGenOptions(); long seed = options.getSeed().orElse(originalWorld.getSeed()); - WorldOptions newOpts = options.getSeed().isPresent() + levelProperties.worldOptions = options.getSeed().isPresent() ? originalOpts.withSeed(OptionalLong.of(seed)) : originalOpts; - levelProperties.setWorldOptions(newOpts); ResourceKey worldRegKey = originalWorld.dimension(); try (ServerLevel serverWorld = new ServerLevel( originalWorld.getServer(), Util.backgroundExecutor(), session, @@ -362,19 +355,29 @@ private void doRegen(Region region, Extent extent, RegenOptions options) throws Thread.yield(); } } finally { - levelProperties.setWorldOptions(originalOpts); + levelProperties.worldOptions = originalOpts; } } finally { SafeFiles.tryHardToDeleteDir(tempDir); } } + private static PrimaryLevelData getPrimaryLevelData(LevelData levelData) { + if (levelData instanceof DerivedLevelData derivedLevelData) { + return getPrimaryLevelData(derivedLevelData.wrapped); + } else if (levelData instanceof PrimaryLevelData primaryLevelData) { + return primaryLevelData; + } else { + throw new IllegalStateException("Unknown level data type: " + levelData.getClass()); + } + } + private void regenForWorld(Region region, Extent extent, ServerLevel serverWorld, RegenOptions options) throws WorldEditException { List> chunkLoadings = submitChunkLoadTasks(region, serverWorld); // drive executor until loading finishes - ((AccessorServerChunkCache) serverWorld.getChunkSource()).getMainThreadProcessor() + serverWorld.getChunkSource().mainThreadProcessor .managedBlock(() -> { // bail out early if a future fails if (chunkLoadings.stream().anyMatch(ftr -> @@ -411,12 +414,11 @@ private void regenForWorld(Region region, Extent extent, ServerLevel serverWorld } private List> submitChunkLoadTasks(Region region, ServerLevel world) { - AccessorServerChunkCache chunkManager = (AccessorServerChunkCache) world.getChunkSource(); List> chunkLoadings = new ArrayList<>(); // Pre-gen all the chunks for (BlockVector2 chunk : region.getChunks()) { chunkLoadings.add( - chunkManager.callGetChunkFuture(chunk.getX(), chunk.getZ(), ChunkStatus.FEATURES, true) + world.getChunkSource().getChunkFuture(chunk.getX(), chunk.getZ(), ChunkStatus.FEATURES, true) .thenApply(either -> either.left().orElse(null)) ); } diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/WorldEditFakePlayer.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/WorldEditFakePlayer.java index 009d512ffa..d5381ebe17 100644 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/WorldEditFakePlayer.java +++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/WorldEditFakePlayer.java @@ -33,9 +33,12 @@ public class WorldEditFakePlayer extends ServerPlayer { private static final GameProfile FAKE_WORLDEDIT_PROFILE = new GameProfile(UUID.nameUUIDFromBytes("worldedit".getBytes()), "[WorldEdit]"); + private static final ClientInformation FAKE_CLIENT_INFO = new ClientInformation( + "en_US", 16, ChatVisiblity.FULL, true, 0, HumanoidArm.LEFT, false, false + ); public WorldEditFakePlayer(ServerLevel world) { - super(world.getServer(), world, FAKE_WORLDEDIT_PROFILE, new ClientInformation("", 0, ChatVisiblity.FULL, false, 0, HumanoidArm.RIGHT, false, false)); + super(world.getServer(), world, FAKE_WORLDEDIT_PROFILE, FAKE_CLIENT_INFO); } @Override diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorClientboundBlockEntityDataPacket.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorClientboundBlockEntityDataPacket.java deleted file mode 100644 index 309770dcb6..0000000000 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorClientboundBlockEntityDataPacket.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * 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 . - */ - -package com.sk89q.worldedit.fabric.mixin; - -import net.minecraft.core.BlockPos; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; -import net.minecraft.world.level.block.entity.BlockEntityType; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Invoker; - -@Mixin(ClientboundBlockEntityDataPacket.class) -public interface AccessorClientboundBlockEntityDataPacket { - @Invoker("") - static ClientboundBlockEntityDataPacket construct(BlockPos blockPos, BlockEntityType blockEntityType, CompoundTag compoundTag) { - throw new AssertionError("This is replaced by Mixin to call the constructor."); - } -} diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorDerivedLevelData.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorDerivedLevelData.java deleted file mode 100644 index 8af17bc613..0000000000 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorDerivedLevelData.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * 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 . - */ - -package com.sk89q.worldedit.fabric.mixin; - -import net.minecraft.world.level.storage.DerivedLevelData; -import net.minecraft.world.level.storage.ServerLevelData; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(DerivedLevelData.class) -public interface AccessorDerivedLevelData extends ServerLevelData { - - @Accessor - ServerLevelData getWrapped(); -} diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorPrimaryLevelData.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorPrimaryLevelData.java deleted file mode 100644 index 14f2f00859..0000000000 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorPrimaryLevelData.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * 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 . - */ - -package com.sk89q.worldedit.fabric.mixin; - -import net.minecraft.world.level.levelgen.WorldOptions; -import net.minecraft.world.level.storage.PrimaryLevelData; -import net.minecraft.world.level.storage.WorldData; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(PrimaryLevelData.class) -public interface AccessorPrimaryLevelData extends WorldData { - - @Accessor - @Mutable - void setWorldOptions(WorldOptions worldOptions); - -} diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorServerChunkCache.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorServerChunkCache.java deleted file mode 100644 index e19ab0f688..0000000000 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorServerChunkCache.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * 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 . - */ - -package com.sk89q.worldedit.fabric.mixin; - -import com.mojang.datafixers.util.Either; -import net.minecraft.server.level.ChunkHolder; -import net.minecraft.server.level.ServerChunkCache; -import net.minecraft.world.level.chunk.ChunkAccess; -import net.minecraft.world.level.chunk.ChunkStatus; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; -import org.spongepowered.asm.mixin.gen.Invoker; - -import java.util.concurrent.CompletableFuture; - -@Mixin(ServerChunkCache.class) -public interface AccessorServerChunkCache { - - @Invoker - CompletableFuture> callGetChunkFuture(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create); - - @Accessor - ServerChunkCache.MainThreadExecutor getMainThreadProcessor(); - -} diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorServerPlayerGameMode.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorServerPlayerGameMode.java deleted file mode 100644 index c9aaaa62d3..0000000000 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorServerPlayerGameMode.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * 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 . - */ - -package com.sk89q.worldedit.fabric.mixin; - -import net.minecraft.server.level.ServerPlayerGameMode; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(ServerPlayerGameMode.class) -public interface AccessorServerPlayerGameMode { - - @Accessor("isDestroyingBlock") - boolean isDestroyingBlock(); -} diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/MixinLevelChunkSetBlockHook.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/MixinLevelChunkSetBlockHook.java index 6c0ef09cde..fe4813f65b 100644 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/MixinLevelChunkSetBlockHook.java +++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/MixinLevelChunkSetBlockHook.java @@ -34,6 +34,7 @@ import net.minecraft.world.level.chunk.UpgradeData; import net.minecraft.world.level.levelgen.blending.BlendingData; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.Slice; @@ -42,12 +43,14 @@ @Mixin(LevelChunk.class) public abstract class MixinLevelChunkSetBlockHook extends ChunkAccess implements ExtendedChunk { + @Unique private boolean shouldUpdate = true; public MixinLevelChunkSetBlockHook(ChunkPos chunkPos, UpgradeData upgradeData, LevelHeightAccessor levelHeightAccessor, Registry registry, long l, @org.jetbrains.annotations.Nullable LevelChunkSection[] levelChunkSections, @org.jetbrains.annotations.Nullable BlendingData blendingData) { super(chunkPos, upgradeData, levelHeightAccessor, registry, l, levelChunkSections, blendingData); } + @Unique @Nullable @Override public BlockState setBlockState(BlockPos pos, BlockState state, boolean moved, boolean update) { diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/MixinMinecraftServer.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/MixinMinecraftServer.java index c2fa3b572f..35d585e722 100644 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/MixinMinecraftServer.java +++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/MixinMinecraftServer.java @@ -28,6 +28,7 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import java.nio.file.Path; @@ -40,11 +41,13 @@ public abstract class MixinMinecraftServer implements Watchdog, ExtendedMinecraf @Shadow protected LevelStorageSource.LevelStorageAccess storageSource; + @Unique @Override public void tick() { nextTickTime = Util.getMillis(); } + @Unique @Override public Path getStoragePath(Level world) { return storageSource.getDimensionPath(world.dimension()); diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/MixinServerGamePacketListenerImpl.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/MixinServerGamePacketListenerImpl.java index ed238fda8b..5eb011f3ef 100644 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/MixinServerGamePacketListenerImpl.java +++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/MixinServerGamePacketListenerImpl.java @@ -26,6 +26,7 @@ import net.minecraft.server.network.ServerGamePacketListenerImpl; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -35,11 +36,12 @@ public class MixinServerGamePacketListenerImpl { @Shadow public ServerPlayer player; + @Unique private int ignoreSwingPackets; @Inject(method = "handleAnimate", at = @At("HEAD")) private void onAnimate(ServerboundSwingPacket packet, CallbackInfo ci) { - if (!((AccessorServerPlayerGameMode) this.player.gameMode).isDestroyingBlock()) { + if (!this.player.gameMode.isDestroyingBlock) { if (this.ignoreSwingPackets > 0) { this.ignoreSwingPackets--; } else if (FabricWorldEdit.inst != null) { diff --git a/worldedit-fabric/src/main/resources/worldedit-fabric.mixins.json b/worldedit-fabric/src/main/resources/worldedit-fabric.mixins.json index 410372dd76..232b19e65f 100644 --- a/worldedit-fabric/src/main/resources/worldedit-fabric.mixins.json +++ b/worldedit-fabric/src/main/resources/worldedit-fabric.mixins.json @@ -3,11 +3,6 @@ "package": "com.sk89q.worldedit.fabric.mixin", "compatibilityLevel": "JAVA_8", "mixins": [ - "AccessorClientboundBlockEntityDataPacket", - "AccessorPrimaryLevelData", - "AccessorDerivedLevelData", - "AccessorServerChunkCache", - "AccessorServerPlayerGameMode", "MixinLevelChunkSetBlockHook", "MixinMinecraftServer", "MixinServerGamePacketListenerImpl" diff --git a/worldedit-fabric/src/main/resources/worldedit.accesswidener b/worldedit-fabric/src/main/resources/worldedit.accesswidener index d0b388e223..88f77ce207 100644 --- a/worldedit-fabric/src/main/resources/worldedit.accesswidener +++ b/worldedit-fabric/src/main/resources/worldedit.accesswidener @@ -1,3 +1,15 @@ accessWidener v2 named + accessible class net/minecraft/server/level/ServerChunkCache$MainThreadExecutor -accessible field net/minecraft/commands/CommandSourceStack source Lnet/minecraft/commands/CommandSource; \ No newline at end of file +accessible field net/minecraft/server/level/ServerChunkCache mainThreadProcessor Lnet/minecraft/server/level/ServerChunkCache$MainThreadExecutor; + +accessible field net/minecraft/commands/CommandSourceStack source Lnet/minecraft/commands/CommandSource; + +accessible field net/minecraft/server/level/ServerPlayerGameMode isDestroyingBlock Z + +accessible field net/minecraft/world/level/storage/DerivedLevelData wrapped Lnet/minecraft/world/level/storage/ServerLevelData; + +accessible field net/minecraft/world/level/storage/PrimaryLevelData worldOptions Lnet/minecraft/world/level/levelgen/WorldOptions; +mutable field net/minecraft/world/level/storage/PrimaryLevelData worldOptions Lnet/minecraft/world/level/levelgen/WorldOptions; + +accessible method net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket (Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/BlockEntityType;Lnet/minecraft/nbt/CompoundTag;)V