From 4033c56b737c4434d1ef40a295051e8001cc0b1b Mon Sep 17 00:00:00 2001 From: drullkus Date: Sun, 7 Apr 2024 00:27:36 -0700 Subject: [PATCH] Port from beta to full-release Neoforge, drop WECUI support since we don't care for that --- gradle.properties | 6 +-- .../worldedit/neoforge/NeoForgeWorldEdit.java | 4 -- .../net/handler/PacketHandlerUtil.java | 48 ----------------- .../net/handler/WECUIPacketHandler.java | 53 ------------------- src/main/resources/META-INF/mods.toml | 4 +- 5 files changed, 5 insertions(+), 110 deletions(-) delete mode 100644 src/main/java/com/sk89q/worldedit/neoforge/net/handler/PacketHandlerUtil.java delete mode 100644 src/main/java/com/sk89q/worldedit/neoforge/net/handler/WECUIPacketHandler.java diff --git a/gradle.properties b/gradle.properties index 962e613..b435eef 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,9 +12,9 @@ minecraft_version=1.20.4 # as they do not follow standard versioning conventions. minecraft_version_range=[1.20.4,1.21) # The Neo version must agree with the Minecraft version to get a valid artifact -neo_version=20.4.42-beta +neo_version=20.4.223 # The Neo version range can use any version of Neo as bounds or match the loader version range -neo_version_range=[20.5,) +neo_version_range=[20.4,) # The loader version range can only use the major version of Neo/FML as bounds loader_version_range=[1,) @@ -28,7 +28,7 @@ mod_name=WorldEdit # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=GPL # The mod version. See https://semver.org/ -mod_version=1.0.0 +mod_version=1.0.1 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeWorldEdit.java b/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeWorldEdit.java index 29d6e44..aa30f5c 100644 --- a/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeWorldEdit.java +++ b/src/main/java/com/sk89q/worldedit/neoforge/NeoForgeWorldEdit.java @@ -31,7 +31,6 @@ import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extension.platform.PlatformManager; -import com.sk89q.worldedit.neoforge.net.handler.WECUIPacketHandler; import com.sk89q.worldedit.internal.anvil.ChunkDeleter; import com.sk89q.worldedit.internal.event.InteractionDebouncer; import com.sk89q.worldedit.internal.util.LogManagerCompat; @@ -59,7 +58,6 @@ import net.neoforged.bus.api.IEventBus; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.IExtensionPoint; -import net.neoforged.fml.ModContainer; import net.neoforged.fml.ModLoadingContext; import net.neoforged.fml.common.Mod; import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; @@ -152,8 +150,6 @@ private void init(FMLCommonSetupEvent event) { setupPlatform(); - WECUIPacketHandler.init(); - LOGGER.info("WorldEdit for NeoForge (version " + getInternalVersion() + ") is loaded"); } diff --git a/src/main/java/com/sk89q/worldedit/neoforge/net/handler/PacketHandlerUtil.java b/src/main/java/com/sk89q/worldedit/neoforge/net/handler/PacketHandlerUtil.java deleted file mode 100644 index 10bbb4a..0000000 --- a/src/main/java/com/sk89q/worldedit/neoforge/net/handler/PacketHandlerUtil.java +++ /dev/null @@ -1,48 +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.neoforge.net.handler; - -import com.sk89q.worldedit.neoforge.NeoForgeWorldEdit; -import net.minecraft.resources.ResourceLocation; -import net.neoforged.neoforge.network.NetworkRegistry; - -import java.util.function.Predicate; - -final class PacketHandlerUtil { - private PacketHandlerUtil() { - } - - 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(NeoForgeWorldEdit.MOD_ID, id)) - .clientAcceptedVersions(validator) - .serverAcceptedVersions(validator) - .networkProtocolVersion(() -> verStr); - } - - 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/neoforge/net/handler/WECUIPacketHandler.java b/src/main/java/com/sk89q/worldedit/neoforge/net/handler/WECUIPacketHandler.java deleted file mode 100644 index e3dadcb..0000000 --- a/src/main/java/com/sk89q/worldedit/neoforge/net/handler/WECUIPacketHandler.java +++ /dev/null @@ -1,53 +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.neoforge.net.handler; - -import com.sk89q.worldedit.LocalSession; -import com.sk89q.worldedit.neoforge.NeoForgePlayer; -import com.sk89q.worldedit.neoforge.NeoForgeWorldEdit; -import net.minecraft.server.level.ServerPlayer; -import net.neoforged.neoforge.network.NetworkEvent; -import net.neoforged.neoforge.network.event.EventNetworkChannel; - -import java.nio.charset.StandardCharsets; - -import static com.sk89q.worldedit.neoforge.NeoForgeAdapter.adaptPlayer; - -public final class WECUIPacketHandler { - private WECUIPacketHandler() { - } - - private static final int PROTOCOL_VERSION = 1; - private static final EventNetworkChannel HANDLER = PacketHandlerUtil - .buildLenientHandler(NeoForgeWorldEdit.CUI_PLUGIN_CHANNEL, PROTOCOL_VERSION) - .eventNetworkChannel(); - - public static void init() { - HANDLER.addListener(WECUIPacketHandler::onPacketData); - } - - public static void onPacketData(NetworkEvent.ClientCustomPayloadEvent event) { - ServerPlayer player = event.getSource().getSender(); - LocalSession session = NeoForgeWorldEdit.inst.getSession(player); - String text = event.getPayload().toString(StandardCharsets.UTF_8); - final NeoForgePlayer actor = adaptPlayer(player); - session.handleCUIInitializationMessage(text, actor); - } -} diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 7351e5c..c8e2647 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -26,13 +26,13 @@ WorldEdit is an easy-to-use in-game world editor for Minecraft, supporting both [[dependencies.worldedit]] modId="minecraft" type="required" - versionRange="[1.20.3,)" + versionRange="[1.20.4,)" ordering="NONE" side="BOTH" [[dependencies.worldedit]] modId="neoforge" type="required" - versionRange="[20.3.1,)" + versionRange="[20.4.1,)" ordering="NONE" side="BOTH"