From 1def030759aa559fe18c36b753405a9498c9566e Mon Sep 17 00:00:00 2001 From: Basique Evangelist Date: Tue, 31 Jan 2023 15:25:34 +0300 Subject: [PATCH] truly 1.19.3 --- build.gradle | 10 +++---- gradle.properties | 10 +++---- .../pingspam/commands/PingSoundCommand.java | 4 +-- .../pingspam/data/PingspamGlobalData.java | 7 +++-- .../pingspam/data/PingspamPlayerData.java | 9 +++---- .../pingspam/mixin/MinecraftServerMixin.java | 10 +++---- .../pingspam/mixin/PlayerManagerMixin.java | 18 ++++++------- .../mixin/ServerPlayerEntityMixin.java | 8 +++--- .../pingspam/mixin/SimpleRegistryMixin.java | 27 ++++++++++++------- .../utils/MessageTypeTransformer.java | 7 ++--- src/main/resources/fabric.mod.json | 2 +- 11 files changed, 54 insertions(+), 58 deletions(-) diff --git a/build.gradle b/build.gradle index a542905..94e2880 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,8 @@ plugins { id 'com.github.johnrengelman.shadow' version '7.1.2' id 'java' - id 'fabric-loom' version '0.12-SNAPSHOT' - id 'io.github.juuxel.loom-quiltflower' version '1.7.2' + id 'fabric-loom' version '1.1-SNAPSHOT' + id 'io.github.juuxel.loom-quiltflower' version '1.8.0' id 'maven-publish' } @@ -50,7 +50,7 @@ dependencies { modLocalRuntime "com.terraformersmc:modmenu:${project.modmenu_version}" - modImplementation include('me.lucko:fabric-permissions-api:0.1-SNAPSHOT') + modImplementation include('me.lucko:fabric-permissions-api:0.2-SNAPSHOT') shadow implementation("blue.endless:jankson:1.2.0") modImplementation include('me.basiqueevangelist:onedatastore:0.1.2+1.19') { @@ -66,10 +66,6 @@ remapJar { inputFile.set shadowJar.archiveFile.get() } -prepareRemapJar { - dependsOn "shadowJar" -} - shadowJar { configurations = [project.configurations.shadow] diff --git a/gradle.properties b/gradle.properties index 7d16074..5f3f196 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/develop - minecraft_version=1.19.2 - yarn_mappings=1.19.2+build.20 - loader_version=0.14.9 + minecraft_version=1.19.3 + yarn_mappings=1.19.3+build.5 + loader_version=0.14.13 # Mod Properties mod_version = 1.3.1 @@ -13,5 +13,5 @@ org.gradle.jvmargs=-Xmx1G archives_base_name = pingspam # Dependencies - fabric_version=0.62.0+1.19.2 - modmenu_version=4.0.6 \ No newline at end of file + fabric_version=0.73.0+1.19.3 + modmenu_version=5.0.2 \ No newline at end of file diff --git a/src/main/java/me/basiqueevangelist/pingspam/commands/PingSoundCommand.java b/src/main/java/me/basiqueevangelist/pingspam/commands/PingSoundCommand.java index 08ea50d..9de4041 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/commands/PingSoundCommand.java +++ b/src/main/java/me/basiqueevangelist/pingspam/commands/PingSoundCommand.java @@ -9,13 +9,13 @@ import me.basiqueevangelist.pingspam.data.PingspamPlayerData; import net.minecraft.command.argument.IdentifierArgumentType; import net.minecraft.command.suggestion.SuggestionProviders; +import net.minecraft.registry.Registries; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.sound.SoundEvent; import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import static net.minecraft.server.command.CommandManager.argument; import static net.minecraft.server.command.CommandManager.literal; @@ -41,7 +41,7 @@ private static int setPingSound(CommandContext ctx) throws ServerPlayerEntity player = src.getPlayerOrThrow(); PingspamPlayerData data = DataStore.getFor(src.getServer()).getPlayer(player.getUuid(), PingSpam.PLAYER_DATA); Identifier soundId = IdentifierArgumentType.getIdentifier(ctx, "sound"); - SoundEvent event = Registry.SOUND_EVENT.getOrEmpty(soundId).orElseThrow(INVALID_SOUND::create); + SoundEvent event = Registries.SOUND_EVENT.getOrEmpty(soundId).orElseThrow(INVALID_SOUND::create); data.setPingSound(event); diff --git a/src/main/java/me/basiqueevangelist/pingspam/data/PingspamGlobalData.java b/src/main/java/me/basiqueevangelist/pingspam/data/PingspamGlobalData.java index 9725dea..f610027 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/data/PingspamGlobalData.java +++ b/src/main/java/me/basiqueevangelist/pingspam/data/PingspamGlobalData.java @@ -5,15 +5,14 @@ import me.basiqueevangelist.pingspam.PingSpam; import me.basiqueevangelist.pingspam.utils.CaseInsensitiveUtil; import me.basiqueevangelist.pingspam.utils.OfflineUtil; -import net.fabricmc.fabric.api.util.NbtType; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; import net.minecraft.nbt.NbtHelper; import net.minecraft.nbt.NbtList; +import net.minecraft.registry.Registries; import net.minecraft.sound.SoundEvents; import net.minecraft.text.Text; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,7 +62,7 @@ public void wasMissing() { } if (tag.contains("IgnoredPlayers")) { - NbtList ignoredPlayerListTag = tag.getList("IgnoredPlayers", NbtType.INT_ARRAY); + NbtList ignoredPlayerListTag = tag.getList("IgnoredPlayers", NbtElement.INT_ARRAY_TYPE); for (NbtElement ignoredPlayerTag : ignoredPlayerListTag) { data.ignoredPlayers().add(NbtHelper.toUuid(ignoredPlayerTag)); } @@ -73,7 +72,7 @@ public void wasMissing() { if (tag.getString("PingSound").equals("null")) { data.setPingSound(null); } else { - data.setPingSound(Registry.SOUND_EVENT.getOrEmpty(new Identifier(tag.getString("PingSound"))).orElse(SoundEvents.BLOCK_BELL_USE)); + data.setPingSound(Registries.SOUND_EVENT.getOrEmpty(new Identifier(tag.getString("PingSound"))).orElse(SoundEvents.BLOCK_BELL_USE)); } } } catch (Exception e) { diff --git a/src/main/java/me/basiqueevangelist/pingspam/data/PingspamPlayerData.java b/src/main/java/me/basiqueevangelist/pingspam/data/PingspamPlayerData.java index 7bccdaf..85aaad0 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/data/PingspamPlayerData.java +++ b/src/main/java/me/basiqueevangelist/pingspam/data/PingspamPlayerData.java @@ -2,13 +2,12 @@ import me.basiqueevangelist.onedatastore.api.ComponentInstance; import me.basiqueevangelist.pingspam.utils.CaseInsensitiveUtil; -import net.fabricmc.fabric.api.util.NbtType; import net.minecraft.nbt.*; +import net.minecraft.registry.Registries; import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; import net.minecraft.text.Text; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -58,18 +57,18 @@ public void fromTag(NbtCompound tag) { } if (tag.contains("IgnoredPlayers")) { - NbtList ignoredPlayerListTag = tag.getList("IgnoredPlayers", NbtType.INT_ARRAY); + NbtList ignoredPlayerListTag = tag.getList("IgnoredPlayers", NbtElement.INT_ARRAY_TYPE); for (NbtElement ignoredPlayerTag : ignoredPlayerListTag) { ignoredPlayers.add(NbtHelper.toUuid(ignoredPlayerTag)); } } - if (tag.contains("PingSound", NbtType.STRING)) { + if (tag.contains("PingSound", NbtElement.STRING_TYPE)) { var soundText = tag.getString("PingSound"); if (soundText.equals("null")) { pingSound = null; } else { - pingSound = Registry.SOUND_EVENT.getOrEmpty(new Identifier(soundText)).orElse(SoundEvents.BLOCK_BELL_USE); + pingSound = Registries.SOUND_EVENT.getOrEmpty(new Identifier(soundText)).orElse(SoundEvents.BLOCK_BELL_USE); } } } diff --git a/src/main/java/me/basiqueevangelist/pingspam/mixin/MinecraftServerMixin.java b/src/main/java/me/basiqueevangelist/pingspam/mixin/MinecraftServerMixin.java index 14686ad..6b1097e 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/mixin/MinecraftServerMixin.java +++ b/src/main/java/me/basiqueevangelist/pingspam/mixin/MinecraftServerMixin.java @@ -1,9 +1,9 @@ package me.basiqueevangelist.pingspam.mixin; import me.basiqueevangelist.pingspam.utils.MessageTypeTransformer; +import net.minecraft.registry.CombinedDynamicRegistries; +import net.minecraft.registry.ServerDynamicRegistryType; import net.minecraft.server.MinecraftServer; -import net.minecraft.util.registry.DynamicRegistryManager; -import net.minecraft.world.SaveProperties; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -13,12 +13,10 @@ @Mixin(MinecraftServer.class) public abstract class MinecraftServerMixin { - @Shadow @Final protected SaveProperties saveProperties; - - @Shadow public abstract DynamicRegistryManager.Immutable getRegistryManager(); + @Shadow @Final private CombinedDynamicRegistries combinedDynamicRegistries; @Inject(method = "", at = @At(value = "RETURN")) private void finalizeWorldGen(CallbackInfo ci) { - MessageTypeTransformer.run(getRegistryManager()); + MessageTypeTransformer.run(combinedDynamicRegistries.getCombinedRegistryManager()); } } diff --git a/src/main/java/me/basiqueevangelist/pingspam/mixin/PlayerManagerMixin.java b/src/main/java/me/basiqueevangelist/pingspam/mixin/PlayerManagerMixin.java index ca99d53..a250a0c 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/mixin/PlayerManagerMixin.java +++ b/src/main/java/me/basiqueevangelist/pingspam/mixin/PlayerManagerMixin.java @@ -4,10 +4,11 @@ import me.basiqueevangelist.pingspam.utils.MessageTypeTransformer; import me.basiqueevangelist.pingspam.utils.PingLogic; import net.minecraft.network.ClientConnection; -import net.minecraft.network.message.MessageSourceProfile; import net.minecraft.network.message.MessageType; import net.minecraft.network.message.SentMessage; import net.minecraft.network.message.SignedMessage; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.server.MinecraftServer; import net.minecraft.server.PlayerManager; import net.minecraft.server.network.ServerPlayerEntity; @@ -15,9 +16,6 @@ import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.util.Util; -import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; -import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -42,8 +40,8 @@ public void onPlayerConnected(ClientConnection conn, ServerPlayerEntity player, ServerNetworkLogic.sendServerAnnouncement(player, conn); } - @Inject(method = "broadcast(Lnet/minecraft/network/message/SignedMessage;Ljava/util/function/Predicate;Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/network/message/MessageSourceProfile;Lnet/minecraft/network/message/MessageType$Parameters;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;logChatMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageType$Parameters;Ljava/lang/String;)V", shift = At.Shift.AFTER)) - public void processPingSigned(SignedMessage message, Predicate shouldSendFiltered, @Nullable ServerPlayerEntity sender, MessageSourceProfile sourceProfile, MessageType.Parameters params, CallbackInfo ci) { + @Inject(method = "broadcast(Lnet/minecraft/network/message/SignedMessage;Ljava/util/function/Predicate;Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/network/message/MessageType$Parameters;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;logChatMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageType$Parameters;Ljava/lang/String;)V", shift = At.Shift.AFTER)) + public void processPingSigned(SignedMessage message, Predicate shouldSendFiltered, ServerPlayerEntity sender, MessageType.Parameters params, CallbackInfo ci) { Decoration rule = params.type().chat(); UUID uuid = sender == null ? Util.NIL_UUID : sender.getUuid(); @@ -57,17 +55,17 @@ private void deletePing(CallbackInfo ci) { pong = null; } - @Redirect(method = "broadcast(Lnet/minecraft/network/message/SignedMessage;Ljava/util/function/Predicate;Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/network/message/MessageSourceProfile;Lnet/minecraft/network/message/MessageType$Parameters;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;sendChatMessage(Lnet/minecraft/network/message/SentMessage;ZLnet/minecraft/network/message/MessageType$Parameters;)V")) + @Redirect(method = "broadcast(Lnet/minecraft/network/message/SignedMessage;Ljava/util/function/Predicate;Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/network/message/MessageType$Parameters;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;sendChatMessage(Lnet/minecraft/network/message/SentMessage;ZLnet/minecraft/network/message/MessageType$Parameters;)V")) private void sendMessageSigned(ServerPlayerEntity player, SentMessage message, boolean filterMaskEnabled, MessageType.Parameters params) { if (pong != null && pong.pingSucceeded) { - var typeRegistry = server.getRegistryManager().get(Registry.MESSAGE_TYPE_KEY); + var typeRegistry = server.getRegistryManager().get(RegistryKeys.MESSAGE_TYPE); var oldKey = typeRegistry.getKey(params.type()).orElseThrow(); RegistryKey newKey = null; if (pong.pingedPlayers.contains(player.getUuid())) { - newKey = RegistryKey.of(Registry.MESSAGE_TYPE_KEY, MessageTypeTransformer.wrapPinged(oldKey.getValue())); + newKey = RegistryKey.of(RegistryKeys.MESSAGE_TYPE, MessageTypeTransformer.wrapPinged(oldKey.getValue())); } else if (pong.sender == player) { - newKey = RegistryKey.of(Registry.MESSAGE_TYPE_KEY, MessageTypeTransformer.wrapPingSuccessful(oldKey.getValue())); + newKey = RegistryKey.of(RegistryKeys.MESSAGE_TYPE, MessageTypeTransformer.wrapPingSuccessful(oldKey.getValue())); pong.pingedPlayers.add(pong.sender.getUuid()); } diff --git a/src/main/java/me/basiqueevangelist/pingspam/mixin/ServerPlayerEntityMixin.java b/src/main/java/me/basiqueevangelist/pingspam/mixin/ServerPlayerEntityMixin.java index ce6aacb..ab0275b 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/mixin/ServerPlayerEntityMixin.java +++ b/src/main/java/me/basiqueevangelist/pingspam/mixin/ServerPlayerEntityMixin.java @@ -5,7 +5,6 @@ import me.basiqueevangelist.pingspam.PingSpam; import me.basiqueevangelist.pingspam.data.PingspamPlayerData; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.network.encryption.PlayerPublicKey; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; @@ -14,7 +13,6 @@ import net.minecraft.text.Text; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -26,8 +24,8 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntity { @Unique private static final int ACTIONBAR_TIME = 10; - public ServerPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile gameProfile, @Nullable PlayerPublicKey publicKey) { - super(world, pos, yaw, gameProfile, publicKey); + public ServerPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile gameProfile) { + super(world, pos, yaw, gameProfile); } @Shadow public abstract void playSound(SoundEvent event, SoundCategory category, float volume, float pitch); @@ -39,7 +37,7 @@ public ServerPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile @Unique private int actionbarTime = 0; @Inject(method = "", at = @At("RETURN")) - private void loadPingspamData(MinecraftServer server, ServerWorld world, GameProfile profile, PlayerPublicKey publicKey, CallbackInfo ci) { + private void loadPingspamData(MinecraftServer server, ServerWorld world, GameProfile profile, CallbackInfo ci) { if (isImpostor()) return; pingspamData = DataStore.getFor(server).getPlayer(uuid, PingSpam.PLAYER_DATA); diff --git a/src/main/java/me/basiqueevangelist/pingspam/mixin/SimpleRegistryMixin.java b/src/main/java/me/basiqueevangelist/pingspam/mixin/SimpleRegistryMixin.java index e1db679..233a987 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/mixin/SimpleRegistryMixin.java +++ b/src/main/java/me/basiqueevangelist/pingspam/mixin/SimpleRegistryMixin.java @@ -1,35 +1,42 @@ package me.basiqueevangelist.pingspam.mixin; +import com.mojang.serialization.Lifecycle; import me.basiqueevangelist.pingspam.access.ExtendedRegistry; -import net.minecraft.util.registry.RegistryEntry; -import net.minecraft.util.registry.SimpleRegistry; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.SimpleRegistry; +import net.minecraft.registry.entry.RegistryEntry; import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.IdentityHashMap; import java.util.List; import java.util.Map; -import java.util.function.Function; @Mixin(SimpleRegistry.class) public class SimpleRegistryMixin implements ExtendedRegistry { + private boolean pingspam$intrusive; - @Shadow private boolean frozen; + @Shadow private @Nullable List> cachedEntries; - @Shadow @Final private @Nullable Function> valueToEntryFunction; + @Shadow @Nullable private Map> intrusiveValueToEntry; - @Shadow private @Nullable Map> unfrozenValueToEntry; + @Shadow private boolean frozen; - @Shadow private @Nullable List> cachedEntries; + @Inject(method = "(Lnet/minecraft/registry/RegistryKey;Lcom/mojang/serialization/Lifecycle;Z)V", at = @At("TAIL")) + private void saveIntrusiveness(RegistryKey key, Lifecycle lifecycle, boolean intrusive, CallbackInfo ci) { + pingspam$intrusive = intrusive; + } @Override public void pingspam$unfreeze() { frozen = false; - if (valueToEntryFunction != null) - this.unfrozenValueToEntry = new IdentityHashMap<>(); + if (pingspam$intrusive) + this.intrusiveValueToEntry = new IdentityHashMap<>(); cachedEntries = null; } diff --git a/src/main/java/me/basiqueevangelist/pingspam/utils/MessageTypeTransformer.java b/src/main/java/me/basiqueevangelist/pingspam/utils/MessageTypeTransformer.java index 6ce2144..41da396 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/utils/MessageTypeTransformer.java +++ b/src/main/java/me/basiqueevangelist/pingspam/utils/MessageTypeTransformer.java @@ -2,12 +2,13 @@ import me.basiqueevangelist.pingspam.access.ExtendedRegistry; import net.minecraft.network.message.MessageType; +import net.minecraft.registry.DynamicRegistryManager; +import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKeys; import net.minecraft.text.Decoration; import net.minecraft.text.Style; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.DynamicRegistryManager; -import net.minecraft.util.registry.Registry; import java.util.HashMap; import java.util.Map; @@ -15,7 +16,7 @@ public class MessageTypeTransformer { public static void run(DynamicRegistryManager drm) { - Registry reg = drm.get(Registry.MESSAGE_TYPE_KEY); + Registry reg = drm.get(RegistryKeys.MESSAGE_TYPE); Map addedTypes = new HashMap<>(); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 1d55d3d..8076fde 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -46,7 +46,7 @@ "depends": { "fabricloader": ">=0.7.4", "fabric": "*", - "minecraft": "1.19.x >=1.19.1", + "minecraft": "1.19.3", "fabric-permissions-api-v0": "*", "onedatastore": ">=0.1.2" }