diff --git a/build.gradle b/build.gradle index 3313149..a353bc7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,5 @@ // todo migrate this code to kotlin import com.google.gson.JsonParser -import com.modrinth.minotaur.TaskModrinthUpload import java.nio.file.Files import java.util.stream.Collectors @@ -178,8 +177,8 @@ curseforge { changelog = changelogMsg releaseType = "alpha" - addGameVersion("1.19-Snapshot") mcReleases.forEach { ver -> addGameVersion(ver) } + if (!rootProject.curseforge_mc_snapshot.isEmpty()) addGameVersion(rootProject.curseforge_mc_snapshot) javaVersions.forEach(v -> addGameVersion(v)) addGameVersion("Fabric") @@ -213,7 +212,7 @@ modrinth { uploadFile.set(remapJar) List mcs = new ArrayList<>(mcReleases) - mcs.add("1.19-pre3") + if (!rootProject.modrinth_mc_snapshot.isEmpty()) mcs.add(rootProject.modrinth_mc_snapshot) gameVersions.set(mcs) loaders.set(["fabric"]) diff --git a/gradle.properties b/gradle.properties index 9d7574c..4b23d37 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,5 +4,8 @@ org.gradle.jvmargs=-Xms32M -Xmx4G -XX:+UseG1GC -XX:+UseStringDeduplication org.gradle.parallel=true loader_version=0.14.6 -viaver_version=4.3.0-1.19-pre3-SNAPSHOT +viaver_version=4.3.0-1.19-rc1-SNAPSHOT yaml_version=1.30 + +modrinth_mc_snapshot=1.19-rc1 +curseforge_mc_snapshot=1.19-Snapshot \ No newline at end of file diff --git a/src/main/java/com/viaversion/fabric/common/provider/AbstractFabricVersionProvider.java b/src/main/java/com/viaversion/fabric/common/provider/AbstractFabricVersionProvider.java index 386f8bf..f73378e 100644 --- a/src/main/java/com/viaversion/fabric/common/provider/AbstractFabricVersionProvider.java +++ b/src/main/java/com/viaversion/fabric/common/provider/AbstractFabricVersionProvider.java @@ -16,6 +16,7 @@ import com.viaversion.viaversion.exception.CancelException; import com.viaversion.viaversion.protocols.base.BaseProtocol1_16; import com.viaversion.viaversion.protocols.base.BaseProtocol1_7; import com.viaversion.viaversion.protocols.base.BaseVersionProvider; +import com.viaversion.viaversion.protocols.base.ClientboundStatusPackets; import io.netty.channel.ChannelPipeline; import net.fabricmc.loader.api.FabricLoader; @@ -124,7 +125,7 @@ public abstract class AbstractFabricVersionProvider extends BaseVersionProvider && (blocked || ProtocolUtils.isSupported(serverVer, getVersionForMulticonnect(serverVer)))) { // Intercept the connection int multiconnectSuggestion = blocked ? -1 : getVersionForMulticonnect(serverVer); getLogger().info("Sending " + ProtocolVersion.getProtocol(multiconnectSuggestion) + " for multiconnect version detector"); - PacketWrapper newAnswer = PacketWrapper.create(0x00, null, connection); + PacketWrapper newAnswer = PacketWrapper.create(ClientboundStatusPackets.STATUS_RESPONSE, null, connection); newAnswer.write(Type.STRING, "{\"version\":{\"name\":\"viafabric integration\",\"protocol\":" + multiconnectSuggestion + "}}"); newAnswer.send(info.getPipeline().contains(BaseProtocol1_16.class) ? BaseProtocol1_16.class : BaseProtocol1_7.class); throw CancelException.generate(); diff --git a/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/commands/NMSCommandSender.java b/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/commands/NMSCommandSender.java index 16872fc..c214d0c 100644 --- a/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/commands/NMSCommandSender.java +++ b/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/commands/NMSCommandSender.java @@ -26,13 +26,17 @@ public class NMSCommandSender implements ViaCommandSender { return source.hasPermissionLevel(3); } + public static Text fromLegacy(String legacy) { + return Text.Serializer.fromJson(RemappingUtil.legacyToJson(legacy)); + } + @Override public void sendMessage(String s) { if (source instanceof ServerCommandSource) { - ((ServerCommandSource) source).sendFeedback(Text.Serializer.fromJson(RemappingUtil.legacyToJson(s)), false); + ((ServerCommandSource) source).sendFeedback(fromLegacy(s), false); } else if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT && source instanceof ClientCommandSource) { - MinecraftClient.getInstance().player.addChatMessage(Text.Serializer.fromJson(RemappingUtil.legacyToJson(s)), false); + MinecraftClient.getInstance().player.addChatMessage(fromLegacy(s), false); } } diff --git a/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/platform/FabricPlatform.java b/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/platform/FabricPlatform.java index b8e1f9e..7087c79 100644 --- a/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/platform/FabricPlatform.java +++ b/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/platform/FabricPlatform.java @@ -4,7 +4,6 @@ import com.viaversion.fabric.common.commands.UserCommandSender; import com.viaversion.fabric.common.platform.NativeVersionProvider; import com.viaversion.fabric.common.provider.AbstractFabricPlatform; import com.viaversion.fabric.common.util.FutureTaskId; -import com.viaversion.fabric.common.util.RemappingUtil; import com.viaversion.fabric.mc114.ViaFabric; import com.viaversion.fabric.mc114.commands.NMSCommandSender; import com.viaversion.viaversion.api.Via; @@ -18,7 +17,6 @@ import net.minecraft.entity.Entity; import net.minecraft.network.MessageType; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.Text; import java.util.UUID; import java.util.concurrent.CompletableFuture; @@ -82,7 +80,7 @@ public class FabricPlatform extends AbstractFabricPlatform { runServerSync(() -> { ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid); if (player == null) return; - player.sendChatMessage(Text.Serializer.fromJson(RemappingUtil.legacyToJson(s)), MessageType.SYSTEM); + player.sendChatMessage(NMSCommandSender.fromLegacy(s), MessageType.SYSTEM); }); } @@ -97,7 +95,7 @@ public class FabricPlatform extends AbstractFabricPlatform { Supplier kickTask = () -> { ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid); if (player == null) return false; - player.networkHandler.disconnect(Text.Serializer.fromJson(RemappingUtil.legacyToJson(s))); + player.networkHandler.disconnect(NMSCommandSender.fromLegacy(s)); return true; }; if (server.isOnThread()) { diff --git a/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/platform/VFLoader.java b/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/platform/VFLoader.java index 2aec1a6..2de8e61 100644 --- a/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/platform/VFLoader.java +++ b/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/platform/VFLoader.java @@ -1,6 +1,5 @@ package com.viaversion.fabric.mc114.platform; -import com.viaversion.fabric.common.platform.NativeVersionProvider; import com.viaversion.fabric.mc114.providers.VRHandItemProvider; import com.viaversion.fabric.mc114.providers.FabricVersionProvider; import net.fabricmc.api.EnvType; @@ -23,7 +22,6 @@ public class VFLoader implements ViaPlatformLoader { if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { handProvider.registerClientTick(); } - handProvider.registerServerTick(); Via.getManager().getProviders().use(HandItemProvider.class, handProvider); } } diff --git a/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/providers/VRHandItemProvider.java b/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/providers/VRHandItemProvider.java index 7cdfdc5..5ef1a89 100644 --- a/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/providers/VRHandItemProvider.java +++ b/viafabric-mc114/src/main/java/com/viaversion/fabric/mc114/providers/VRHandItemProvider.java @@ -4,33 +4,24 @@ import com.viaversion.fabric.common.util.RemappingUtil; import com.viaversion.fabric.mc114.ViaFabric; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.event.world.WorldTickCallback; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.registry.Registry; import net.minecraft.util.Identifier; -import net.minecraft.world.World; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemProvider; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; - public class VRHandItemProvider extends HandItemProvider { public Item clientItem = null; - public final Map serverPlayers = new ConcurrentHashMap<>(); @Override public Item getHandItem(UserConnection info) { - Item serverItem; if (info.isClientSide()) { return getClientItem(); - } else if ((serverItem = serverPlayers.get(info.getProtocolInfo().getUuid())) != null) { - return new DataItem(serverItem); } return super.getHandItem(info); } @@ -45,24 +36,12 @@ public class VRHandItemProvider extends HandItemProvider { @Environment(EnvType.CLIENT) public void registerClientTick() { try { - WorldTickCallback.EVENT.register(world -> { - if (world.isClient) { - tickClient(); - } - }); + ClientTickEvents.END_CLIENT_TICK.register(world -> tickClient()); } catch (NoClassDefFoundError ignored2) { ViaFabric.JLOGGER.info("Fabric Lifecycle V0 isn't installed"); } } - public void registerServerTick() { - WorldTickCallback.EVENT.register(world -> { - if (!world.isClient) { - tickServer(world); - } - }); - } - private void tickClient() { ClientPlayerEntity p = MinecraftClient.getInstance().player; if (p != null) { @@ -70,12 +49,6 @@ public class VRHandItemProvider extends HandItemProvider { } } - private void tickServer(World world) { - serverPlayers.clear(); - world.getPlayers().forEach(it -> serverPlayers - .put(it.getUuid(), fromNative(it.inventory.getMainHandStack()))); - } - private Item fromNative(ItemStack original) { Identifier iid = Registry.ITEM.getId(original.getItem()); int id = RemappingUtil.swordId(iid.toString()); diff --git a/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/commands/NMSCommandSender.java b/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/commands/NMSCommandSender.java index a177351..c21ec0c 100644 --- a/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/commands/NMSCommandSender.java +++ b/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/commands/NMSCommandSender.java @@ -26,12 +26,16 @@ public class NMSCommandSender implements ViaCommandSender { return source.hasPermissionLevel(3); } + public static Text fromLegacy(String legacy) { + return Text.Serializer.fromJson(RemappingUtil.legacyToJson(legacy)); + } + @Override public void sendMessage(String s) { if (source instanceof ServerCommandSource) { - ((ServerCommandSource) source).sendFeedback(Text.Serializer.fromJson(RemappingUtil.legacyToJson(s)), false); + ((ServerCommandSource) source).sendFeedback(fromLegacy(s), false); } else if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT && source instanceof ClientCommandSource) { - MinecraftClient.getInstance().player.addChatMessage(Text.Serializer.fromJson(RemappingUtil.legacyToJson(s)), false); + MinecraftClient.getInstance().player.addChatMessage(fromLegacy(s), false); } } diff --git a/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/platform/FabricPlatform.java b/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/platform/FabricPlatform.java index df41d74..4a527ff 100644 --- a/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/platform/FabricPlatform.java +++ b/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/platform/FabricPlatform.java @@ -4,7 +4,6 @@ import com.viaversion.fabric.common.commands.UserCommandSender; import com.viaversion.fabric.common.platform.NativeVersionProvider; import com.viaversion.fabric.common.provider.AbstractFabricPlatform; import com.viaversion.fabric.common.util.FutureTaskId; -import com.viaversion.fabric.common.util.RemappingUtil; import com.viaversion.fabric.mc115.ViaFabric; import com.viaversion.fabric.mc115.commands.NMSCommandSender; import com.viaversion.viaversion.api.Via; @@ -18,7 +17,6 @@ import net.minecraft.entity.Entity; import net.minecraft.network.MessageType; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.Text; import java.util.UUID; import java.util.concurrent.CompletableFuture; @@ -97,7 +95,7 @@ public class FabricPlatform extends AbstractFabricPlatform { runServerSync(() -> { ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid); if (player == null) return; - player.sendChatMessage(Text.Serializer.fromJson(RemappingUtil.legacyToJson(s)), MessageType.SYSTEM); + player.sendChatMessage(NMSCommandSender.fromLegacy(s), MessageType.SYSTEM); }); } @@ -112,7 +110,7 @@ public class FabricPlatform extends AbstractFabricPlatform { Supplier kickTask = () -> { ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid); if (player == null) return false; - player.networkHandler.disconnect(Text.Serializer.fromJson(RemappingUtil.legacyToJson(s))); + player.networkHandler.disconnect(NMSCommandSender.fromLegacy(s)); return true; }; if (server.isOnThread()) { diff --git a/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/platform/VFLoader.java b/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/platform/VFLoader.java index 602ec4a..c1d196d 100644 --- a/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/platform/VFLoader.java +++ b/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/platform/VFLoader.java @@ -1,6 +1,5 @@ package com.viaversion.fabric.mc115.platform; -import com.viaversion.fabric.common.platform.NativeVersionProvider; import com.viaversion.fabric.mc115.providers.VRHandItemProvider; import com.viaversion.fabric.mc115.providers.FabricVersionProvider; import net.fabricmc.api.EnvType; @@ -23,7 +22,6 @@ public class VFLoader implements ViaPlatformLoader { if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { handProvider.registerClientTick(); } - handProvider.registerServerTick(); Via.getManager().getProviders().use(HandItemProvider.class, handProvider); } } diff --git a/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/providers/VRHandItemProvider.java b/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/providers/VRHandItemProvider.java index b7dde63..088e44d 100644 --- a/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/providers/VRHandItemProvider.java +++ b/viafabric-mc115/src/main/java/com/viaversion/fabric/mc115/providers/VRHandItemProvider.java @@ -9,29 +9,19 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemPr import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; -import net.minecraft.world.World; - -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; public class VRHandItemProvider extends HandItemProvider { public Item clientItem = null; - public final Map serverPlayers = new ConcurrentHashMap<>(); @Override public Item getHandItem(UserConnection info) { - Item serverItem; if (info.isClientSide()) { return getClientItem(); - } else if ((serverItem = serverPlayers.get(info.getProtocolInfo().getUuid())) != null) { - return new DataItem(serverItem); } return super.getHandItem(info); } @@ -52,13 +42,6 @@ public class VRHandItemProvider extends HandItemProvider { } } - public void registerServerTick() { - try { - ServerTickEvents.END_WORLD_TICK.register(this::tickServer); - } catch (NoClassDefFoundError ignored) { - } - } - private void tickClient() { ClientPlayerEntity p = MinecraftClient.getInstance().player; if (p != null) { @@ -66,12 +49,6 @@ public class VRHandItemProvider extends HandItemProvider { } } - private void tickServer(World world) { - serverPlayers.clear(); - world.getPlayers().forEach(it -> serverPlayers - .put(it.getUuid(), fromNative(it.inventory.getMainHandStack()))); - } - private Item fromNative(ItemStack original) { Identifier iid = Registry.ITEM.getId(original.getItem()); int id = RemappingUtil.swordId(iid.toString()); diff --git a/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/commands/NMSCommandSender.java b/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/commands/NMSCommandSender.java index 2a01d5c..c39c628 100644 --- a/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/commands/NMSCommandSender.java +++ b/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/commands/NMSCommandSender.java @@ -23,12 +23,16 @@ public class NMSCommandSender implements ViaCommandSender { return source.hasPermissionLevel(3); } + public static Text fromLegacy(String legacy) { + return Text.Serializer.fromJson(RemappingUtil.legacyToJson(legacy)); + } + @Override public void sendMessage(String s) { if (source instanceof ServerCommandSource) { - ((ServerCommandSource) source).sendFeedback(Text.Serializer.fromJson(RemappingUtil.legacyToJson(s)), false); + ((ServerCommandSource) source).sendFeedback(fromLegacy(s), false); } else if (source instanceof FabricClientCommandSource) { - ((FabricClientCommandSource) source).sendFeedback(Text.Serializer.fromJson(RemappingUtil.legacyToJson(s))); + ((FabricClientCommandSource) source).sendFeedback(fromLegacy(s)); } } diff --git a/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/platform/FabricPlatform.java b/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/platform/FabricPlatform.java index 2158cac..5b9dd00 100644 --- a/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/platform/FabricPlatform.java +++ b/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/platform/FabricPlatform.java @@ -4,7 +4,6 @@ import com.viaversion.fabric.common.commands.UserCommandSender; import com.viaversion.fabric.common.platform.NativeVersionProvider; import com.viaversion.fabric.common.provider.AbstractFabricPlatform; import com.viaversion.fabric.common.util.FutureTaskId; -import com.viaversion.fabric.common.util.RemappingUtil; import com.viaversion.fabric.mc116.ViaFabric; import com.viaversion.fabric.mc116.commands.NMSCommandSender; import com.viaversion.viaversion.api.Via; @@ -17,7 +16,6 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.Text; import java.util.UUID; import java.util.concurrent.CompletableFuture; @@ -96,9 +94,7 @@ public class FabricPlatform extends AbstractFabricPlatform { runServerSync(() -> { ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid); if (player == null) return; - player.sendMessage(Text.Serializer.fromJson( - RemappingUtil.legacyToJson(s) - ), false); + player.sendMessage(NMSCommandSender.fromLegacy(s), false); }); } @@ -113,7 +109,7 @@ public class FabricPlatform extends AbstractFabricPlatform { Supplier kickTask = () -> { ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid); if (player == null) return false; - player.networkHandler.disconnect(Text.Serializer.fromJson(RemappingUtil.legacyToJson(s))); + player.networkHandler.disconnect(NMSCommandSender.fromLegacy(s)); return true; }; if (server.isOnThread()) { diff --git a/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/platform/VFLoader.java b/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/platform/VFLoader.java index de4300d..4279374 100644 --- a/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/platform/VFLoader.java +++ b/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/platform/VFLoader.java @@ -1,6 +1,5 @@ package com.viaversion.fabric.mc116.platform; -import com.viaversion.fabric.common.platform.NativeVersionProvider; import com.viaversion.fabric.mc116.providers.VRHandItemProvider; import com.viaversion.fabric.mc116.providers.FabricVersionProvider; import net.fabricmc.api.EnvType; @@ -23,7 +22,6 @@ public class VFLoader implements ViaPlatformLoader { if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { handProvider.registerClientTick(); } - handProvider.registerServerTick(); Via.getManager().getProviders().use(HandItemProvider.class, handProvider); } } diff --git a/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/providers/VRHandItemProvider.java b/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/providers/VRHandItemProvider.java index c1c231b..ffa63a0 100644 --- a/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/providers/VRHandItemProvider.java +++ b/viafabric-mc116/src/main/java/com/viaversion/fabric/mc116/providers/VRHandItemProvider.java @@ -9,29 +9,19 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemPr import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; -import net.minecraft.world.World; - -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; public class VRHandItemProvider extends HandItemProvider { public Item clientItem = null; - public final Map serverPlayers = new ConcurrentHashMap<>(); @Override public Item getHandItem(UserConnection info) { - Item serverItem; if (info.isClientSide()) { return getClientItem(); - } else if ((serverItem = serverPlayers.get(info.getProtocolInfo().getUuid())) != null) { - return new DataItem(serverItem); } return super.getHandItem(info); } @@ -52,13 +42,6 @@ public class VRHandItemProvider extends HandItemProvider { } } - public void registerServerTick() { - try { - ServerTickEvents.END_WORLD_TICK.register(this::tickServer); - } catch (NoClassDefFoundError ignored) { - } - } - private void tickClient() { ClientPlayerEntity p = MinecraftClient.getInstance().player; if (p != null) { @@ -66,12 +49,6 @@ public class VRHandItemProvider extends HandItemProvider { } } - private void tickServer(World world) { - serverPlayers.clear(); - world.getPlayers().forEach(it -> serverPlayers - .put(it.getUuid(), fromNative(it.inventory.getMainHandStack()))); - } - private Item fromNative(ItemStack original) { Identifier iid = Registry.ITEM.getId(original.getItem()); int id = RemappingUtil.swordId(iid.toString()); diff --git a/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/commands/NMSCommandSender.java b/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/commands/NMSCommandSender.java index 4145109..9ede2a5 100644 --- a/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/commands/NMSCommandSender.java +++ b/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/commands/NMSCommandSender.java @@ -1,11 +1,11 @@ package com.viaversion.fabric.mc117.commands; import com.viaversion.fabric.common.util.RemappingUtil; -import com.viaversion.fabric.mc117.platform.FabricPlatform; import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource; import net.minecraft.command.CommandSource; import net.minecraft.entity.Entity; import net.minecraft.server.command.ServerCommandSource; +import net.minecraft.text.MutableText; import net.minecraft.text.Text; import com.viaversion.viaversion.api.command.ViaCommandSender; @@ -24,12 +24,16 @@ public class NMSCommandSender implements ViaCommandSender { return source.hasPermissionLevel(3); } + public static MutableText fromLegacy(String legacy) { + return Text.Serializer.fromJson(RemappingUtil.legacyToJson(legacy)); + } + @Override public void sendMessage(String s) { if (source instanceof ServerCommandSource) { - ((ServerCommandSource) source).sendFeedback(Text.Serializer.fromJson(RemappingUtil.legacyToJson(s)), false); + ((ServerCommandSource) source).sendFeedback(fromLegacy(s), false); } else if (source instanceof FabricClientCommandSource) { - ((FabricClientCommandSource) source).sendFeedback(Text.Serializer.fromJson(RemappingUtil.legacyToJson(s))); + ((FabricClientCommandSource) source).sendFeedback(fromLegacy(s)); } } diff --git a/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/platform/FabricPlatform.java b/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/platform/FabricPlatform.java index 47c747a..d366baf 100644 --- a/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/platform/FabricPlatform.java +++ b/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/platform/FabricPlatform.java @@ -4,7 +4,6 @@ import com.viaversion.fabric.common.commands.UserCommandSender; import com.viaversion.fabric.common.platform.NativeVersionProvider; import com.viaversion.fabric.common.provider.AbstractFabricPlatform; import com.viaversion.fabric.common.util.FutureTaskId; -import com.viaversion.fabric.common.util.RemappingUtil; import com.viaversion.fabric.mc117.ViaFabric; import com.viaversion.fabric.mc117.commands.NMSCommandSender; import com.viaversion.viaversion.api.Via; @@ -17,7 +16,6 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.Text; import java.util.UUID; import java.util.concurrent.CompletableFuture; @@ -81,9 +79,7 @@ public class FabricPlatform extends AbstractFabricPlatform { runServerSync(() -> { ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid); if (player == null) return; - player.sendMessage(Text.Serializer.fromJson( - RemappingUtil.legacyToJson(s) - ), false); + player.sendMessage(NMSCommandSender.fromLegacy(s), false); }); } @@ -98,7 +94,7 @@ public class FabricPlatform extends AbstractFabricPlatform { Supplier kickTask = () -> { ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid); if (player == null) return false; - player.networkHandler.disconnect(Text.Serializer.fromJson(RemappingUtil.legacyToJson(s))); + player.networkHandler.disconnect(NMSCommandSender.fromLegacy(s)); return true; }; if (server.isOnThread()) { diff --git a/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/platform/VFLoader.java b/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/platform/VFLoader.java index 8d5570d..ab55fb9 100644 --- a/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/platform/VFLoader.java +++ b/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/platform/VFLoader.java @@ -1,6 +1,5 @@ package com.viaversion.fabric.mc117.platform; -import com.viaversion.fabric.common.platform.NativeVersionProvider; import com.viaversion.fabric.mc117.providers.VRHandItemProvider; import com.viaversion.fabric.mc117.providers.FabricVersionProvider; import net.fabricmc.api.EnvType; @@ -23,7 +22,6 @@ public class VFLoader implements ViaPlatformLoader { if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { handProvider.registerClientTick(); } - handProvider.registerServerTick(); Via.getManager().getProviders().use(HandItemProvider.class, handProvider); } } diff --git a/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/providers/VRHandItemProvider.java b/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/providers/VRHandItemProvider.java index b576827..840864d 100644 --- a/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/providers/VRHandItemProvider.java +++ b/viafabric-mc117/src/main/java/com/viaversion/fabric/mc117/providers/VRHandItemProvider.java @@ -9,29 +9,19 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemPr import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; -import net.minecraft.world.World; - -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; public class VRHandItemProvider extends HandItemProvider { - public final Map serverPlayers = new ConcurrentHashMap<>(); public Item clientItem = null; @Override public Item getHandItem(UserConnection info) { - Item serverItem; if (info.isClientSide()) { return getClientItem(); - } else if ((serverItem = serverPlayers.get(info.getProtocolInfo().getUuid())) != null) { - return new DataItem(serverItem); } return super.getHandItem(info); } @@ -52,13 +42,6 @@ public class VRHandItemProvider extends HandItemProvider { } } - public void registerServerTick() { - try { - ServerTickEvents.END_WORLD_TICK.register(this::tickServer); - } catch (NoClassDefFoundError ignored) { - } - } - private void tickClient() { ClientPlayerEntity p = MinecraftClient.getInstance().player; if (p != null) { @@ -66,12 +49,6 @@ public class VRHandItemProvider extends HandItemProvider { } } - private void tickServer(World world) { - serverPlayers.clear(); - world.getPlayers().forEach(it -> serverPlayers - .put(it.getUuid(), fromNative(it.getInventory().getMainHandStack()))); - } - private Item fromNative(ItemStack original) { Identifier iid = Registry.ITEM.getId(original.getItem()); int id = RemappingUtil.swordId(iid.toString()); diff --git a/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/commands/NMSCommandSender.java b/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/commands/NMSCommandSender.java index 915ca5b..97f2ad8 100644 --- a/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/commands/NMSCommandSender.java +++ b/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/commands/NMSCommandSender.java @@ -1,7 +1,6 @@ package com.viaversion.fabric.mc118.commands; import com.viaversion.fabric.common.util.RemappingUtil; -import com.viaversion.fabric.mc118.platform.FabricPlatform; import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource; import net.minecraft.command.CommandSource; import net.minecraft.entity.Entity; @@ -24,12 +23,16 @@ public class NMSCommandSender implements ViaCommandSender { return source.hasPermissionLevel(3); } + public static Text fromLegacy(String legacy) { + return Text.Serializer.fromJson(RemappingUtil.legacyToJson(legacy)); + } + @Override public void sendMessage(String s) { if (source instanceof ServerCommandSource) { - ((ServerCommandSource) source).sendFeedback(Text.Serializer.fromJson(RemappingUtil.legacyToJson(s)), false); + ((ServerCommandSource) source).sendFeedback(fromLegacy(s), false); } else if (source instanceof FabricClientCommandSource) { - ((FabricClientCommandSource) source).sendFeedback(Text.Serializer.fromJson(RemappingUtil.legacyToJson(s))); + ((FabricClientCommandSource) source).sendFeedback(fromLegacy(s)); } } diff --git a/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/platform/FabricPlatform.java b/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/platform/FabricPlatform.java index 27cd4d6..43e5be9 100644 --- a/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/platform/FabricPlatform.java +++ b/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/platform/FabricPlatform.java @@ -4,7 +4,6 @@ import com.viaversion.fabric.common.commands.UserCommandSender; import com.viaversion.fabric.common.platform.NativeVersionProvider; import com.viaversion.fabric.common.provider.AbstractFabricPlatform; import com.viaversion.fabric.common.util.FutureTaskId; -import com.viaversion.fabric.common.util.RemappingUtil; import com.viaversion.fabric.mc118.ViaFabric; import com.viaversion.fabric.mc118.commands.NMSCommandSender; import com.viaversion.viaversion.api.Via; @@ -17,7 +16,6 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.Text; import java.util.UUID; import java.util.concurrent.CompletableFuture; @@ -81,9 +79,7 @@ public class FabricPlatform extends AbstractFabricPlatform { runServerSync(() -> { ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid); if (player == null) return; - player.sendMessage(Text.Serializer.fromJson( - RemappingUtil.legacyToJson(s) - ), false); + player.sendMessage(NMSCommandSender.fromLegacy(s), false); }); } @@ -98,7 +94,7 @@ public class FabricPlatform extends AbstractFabricPlatform { Supplier kickTask = () -> { ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid); if (player == null) return false; - player.networkHandler.disconnect(Text.Serializer.fromJson(RemappingUtil.legacyToJson(s))); + player.networkHandler.disconnect(NMSCommandSender.fromLegacy(s)); return true; }; if (server.isOnThread()) { diff --git a/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/platform/VFLoader.java b/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/platform/VFLoader.java index 82a42de..5522eeb 100644 --- a/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/platform/VFLoader.java +++ b/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/platform/VFLoader.java @@ -1,6 +1,5 @@ package com.viaversion.fabric.mc118.platform; -import com.viaversion.fabric.common.platform.NativeVersionProvider; import com.viaversion.fabric.mc118.providers.VRHandItemProvider; import com.viaversion.fabric.mc118.providers.FabricVersionProvider; import net.fabricmc.api.EnvType; @@ -23,7 +22,6 @@ public class VFLoader implements ViaPlatformLoader { if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { handProvider.registerClientTick(); } - handProvider.registerServerTick(); Via.getManager().getProviders().use(HandItemProvider.class, handProvider); } } diff --git a/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/providers/VRHandItemProvider.java b/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/providers/VRHandItemProvider.java index f99f917..5f0d51f 100644 --- a/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/providers/VRHandItemProvider.java +++ b/viafabric-mc118/src/main/java/com/viaversion/fabric/mc118/providers/VRHandItemProvider.java @@ -9,29 +9,19 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemPr import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; -import net.minecraft.world.World; - -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; public class VRHandItemProvider extends HandItemProvider { public Item clientItem = null; - public final Map serverPlayers = new ConcurrentHashMap<>(); @Override public Item getHandItem(UserConnection info) { - Item serverItem; if (info.isClientSide()) { return getClientItem(); - } else if ((serverItem = serverPlayers.get(info.getProtocolInfo().getUuid())) != null) { - return new DataItem(serverItem); } return super.getHandItem(info); } @@ -52,13 +42,6 @@ public class VRHandItemProvider extends HandItemProvider { } } - public void registerServerTick() { - try { - ServerTickEvents.END_WORLD_TICK.register(this::tickServer); - } catch (NoClassDefFoundError ignored) { - } - } - private void tickClient() { ClientPlayerEntity p = MinecraftClient.getInstance().player; if (p != null) { @@ -66,12 +49,6 @@ public class VRHandItemProvider extends HandItemProvider { } } - private void tickServer(World world) { - serverPlayers.clear(); - world.getPlayers().forEach(it -> serverPlayers - .put(it.getUuid(), fromNative(it.getInventory().getMainHandStack()))); - } - private Item fromNative(ItemStack original) { Identifier iid = Registry.ITEM.getId(original.getItem()); int id = RemappingUtil.swordId(iid.toString()); diff --git a/viafabric-mc119/build.gradle.kts b/viafabric-mc119/build.gradle.kts index a01c46c..23fe5b0 100644 --- a/viafabric-mc119/build.gradle.kts +++ b/viafabric-mc119/build.gradle.kts @@ -1,7 +1,7 @@ dependencies { - minecraft("com.mojang:minecraft:1.19-pre3") - mappings("net.fabricmc:yarn:1.19-pre3+build.4:v2") + minecraft("com.mojang:minecraft:1.19-rc2") + mappings("net.fabricmc:yarn:1.19-rc2+build.1:v2") - modImplementation("net.fabricmc.fabric-api:fabric-api:0.53.4+1.19") + modImplementation("net.fabricmc.fabric-api:fabric-api:0.55.0+1.19") modImplementation("com.terraformersmc:modmenu:4.0.0-beta.4") } diff --git a/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/ViaFabric.java b/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/ViaFabric.java index 20fc93f..605f665 100644 --- a/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/ViaFabric.java +++ b/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/ViaFabric.java @@ -20,7 +20,7 @@ import io.netty.channel.DefaultEventLoop; import io.netty.channel.EventLoop; import net.fabricmc.api.EnvType; import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.command.CommandSource; @@ -93,7 +93,7 @@ public class ViaFabric implements ModInitializer { CommandRegistrationCallback.EVENT.register((dispatcher, dedicated, env) -> dispatcher.register(command("viaver"))); CommandRegistrationCallback.EVENT.register((dispatcher, dedicated, env) -> dispatcher.register(command("vvfabric"))); if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { - ClientCommandManager.DISPATCHER.register(command("viafabricclient")); + ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(command("viafabricclient"))); } } catch (NoClassDefFoundError ignored) { JLOGGER.info("Couldn't register command as Fabric Commands V1 isn't installed"); diff --git a/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/commands/NMSCommandSender.java b/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/commands/NMSCommandSender.java index 00d5084..d30bb21 100644 --- a/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/commands/NMSCommandSender.java +++ b/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/commands/NMSCommandSender.java @@ -5,6 +5,7 @@ import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.command.CommandSource; import net.minecraft.entity.Entity; import net.minecraft.server.command.ServerCommandSource; +import net.minecraft.text.MutableText; import net.minecraft.text.Text; import com.viaversion.viaversion.api.command.ViaCommandSender; @@ -23,12 +24,16 @@ public class NMSCommandSender implements ViaCommandSender { return source.hasPermissionLevel(3); } + public static MutableText fromLegacy(String legacy) { + return Text.Serializer.fromJson(RemappingUtil.legacyToJson(legacy)); + } + @Override public void sendMessage(String s) { if (source instanceof ServerCommandSource) { - ((ServerCommandSource) source).sendFeedback(Text.Serializer.fromJson(RemappingUtil.legacyToJson(s)), false); + ((ServerCommandSource) source).sendFeedback(fromLegacy(s), false); } else if (source instanceof FabricClientCommandSource) { - ((FabricClientCommandSource) source).sendFeedback(Text.Serializer.fromJson(RemappingUtil.legacyToJson(s))); + ((FabricClientCommandSource) source).sendFeedback(fromLegacy(s)); } } diff --git a/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/platform/FabricPlatform.java b/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/platform/FabricPlatform.java index 8085b37..c874065 100644 --- a/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/platform/FabricPlatform.java +++ b/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/platform/FabricPlatform.java @@ -4,7 +4,6 @@ import com.viaversion.fabric.common.commands.UserCommandSender; import com.viaversion.fabric.common.platform.NativeVersionProvider; import com.viaversion.fabric.common.provider.AbstractFabricPlatform; import com.viaversion.fabric.common.util.FutureTaskId; -import com.viaversion.fabric.common.util.RemappingUtil; import com.viaversion.fabric.mc119.ViaFabric; import com.viaversion.fabric.mc119.commands.NMSCommandSender; import com.viaversion.viaversion.api.Via; @@ -17,7 +16,6 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.Text; import java.util.UUID; import java.util.concurrent.CompletableFuture; @@ -81,9 +79,7 @@ public class FabricPlatform extends AbstractFabricPlatform { runServerSync(() -> { ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid); if (player == null) return; - player.sendMessage(Text.Serializer.fromJson( - RemappingUtil.legacyToJson(s) - ), false); + player.sendMessage(NMSCommandSender.fromLegacy(s), false); }); } @@ -98,7 +94,7 @@ public class FabricPlatform extends AbstractFabricPlatform { Supplier kickTask = () -> { ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid); if (player == null) return false; - player.networkHandler.disconnect(Text.Serializer.fromJson(RemappingUtil.legacyToJson(s))); + player.networkHandler.disconnect(NMSCommandSender.fromLegacy(s)); return true; }; if (server.isOnThread()) { diff --git a/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/platform/VFLoader.java b/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/platform/VFLoader.java index 380bf18..14a2e10 100644 --- a/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/platform/VFLoader.java +++ b/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/platform/VFLoader.java @@ -22,7 +22,6 @@ public class VFLoader implements ViaPlatformLoader { if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { handProvider.registerClientTick(); } - handProvider.registerServerTick(); Via.getManager().getProviders().use(HandItemProvider.class, handProvider); } } diff --git a/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/providers/VRHandItemProvider.java b/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/providers/VRHandItemProvider.java index 0e564d6..070c5f3 100644 --- a/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/providers/VRHandItemProvider.java +++ b/viafabric-mc119/src/main/java/com/viaversion/fabric/mc119/providers/VRHandItemProvider.java @@ -9,29 +9,19 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.HandItemPr import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; -import net.minecraft.world.World; - -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; public class VRHandItemProvider extends HandItemProvider { public Item clientItem = null; - public final Map serverPlayers = new ConcurrentHashMap<>(); @Override public Item getHandItem(UserConnection info) { - Item serverItem; if (info.isClientSide()) { return getClientItem(); - } else if ((serverItem = serverPlayers.get(info.getProtocolInfo().getUuid())) != null) { - return new DataItem(serverItem); } return super.getHandItem(info); } @@ -52,13 +42,6 @@ public class VRHandItemProvider extends HandItemProvider { } } - public void registerServerTick() { - try { - ServerTickEvents.END_WORLD_TICK.register(this::tickServer); - } catch (NoClassDefFoundError ignored) { - } - } - private void tickClient() { ClientPlayerEntity p = MinecraftClient.getInstance().player; if (p != null) { @@ -66,12 +49,6 @@ public class VRHandItemProvider extends HandItemProvider { } } - private void tickServer(World world) { - serverPlayers.clear(); - world.getPlayers().forEach(it -> serverPlayers - .put(it.getUuid(), fromNative(it.getInventory().getMainHandStack()))); - } - private Item fromNative(ItemStack original) { Identifier iid = Registry.ITEM.getId(original.getItem()); int id = RemappingUtil.swordId(iid.toString()); diff --git a/viafabric-mc18/build.gradle.kts b/viafabric-mc18/build.gradle.kts index 27b175d..93cb816 100644 --- a/viafabric-mc18/build.gradle.kts +++ b/viafabric-mc18/build.gradle.kts @@ -8,6 +8,7 @@ dependencies { } // fix newer java + @Suppress("GradlePackageUpdate") implementation("io.netty:netty-all:4.0.56.Final") } diff --git a/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/platform/VFLoader.java b/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/platform/VFLoader.java index 768a78e..4f80645 100644 --- a/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/platform/VFLoader.java +++ b/viafabric-mc18/src/main/java/com/viaversion/fabric/mc18/platform/VFLoader.java @@ -1,6 +1,5 @@ package com.viaversion.fabric.mc18.platform; -import com.viaversion.fabric.common.platform.NativeVersionProvider; import com.viaversion.fabric.mc18.providers.VRHandItemProvider; import com.viaversion.fabric.mc18.providers.FabricVersionProvider; import net.fabricmc.api.EnvType;