From 2224202ed557443c8ccdda5c9e4a692d80d7dcb1 Mon Sep 17 00:00:00 2001 From: drullkus Date: Mon, 18 Dec 2023 17:35:40 -0800 Subject: [PATCH] Fix last of compile problems --- build.gradle | 2 +- .../extension/platform/Annotations.java | 38 +++++++++++++++++++ .../sk89q/worldedit/forge/ForgePlayer.java | 11 +++++- .../com/sk89q/worldedit/forge/ForgeWorld.java | 2 +- .../forge/net/handler/PacketHandlerUtil.java | 29 +++++++------- .../forge/net/handler/WECUIPacketHandler.java | 9 +---- .../resources/META-INF/accesstransformer.cfg | 14 +++---- src/main/resources/META-INF/mods.toml | 10 ++--- 8 files changed, 78 insertions(+), 37 deletions(-) create mode 100644 src/main/java/com/sk89q/worldedit/extension/platform/Annotations.java diff --git a/build.gradle b/build.gradle index 1a24a56..ee43d08 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ base { // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) -//minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg') +minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg') //minecraft.accessTransformers.entry public net.minecraft.client.Minecraft textureManager # textureManager // Default run configurations. diff --git a/src/main/java/com/sk89q/worldedit/extension/platform/Annotations.java b/src/main/java/com/sk89q/worldedit/extension/platform/Annotations.java new file mode 100644 index 0000000..399b183 --- /dev/null +++ b/src/main/java/com/sk89q/worldedit/extension/platform/Annotations.java @@ -0,0 +1,38 @@ +/* + * 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.extension.platform; + +import com.google.auto.value.AutoAnnotation; +import com.sk89q.worldedit.internal.annotation.Radii; + +/** + * Holder for generated annotation classes. + */ +class Annotations { + + @AutoAnnotation + static Radii radii(int value) { + return new AutoAnnotation_Annotations_radii(value); + } + + private Annotations() { + } + +} diff --git a/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java b/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java index 41dc8a2..7452011 100644 --- a/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java +++ b/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java @@ -35,6 +35,7 @@ import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.formatting.WorldEditText; import com.sk89q.worldedit.util.formatting.component.TextUtils; +import io.netty.buffer.ByteBuf; import net.kyori.text.Component; import net.kyori.text.serializer.gson.GsonComponentSerializer; import com.sk89q.worldedit.world.World; @@ -45,8 +46,10 @@ import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket; import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket; +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; @@ -131,8 +134,12 @@ public void dispatchCUIEvent(CUIEvent event) { if (params.length > 0) { send = send + "|" + StringUtil.joinString(params, "|"); } - FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.copiedBuffer(send, StandardCharsets.UTF_8)); - WECUIPacketHandler.send(this.player.connection.connection, buffer); + + FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.buffer()); + buffer.writeResourceLocation(new ResourceLocation(ForgeWorldEdit.MOD_ID, ForgeWorldEdit.CUI_PLUGIN_CHANNEL)); + buffer.writeBytes(Unpooled.copiedBuffer(send, StandardCharsets.UTF_8)); + ClientboundCustomPayloadPacket packet = new ClientboundCustomPayloadPacket(buffer); + this.player.connection.send(packet); } private void sendMessage(net.minecraft.network.chat.Component textComponent) { diff --git a/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java b/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java index d478503..6600db6 100644 --- a/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java +++ b/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java @@ -409,7 +409,7 @@ private List> submitChunkLoadTasks(Region region, ); } return chunkLoadings; - } + }//*/ @Nullable private static ResourceKey> createTreeFeatureGenerator(TreeType type) { diff --git a/src/main/java/com/sk89q/worldedit/forge/net/handler/PacketHandlerUtil.java b/src/main/java/com/sk89q/worldedit/forge/net/handler/PacketHandlerUtil.java index 9bacaef..a17116a 100644 --- a/src/main/java/com/sk89q/worldedit/forge/net/handler/PacketHandlerUtil.java +++ b/src/main/java/com/sk89q/worldedit/forge/net/handler/PacketHandlerUtil.java @@ -21,25 +21,28 @@ import com.sk89q.worldedit.forge.ForgeWorldEdit; import net.minecraft.resources.ResourceLocation; +import net.neoforged.neoforge.network.NetworkRegistry; + +import java.util.function.Predicate; final class PacketHandlerUtil { private PacketHandlerUtil() { } - static ChannelBuilder buildLenientHandler(String id, int protocolVersion) { - final Channel.VersionTest validator = validateLenient(protocolVersion); - return ChannelBuilder - .named(new ResourceLocation(ForgeWorldEdit.MOD_ID, id)) - .clientAcceptedVersions(validator) - .serverAcceptedVersions(validator) - .networkProtocolVersion(protocolVersion); + static NetworkRegistry.ChannelBuilder buildLenientHandler(String id, int protocolVersion) { + final String verStr = Integer.toString(protocolVersion); + final Predicate validator = validateLenient(verStr); + return NetworkRegistry.ChannelBuilder + .named(new ResourceLocation(ForgeWorldEdit.MOD_ID, id)) + .clientAcceptedVersions(validator) + .serverAcceptedVersions(validator) + .networkProtocolVersion(() -> verStr); } - private static Channel.VersionTest validateLenient(int protocolVersion) { - return (status, remoteVersion) -> - protocolVersion == remoteVersion - // These two ignore protocolVersion anyway so it doesn't matter what it is - || Channel.VersionTest.ACCEPT_MISSING.accepts(status, protocolVersion) - || Channel.VersionTest.ACCEPT_VANILLA.accepts(status, protocolVersion); + private static Predicate validateLenient(String protocolVersion) { + return remoteVersion -> + protocolVersion.equals(remoteVersion) + || NetworkRegistry.ABSENT.version().equals(remoteVersion) + || NetworkRegistry.ACCEPTVANILLA.equals(remoteVersion); } } diff --git a/src/main/java/com/sk89q/worldedit/forge/net/handler/WECUIPacketHandler.java b/src/main/java/com/sk89q/worldedit/forge/net/handler/WECUIPacketHandler.java index c15c6e9..ef3b1f9 100644 --- a/src/main/java/com/sk89q/worldedit/forge/net/handler/WECUIPacketHandler.java +++ b/src/main/java/com/sk89q/worldedit/forge/net/handler/WECUIPacketHandler.java @@ -22,8 +22,6 @@ import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.forge.ForgePlayer; import com.sk89q.worldedit.forge.ForgeWorldEdit; -import net.minecraft.network.Connection; -import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerPlayer; import net.neoforged.neoforge.network.NetworkEvent; import net.neoforged.neoforge.network.event.EventNetworkChannel; @@ -45,16 +43,11 @@ public static void init() { HANDLER.addListener(WECUIPacketHandler::onPacketData); } - public static void onPacketData(NetworkEvent.ServerCustomPayloadEvent event) { + public static void onPacketData(NetworkEvent.ClientCustomPayloadEvent event) { ServerPlayer player = event.getSource().getSender(); LocalSession session = ForgeWorldEdit.inst.getSession(player); String text = event.getPayload().toString(StandardCharsets.UTF_8); final ForgePlayer actor = adaptPlayer(player); session.handleCUIInitializationMessage(text, actor); } - - public static void send(Connection connection, FriendlyByteBuf friendlyByteBuf) { - HANDLER.send(friendlyByteBuf, connection); - } - } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 40da83a..edaccd5 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -1,11 +1,11 @@ -public net.minecraft.server.MinecraftServer f_129726_ # nextTickTime +public net.minecraft.server.MinecraftServer nextTickTimeNanos # For regen -public net.minecraft.server.MinecraftServer f_129744_ # storageSource -public net.minecraft.server.level.ServerChunkCache f_8332_ # mainThreadProcessor -public net.minecraft.server.level.ServerChunkCache m_8456_(IILnet/minecraft/world/level/chunk/ChunkStatus;Z)Ljava/util/concurrent/CompletableFuture; # getChunkFutureMainThread +public net.minecraft.server.MinecraftServer storageSource +public net.minecraft.server.level.ServerChunkCache mainThreadProcessor +public net.minecraft.server.level.ServerChunkCache getChunkFutureMainThread(IILnet/minecraft/world/level/chunk/ChunkStatus;Z)Ljava/util/concurrent/CompletableFuture; -public net.minecraft.world.level.chunk.ChunkBiomeContainer f_62112_ # biomes -public-f net.minecraft.world.level.storage.PrimaryLevelData f_244409_ # worldOptions +public net.minecraft.world.level.chunk.ChunkBiomeContainer biomes +public-f net.minecraft.world.level.storage.PrimaryLevelData worldOptions -public net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket (Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/BlockEntityType;Lnet/minecraft/nbt/CompoundTag;)V # constructor +public net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket (Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/BlockEntityType;Lnet/minecraft/nbt/CompoundTag;)V diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 3a6a8a8..f8f08bb 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,7 +1,7 @@ # The name of the mod loader type to load - for regular FML @Mod mods it should be javafml modLoader="javafml" # A version range to match for said mod loader - for regular FML @Mod it will be the minecraft version (without the 1.) -loaderVersion="[24,)" +loaderVersion="[1,)" # A URL to refer people to when problems occur with this mod issueTrackerURL="https://discord.gg/enginehub" # A URL for the "homepage" for this mod, displayed in the mod UI @@ -16,7 +16,7 @@ license="GPL" # The modid of the mod modId="worldedit" # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it -version="${version}" +version="7.2-custom_neoforged" # A display name for the mod displayName="WorldEdit" # The description text for the mod (multi line!) @@ -26,12 +26,12 @@ WorldEdit is an easy-to-use in-game world editor for Minecraft, supporting both [[dependencies.worldedit]] modId="minecraft" mandatory=true - versionRange="[${minecraftVersion},${nextMajorMinecraftVersion})" + versionRange="[1.20.3,)" ordering="NONE" side="BOTH" [[dependencies.worldedit]] - modId="forge" + modId="neoforge" mandatory=true - versionRange="[${forgeVersion},)" + versionRange="[20.3.1,)" ordering="NONE" side="BOTH"