Skip to content

Commit

Permalink
Fix last of compile problems
Browse files Browse the repository at this point in the history
  • Loading branch information
Drullkus committed Dec 19, 2023
1 parent 68ce366 commit 2224202
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 37 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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.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() {
}

}
11 changes: 9 additions & 2 deletions src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ private List<CompletableFuture<ChunkAccess>> submitChunkLoadTasks(Region region,
);
}
return chunkLoadings;
}
}//*/

@Nullable
private static ResourceKey<ConfiguredFeature<?, ?>> createTreeFeatureGenerator(TreeType type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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<String> validateLenient(String protocolVersion) {
return remoteVersion ->
protocolVersion.equals(remoteVersion)
|| NetworkRegistry.ABSENT.version().equals(remoteVersion)
|| NetworkRegistry.ACCEPTVANILLA.equals(remoteVersion);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

}
14 changes: 7 additions & 7 deletions src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
@@ -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 <init>(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/BlockEntityType;Lnet/minecraft/nbt/CompoundTag;)V # constructor
public net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket <init>(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/BlockEntityType;Lnet/minecraft/nbt/CompoundTag;)V
10 changes: 5 additions & 5 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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!)
Expand All @@ -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"

0 comments on commit 2224202

Please sign in to comment.