diff --git a/build.gradle b/build.gradle index 6bb7f64..e285e2a 100644 --- a/build.gradle +++ b/build.gradle @@ -28,7 +28,7 @@ dependencies { modImplementation("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}") //SGui - modImplementation include("eu.pb4:sgui:1.5.1+1.20.5") { exclude group: "net.fabricmc.fabric-api" } + modImplementation include("eu.pb4:sgui:1.6.0+1.21") { exclude group: "net.fabricmc.fabric-api" } //Fantasy modImplementation include('xyz.nucleoid:fantasy:0.6.0+1.20.6') { exclude group: "net.fabricmc.fabric-api" } @@ -40,7 +40,7 @@ dependencies { modImplementation "com.moandjiezana.toml:toml4j:0.7.2" //carpet - modImplementation('carpet:fabric-carpet:1.20.6-1.4.141+v240429') { exclude group: "net.fabricmc.fabric-api" } + modImplementation('carpet:fabric-carpet:1.21-pre3-1.4.146+v240605') { exclude group: "net.fabricmc.fabric-api" } //NoChatReports modImplementation('maven.modrinth:no-chat-reports:Fabric-1.20.6-v2.7.0') { exclude group: "net.fabricmc.fabric-api" } diff --git a/gradle.properties b/gradle.properties index 12f79aa..1500022 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,15 +2,15 @@ org.gradle.jvmargs=-Xmx2G org.gradle.parallel=true # Fabric Properties -minecraft_version=1.20.6 -yarn_mappings=1.20.6+build.2 +minecraft_version=1.21-pre4 +yarn_mappings=1.21-pre4+build.3 loader_version=0.15.11 # Fabric API -fabric_version=0.99.0+1.20.6 +fabric_version=0.100.0+1.21 # Mod Properties -mod_version=1.1.0-1.20.6 +mod_version=1.1.0-1.21 maven_group=net.kyrptonaught archives_base_name=ServerUtils diff --git a/src/main/java/net/kyrptonaught/serverutils/CMDHelper.java b/src/main/java/net/kyrptonaught/serverutils/CMDHelper.java index bae5b94..5eb670d 100644 --- a/src/main/java/net/kyrptonaught/serverutils/CMDHelper.java +++ b/src/main/java/net/kyrptonaught/serverutils/CMDHelper.java @@ -46,10 +46,10 @@ public static Supplier getFeedback(Text text) { public static Collection> getFunctions(MinecraftServer server, String id) { if (id.startsWith("#")) { - return server.getCommandFunctionManager().getTag(new Identifier(id.replaceAll("#", ""))); + return server.getCommandFunctionManager().getTag(Identifier.of(id.replaceAll("#", ""))); } - Optional> function = server.getCommandFunctionManager().getFunction(new Identifier(id)); + Optional> function = server.getCommandFunctionManager().getFunction(Identifier.of(id)); if (function.isPresent()) return Collections.singleton(function.get()); return Collections.emptySet(); diff --git a/src/main/java/net/kyrptonaught/serverutils/ServerUtilsPresencePacket.java b/src/main/java/net/kyrptonaught/serverutils/ServerUtilsPresencePacket.java index e0b2158..4c756cd 100644 --- a/src/main/java/net/kyrptonaught/serverutils/ServerUtilsPresencePacket.java +++ b/src/main/java/net/kyrptonaught/serverutils/ServerUtilsPresencePacket.java @@ -8,7 +8,7 @@ import net.minecraft.util.Identifier; public record ServerUtilsPresencePacket(boolean enabled) implements CustomPayload { - public static final CustomPayload.Id PACKET_ID = new CustomPayload.Id<>(new Identifier(ServerUtilsMod.MOD_ID, "presence")); + public static final CustomPayload.Id PACKET_ID = new CustomPayload.Id<>(Identifier.of(ServerUtilsMod.MOD_ID, "presence")); public static final PacketCodec codec = PacketCodecs.BOOL.xmap(ServerUtilsPresencePacket::new, ServerUtilsPresencePacket::enabled).cast(); @Override diff --git a/src/main/java/net/kyrptonaught/serverutils/SpectateSqueaker/SqueakPacket.java b/src/main/java/net/kyrptonaught/serverutils/SpectateSqueaker/SqueakPacket.java index b8c1755..e487b2d 100644 --- a/src/main/java/net/kyrptonaught/serverutils/SpectateSqueaker/SqueakPacket.java +++ b/src/main/java/net/kyrptonaught/serverutils/SpectateSqueaker/SqueakPacket.java @@ -8,7 +8,7 @@ import net.minecraft.util.Identifier; public record SqueakPacket(boolean enabled) implements CustomPayload { - public static final Id PACKET_ID = new Id<>(new Identifier(ServerUtilsMod.SpectatorSqueakModule.getMOD_ID(), "squeak_packet")); + public static final Id PACKET_ID = new Id<>(Identifier.of(ServerUtilsMod.SpectatorSqueakModule.getMOD_ID(), "squeak_packet")); public static final PacketCodec codec = PacketCodecs.BOOL.xmap(SqueakPacket::new, SqueakPacket::enabled).cast(); @Override diff --git a/src/main/java/net/kyrptonaught/serverutils/armorHudToggle/ArmorHudPacket.java b/src/main/java/net/kyrptonaught/serverutils/armorHudToggle/ArmorHudPacket.java index 7ab5f7f..e0eabdf 100644 --- a/src/main/java/net/kyrptonaught/serverutils/armorHudToggle/ArmorHudPacket.java +++ b/src/main/java/net/kyrptonaught/serverutils/armorHudToggle/ArmorHudPacket.java @@ -7,7 +7,7 @@ import net.minecraft.util.Identifier; public record ArmorHudPacket(boolean enabled) implements CustomPayload { - public static final CustomPayload.Id PACKET_ID = new CustomPayload.Id<>(new Identifier("armorhud", "armor_hud_render_enable")); + public static final CustomPayload.Id PACKET_ID = new CustomPayload.Id<>(Identifier.of("armorhud", "armor_hud_render_enable")); public static final PacketCodec codec = PacketCodecs.BOOL.xmap(ArmorHudPacket::new, ArmorHudPacket::enabled).cast(); @Override diff --git a/src/main/java/net/kyrptonaught/serverutils/customMapLoader/addons/ResourcePackList.java b/src/main/java/net/kyrptonaught/serverutils/customMapLoader/addons/ResourcePackList.java index 00d1fb8..380d2e0 100644 --- a/src/main/java/net/kyrptonaught/serverutils/customMapLoader/addons/ResourcePackList.java +++ b/src/main/java/net/kyrptonaught/serverutils/customMapLoader/addons/ResourcePackList.java @@ -23,7 +23,7 @@ public ResourcePackList deserialize(JsonElement json, Type typeOfT, JsonDeserial if (array.get(i).isJsonObject()) { packList.packs.add(context.deserialize(array.get(i), ResourcePack.class)); } else { - packList.packs.add(SwitchableResourcepacksMod.ResourcePacks.get(new Identifier(array.get(i).getAsString()))); + packList.packs.add(SwitchableResourcepacksMod.ResourcePacks.get(Identifier.of(array.get(i).getAsString()))); } } diff --git a/src/main/java/net/kyrptonaught/serverutils/customMapLoader/converter/Converter.java b/src/main/java/net/kyrptonaught/serverutils/customMapLoader/converter/Converter.java index d10ae90..0776ad1 100644 --- a/src/main/java/net/kyrptonaught/serverutils/customMapLoader/converter/Converter.java +++ b/src/main/java/net/kyrptonaught/serverutils/customMapLoader/converter/Converter.java @@ -1,6 +1,5 @@ package net.kyrptonaught.serverutils.customMapLoader.converter; -import com.google.common.collect.ImmutableMap; import com.google.common.collect.Sets; import com.google.gson.JsonObject; import net.fabricmc.loader.api.FabricLoader; @@ -11,9 +10,7 @@ import net.kyrptonaught.serverutils.customMapLoader.addons.BattleMusic; import net.kyrptonaught.serverutils.customMapLoader.addons.LobbyMapAddon; import net.kyrptonaught.serverutils.customMapLoader.addons.ResourcePackList; -import net.kyrptonaught.serverutils.switchableresourcepacks.MusicPack; import net.kyrptonaught.serverutils.switchableresourcepacks.ResourcePack; -import net.kyrptonaught.serverutils.switchableresourcepacks.ResourcePackConfig; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; import net.minecraft.nbt.NbtIo; @@ -39,19 +36,6 @@ public static void ConvertAll() { } public static void BattleConvert() { - Map musicPacks = new HashMap<>(); - musicPacks.put("lem.battle:chinese", new MusicPackData(ImmutableMap.of("1", 199, "2", 145, "3", 206, "4", 211))); - musicPacks.put("lem.battle:city", new MusicPackData(ImmutableMap.of("1", 179, "2", 196, "3", 194, "4", 228, "5", 183))); - musicPacks.put("lem.battle:fallout", new MusicPackData(ImmutableMap.of("1", 183, "2", 179, "3", 193, "4", 188, "5", 208, "6", 126, "7", 103))); - musicPacks.put("lem.battle:fantasy", new MusicPackData(ImmutableMap.of("1", 130, "2", 214, "3", 222))); - musicPacks.put("lem.battle:festive", new MusicPackData(ImmutableMap.of("1", 138, "2", 156, "3", 165))); - musicPacks.put("lem.battle:greek", new MusicPackData(ImmutableMap.of("1", 155, "2", 215, "3", 216))); - musicPacks.put("lem.battle:halloween", new MusicPackData(ImmutableMap.of("1", 151, "2", 166, "3", 164))); - musicPacks.put("lem.battle:plastic", new MusicPackData(ImmutableMap.of("1", 135, "2", 155, "3", 150))); - musicPacks.put("lem.battle:steampunk", new MusicPackData(ImmutableMap.of("1", 170, "2", 179, "3", 223, "4", 190))); - musicPacks.put("lem.battle:vanilla", new MusicPackData(ImmutableMap.of("1", 491, "2", 489, "3", 508, "4", 528))); - musicPacks.put("lem.battle:western", new MusicPackData(ImmutableMap.of("1", 140, "2", 148, "3", 172))); - BattleMapData[] battlemaps = new BattleMapData[]{ new BattleMapData("cavern", "lem.base:vanilla", "mappack0", "lem.battle.mapdecider.menu.voting.mappack0"), new BattleMapData("cove", "lem.base:vanilla", "mappack0", "lem.battle.mapdecider.menu.voting.mappack0"), @@ -110,7 +94,7 @@ public static void BattleConvert() { FileHelper.createDir(tempOut); BattleMapAddon addon = new BattleMapAddon(); - addon.addon_id = new Identifier("4jstudios", map.mapName); + addon.addon_id = Identifier.of("4jstudios", map.mapName); addon.addon_type = BattleMapAddon.TYPE; addon.addon_pack = map.mappack; addon.addon_pack_key = map.mappackkey; @@ -207,7 +191,7 @@ public static void LobbyConvert() { FileHelper.createDir(tempOut); LobbyMapAddon addon = new LobbyMapAddon(); - addon.addon_id = new Identifier("4jstudios", lobby.mapName); + addon.addon_id = Identifier.of("4jstudios", lobby.mapName); addon.addon_type = LobbyMapAddon.TYPE; addon.addon_pack = "base"; addon.name_key = "lem.menu.host.config.update.lobby." + lobby.mapName; @@ -270,7 +254,7 @@ public static void LEBModsConvert() { FileHelper.createDir(tempOut); BattleMapAddon addon = new BattleMapAddon(); - addon.addon_id = new Identifier("lemcommunity", rawConfig.get("id").getAsString()); + addon.addon_id = Identifier.of("lemcommunity", rawConfig.get("id").getAsString()); addon.addon_type = BattleMapAddon.TYPE; addon.addon_pack = "Other"; addon.name = mapname; @@ -402,35 +386,17 @@ public record BattleMapData(String mapName, String resourcepack, String mappack, public record LobbyMapData(String mapName, String resourcepack, String winnercoords) { } - public record MusicPackData(Map songs) { - - public MusicPack build(String id) { - MusicPack pack = new MusicPack(); - pack.packID = new Identifier(id); - pack.play_order = MusicPack.PLAY_ORDER.CHRONOLOGICAL; - - LinkedHashMap map = new LinkedHashMap<>(); - for (String song : songs.keySet()) { - map.put(new Identifier(id.replace("lem.battle:", "lem.battle:music.") + "." + song), songs.get(song)); - } - pack.songs = map; - - return pack; - } - } - - public static class DummyPack extends ResourcePack { public DummyPack(String pack) { super(); - this.packID = new Identifier(pack); + this.packID = Identifier.of(pack); } } public static class DummyMusic extends BattleMusic { public DummyMusic(String pack) { super(); - this.packID = new Identifier(pack); + this.packID = Identifier.of(pack); } } diff --git a/src/main/java/net/kyrptonaught/serverutils/customMapLoader/voting/HostOptions.java b/src/main/java/net/kyrptonaught/serverutils/customMapLoader/voting/HostOptions.java index 1852cee..a45b0a8 100644 --- a/src/main/java/net/kyrptonaught/serverutils/customMapLoader/voting/HostOptions.java +++ b/src/main/java/net/kyrptonaught/serverutils/customMapLoader/voting/HostOptions.java @@ -16,7 +16,7 @@ public static void enableDisableMap(MinecraftServer server, Identifier map, bool } public static Identifier getMapResourcePackKey(Identifier mapID, Identifier packID) { - return new Identifier("acceptedpacks", mapID.toUnderscoreSeparatedString() + "." + packID.toUnderscoreSeparatedString()); + return Identifier.of("acceptedpacks", mapID.toUnderscoreSeparatedString() + "." + packID.toUnderscoreSeparatedString()); } public static boolean getMapResourcePackValue(ServerPlayerEntity player, Identifier mapID, Identifier packID) { @@ -24,7 +24,7 @@ public static boolean getMapResourcePackValue(ServerPlayerEntity player, Identif } public static Identifier getGlobalAcceptKey() { - return new Identifier("acceptedpacks", "global_accept"); + return Identifier.of("acceptedpacks", "global_accept"); } public static boolean getGlobalAcceptValue(ServerPlayerEntity player) { @@ -32,7 +32,7 @@ public static boolean getGlobalAcceptValue(ServerPlayerEntity player) { } public static Identifier getOverwriteKey(Identifier mapID) { - return new Identifier("acceptedpacks", "acceptance_policy." + mapID.toUnderscoreSeparatedString() + ".dontaskagain"); + return Identifier.of("acceptedpacks", "acceptance_policy." + mapID.toUnderscoreSeparatedString() + ".dontaskagain"); } public static boolean getOverwriteValue(ServerPlayerEntity player, Identifier mapID) { diff --git a/src/main/java/net/kyrptonaught/serverutils/customMapLoader/voting/Votebook.java b/src/main/java/net/kyrptonaught/serverutils/customMapLoader/voting/Votebook.java index 6245aea..9ee5903 100644 --- a/src/main/java/net/kyrptonaught/serverutils/customMapLoader/voting/Votebook.java +++ b/src/main/java/net/kyrptonaught/serverutils/customMapLoader/voting/Votebook.java @@ -282,7 +282,7 @@ private static void generateMapEnableDisable(DynamicData data, BookPage bookPage } private static void generateMapExtras(DynamicData data, BookPage bookPage) { - BattleMapAddon addon = CustomMapLoaderMod.BATTLE_MAPS.get(new Identifier(data.arg(2))); + BattleMapAddon addon = CustomMapLoaderMod.BATTLE_MAPS.get(Identifier.of(data.arg(2))); Text requiredHeader = withHover(dashTrans("lem.mapdecider.menu.requiredpacks"), trimName(addon.getNameText(), 20)); if (addon.required_packs == null || addon.required_packs.packs.isEmpty()) { diff --git a/src/main/java/net/kyrptonaught/serverutils/customUI/CustomUI.java b/src/main/java/net/kyrptonaught/serverutils/customUI/CustomUI.java index b2993b6..2445fd8 100644 --- a/src/main/java/net/kyrptonaught/serverutils/customUI/CustomUI.java +++ b/src/main/java/net/kyrptonaught/serverutils/customUI/CustomUI.java @@ -134,7 +134,7 @@ private static ScreenConfig.SlotDefinition getSlotDefinition(ScreenConfig.SlotDe } } - slotDefinition.generatedStack = Registries.ITEM.get(new Identifier(slotDefinition.itemID)).getDefaultStack(); + slotDefinition.generatedStack = Registries.ITEM.get(Identifier.of(slotDefinition.itemID)).getDefaultStack(); if (slotDefinition.itemNBT != null) try { @@ -217,7 +217,7 @@ private static Text getAsText(String text) { private static void playSound(ServerPlayerEntity player, String soundID) { if (soundID != null) { - RegistryEntry sound = RegistryEntry.of(SoundEvent.of(new Identifier(soundID))); + RegistryEntry sound = RegistryEntry.of(SoundEvent.of(Identifier.of(soundID))); Vec3d pos = player.getPos(); player.networkHandler.sendPacket(new PlaySoundS2CPacket(sound, SoundCategory.MASTER, pos.x, pos.y, pos.z, 1, 1, player.getRandom().nextLong())); } diff --git a/src/main/java/net/kyrptonaught/serverutils/customUI/ScreenConfigLoader.java b/src/main/java/net/kyrptonaught/serverutils/customUI/ScreenConfigLoader.java index 7fba7b6..a8beb7f 100644 --- a/src/main/java/net/kyrptonaught/serverutils/customUI/ScreenConfigLoader.java +++ b/src/main/java/net/kyrptonaught/serverutils/customUI/ScreenConfigLoader.java @@ -11,7 +11,7 @@ import java.util.Map; public class ScreenConfigLoader implements SimpleSynchronousResourceReloadListener { - public static final Identifier ID = new Identifier(ServerUtilsMod.MOD_ID, ServerUtilsMod.CustomUIModule.getMOD_ID()); + public static final Identifier ID = Identifier.of(ServerUtilsMod.MOD_ID, ServerUtilsMod.CustomUIModule.getMOD_ID()); @Override public Identifier getFabricId() { diff --git a/src/main/java/net/kyrptonaught/serverutils/customWorldBorder/CustomWorldBorderManager.java b/src/main/java/net/kyrptonaught/serverutils/customWorldBorder/CustomWorldBorderManager.java index 0139268..bd4c871 100644 --- a/src/main/java/net/kyrptonaught/serverutils/customWorldBorder/CustomWorldBorderManager.java +++ b/src/main/java/net/kyrptonaught/serverutils/customWorldBorder/CustomWorldBorderManager.java @@ -105,15 +105,15 @@ public void tickPlayer(ServerPlayerEntity player, WorldBorder worldBorder) { private static void checkBounds(ServerPlayerEntity player, WorldBorder worldBorder, double maxY) { if (player.getX() > worldBorder.getBoundEast()) - player.teleport(worldBorder.getBoundEast() - .5, player.getY(), player.getZ()); + player.requestTeleport(worldBorder.getBoundEast() - .5, player.getY(), player.getZ()); if (player.getX() < worldBorder.getBoundWest()) - player.teleport(worldBorder.getBoundWest() + .5, player.getY(), player.getZ()); + player.requestTeleport(worldBorder.getBoundWest() + .5, player.getY(), player.getZ()); if (player.getZ() > worldBorder.getBoundSouth()) - player.teleport(player.getX(), player.getY(), worldBorder.getBoundSouth() - .5); + player.requestTeleport(player.getX(), player.getY(), worldBorder.getBoundSouth() - .5); if (player.getZ() < worldBorder.getBoundNorth()) - player.teleport(player.getX(), player.getY(), worldBorder.getBoundNorth() + .5); + player.requestTeleport(player.getX(), player.getY(), worldBorder.getBoundNorth() + .5); if (player.getY() > maxY) - player.teleport(player.getX(), maxY - .5, player.getZ()); + player.requestTeleport(player.getX(), maxY - .5, player.getZ()); } public static void sendWorldBorderPacket(ServerPlayerEntity player, WorldBorder worldBorder) { diff --git a/src/main/java/net/kyrptonaught/serverutils/customWorldBorder/CustomWorldBorderNetworking.java b/src/main/java/net/kyrptonaught/serverutils/customWorldBorder/CustomWorldBorderNetworking.java index 17b52e3..2a2dbf0 100644 --- a/src/main/java/net/kyrptonaught/serverutils/customWorldBorder/CustomWorldBorderNetworking.java +++ b/src/main/java/net/kyrptonaught/serverutils/customWorldBorder/CustomWorldBorderNetworking.java @@ -8,7 +8,7 @@ import net.minecraft.util.Identifier; public class CustomWorldBorderNetworking { - public static final Identifier CUSTOM_BORDER_PACKET = new Identifier(ServerUtilsMod.CustomWorldBorder.getMOD_ID(), "customborder"); + public static final Identifier CUSTOM_BORDER_PACKET = Identifier.of(ServerUtilsMod.CustomWorldBorder.getMOD_ID(), "customborder"); public static void sendCustomWorldBorderPacket(ServerPlayerEntity player, double xCenter, double zCenter, double xSize, double zSize) { diff --git a/src/main/java/net/kyrptonaught/serverutils/customWorldBorder/CustomWorldBorderPacket.java b/src/main/java/net/kyrptonaught/serverutils/customWorldBorder/CustomWorldBorderPacket.java index 82695b0..749a2a7 100644 --- a/src/main/java/net/kyrptonaught/serverutils/customWorldBorder/CustomWorldBorderPacket.java +++ b/src/main/java/net/kyrptonaught/serverutils/customWorldBorder/CustomWorldBorderPacket.java @@ -8,7 +8,7 @@ public record CustomWorldBorderPacket(double xCenter, double zCenter, double xSize, double zSize) implements CustomPayload { - public static final CustomPayload.Id PACKET_ID = new CustomPayload.Id<>(new Identifier(ServerUtilsMod.CustomWorldBorder.getMOD_ID(), "customborder")); + public static final CustomPayload.Id PACKET_ID = new CustomPayload.Id<>(Identifier.of(ServerUtilsMod.CustomWorldBorder.getMOD_ID(), "customborder")); public static final PacketCodec codec = PacketCodec.of(CustomWorldBorderPacket::write, CustomWorldBorderPacket::read); public static CustomWorldBorderPacket read(RegistryByteBuf buf) { diff --git a/src/main/java/net/kyrptonaught/serverutils/datapackInteractables/DatapackInteractables.java b/src/main/java/net/kyrptonaught/serverutils/datapackInteractables/DatapackInteractables.java index 27c788f..958d747 100644 --- a/src/main/java/net/kyrptonaught/serverutils/datapackInteractables/DatapackInteractables.java +++ b/src/main/java/net/kyrptonaught/serverutils/datapackInteractables/DatapackInteractables.java @@ -64,13 +64,13 @@ private static void addToBlockList(Set blockIDs, boolean clear, Map< for (String id : blockIds.keySet()) { if (!id.startsWith("#")) { - if (blockIds.get(id)) blockIDs.add(new Identifier(id)); - else blockIDs.remove(new Identifier(id)); + if (blockIds.get(id)) blockIDs.add(Identifier.of(id)); + else blockIDs.remove(Identifier.of(id)); } else { if (blockIds.get(id)) - blockIDs.addAll(getBlockIDsInTag(new Identifier(id.replaceAll("#", "")))); + blockIDs.addAll(getBlockIDsInTag(Identifier.of(id.replaceAll("#", "")))); else - blockIDs.removeAll(getBlockIDsInTag(new Identifier(id.replaceAll("#", "")))); + blockIDs.removeAll(getBlockIDsInTag(Identifier.of(id.replaceAll("#", "")))); } } } diff --git a/src/main/java/net/kyrptonaught/serverutils/datapackInteractables/DatapackLoader.java b/src/main/java/net/kyrptonaught/serverutils/datapackInteractables/DatapackLoader.java index 2cf2f82..83570e1 100644 --- a/src/main/java/net/kyrptonaught/serverutils/datapackInteractables/DatapackLoader.java +++ b/src/main/java/net/kyrptonaught/serverutils/datapackInteractables/DatapackLoader.java @@ -12,7 +12,7 @@ import java.util.Map; public class DatapackLoader implements SimpleSynchronousResourceReloadListener { - public static final Identifier ID = new Identifier(ServerUtilsMod.MOD_ID, ServerUtilsMod.DatapackInteractablesModule.getMOD_ID()); + public static final Identifier ID = Identifier.of(ServerUtilsMod.MOD_ID, ServerUtilsMod.DatapackInteractablesModule.getMOD_ID()); @Override public Identifier getFabricId() { diff --git a/src/main/java/net/kyrptonaught/serverutils/mixin/bigstructures/StructureMixin.java b/src/main/java/net/kyrptonaught/serverutils/mixin/bigstructures/StructureMixin.java index 857863e..93ee441 100644 --- a/src/main/java/net/kyrptonaught/serverutils/mixin/bigstructures/StructureMixin.java +++ b/src/main/java/net/kyrptonaught/serverutils/mixin/bigstructures/StructureMixin.java @@ -18,7 +18,7 @@ public class StructureMixin { @Redirect(method = "spawnEntities", at = @At(value = "INVOKE", target = "Ljava/util/Iterator;next()Ljava/lang/Object;")) public E fixPaintings(Iterator instance) { StructureTemplate.StructureEntityInfo nextStructureEntityInfo = instance.next(); - Optional> entityType = Registries.ENTITY_TYPE.getOrEmpty(new Identifier(nextStructureEntityInfo.nbt.getString("id"))); + Optional> entityType = Registries.ENTITY_TYPE.getOrEmpty(Identifier.of(nextStructureEntityInfo.nbt.getString("id"))); if (entityType.isPresent() && entityType.get().equals(EntityType.PAINTING)) { return (E) new StructureTemplate.StructureEntityInfo(Vec3d.of(nextStructureEntityInfo.blockPos), nextStructureEntityInfo.blockPos, nextStructureEntityInfo.nbt); } diff --git a/src/main/java/net/kyrptonaught/serverutils/mixin/chesttracker/AbstractBlockStateMixin.java b/src/main/java/net/kyrptonaught/serverutils/mixin/chesttracker/AbstractBlockStateMixin.java index 95fcd86..fbd7a67 100644 --- a/src/main/java/net/kyrptonaught/serverutils/mixin/chesttracker/AbstractBlockStateMixin.java +++ b/src/main/java/net/kyrptonaught/serverutils/mixin/chesttracker/AbstractBlockStateMixin.java @@ -8,6 +8,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.random.Random; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -15,6 +16,7 @@ @Mixin(AbstractBlock.AbstractBlockState.class) public abstract class AbstractBlockStateMixin implements BlockEntityTickerWrapper { + @Unique private BlockEntityTicker wrapper; @Inject(method = "scheduledTick", at = @At("TAIL")) diff --git a/src/main/java/net/kyrptonaught/serverutils/mixin/dimensionLoader/ServerPlayerEntityMixin.java b/src/main/java/net/kyrptonaught/serverutils/mixin/dimensionLoader/ServerPlayerEntityMixin.java index 9ad85bc..45c05b3 100644 --- a/src/main/java/net/kyrptonaught/serverutils/mixin/dimensionLoader/ServerPlayerEntityMixin.java +++ b/src/main/java/net/kyrptonaught/serverutils/mixin/dimensionLoader/ServerPlayerEntityMixin.java @@ -11,13 +11,7 @@ @Mixin(ServerPlayerEntity.class) public class ServerPlayerEntityMixin { - @Redirect(method = "teleport(Lnet/minecraft/server/world/ServerWorld;DDDFF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;createCommonPlayerSpawnInfo(Lnet/minecraft/server/world/ServerWorld;)Lnet/minecraft/network/packet/s2c/play/CommonPlayerSpawnInfo;")) - public CommonPlayerSpawnInfo tpSpoofDim(ServerPlayerEntity instance, ServerWorld world) { - CommonPlayerSpawnInfo commonPlayerSpawnInfo = instance.createCommonPlayerSpawnInfo(world); - return new CommonPlayerSpawnInfo(DimensionLoaderMod.tryGetDimKey(world), DimensionLoaderMod.tryGetWorldKey(world), commonPlayerSpawnInfo.seed(), commonPlayerSpawnInfo.gameMode(), commonPlayerSpawnInfo.prevGameMode(), commonPlayerSpawnInfo.isDebug(), commonPlayerSpawnInfo.isFlat(), commonPlayerSpawnInfo.lastDeathLocation(), commonPlayerSpawnInfo.portalCooldown()); - } - - @Redirect(method = "moveToWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;createCommonPlayerSpawnInfo(Lnet/minecraft/server/world/ServerWorld;)Lnet/minecraft/network/packet/s2c/play/CommonPlayerSpawnInfo;")) + @Redirect(method = "teleportTo", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;createCommonPlayerSpawnInfo(Lnet/minecraft/server/world/ServerWorld;)Lnet/minecraft/network/packet/s2c/play/CommonPlayerSpawnInfo;")) public CommonPlayerSpawnInfo mtwSpoofDim(ServerPlayerEntity instance, ServerWorld world) { CommonPlayerSpawnInfo commonPlayerSpawnInfo = instance.createCommonPlayerSpawnInfo(world); return new CommonPlayerSpawnInfo(DimensionLoaderMod.tryGetDimKey(world), DimensionLoaderMod.tryGetWorldKey(world), commonPlayerSpawnInfo.seed(), commonPlayerSpawnInfo.gameMode(), commonPlayerSpawnInfo.prevGameMode(), commonPlayerSpawnInfo.isDebug(), commonPlayerSpawnInfo.isFlat(), commonPlayerSpawnInfo.lastDeathLocation(), commonPlayerSpawnInfo.portalCooldown()); diff --git a/src/main/java/net/kyrptonaught/serverutils/mixin/floodgate/ServerHandshakeNetworkHandlerMixin.java b/src/main/java/net/kyrptonaught/serverutils/mixin/floodgate/ServerHandshakeNetworkHandlerMixin.java deleted file mode 100644 index eda9a9f..0000000 --- a/src/main/java/net/kyrptonaught/serverutils/mixin/floodgate/ServerHandshakeNetworkHandlerMixin.java +++ /dev/null @@ -1,30 +0,0 @@ -package net.kyrptonaught.serverutils.mixin.floodgate; - -import net.kyrptonaught.serverutils.scoreboardPlayerInfo.QueuedPlayerData; -import net.kyrptonaught.serverutils.scoreboardPlayerInfo.ScoreboardPlayerInfo; -import net.minecraft.network.ClientConnection; -import net.minecraft.network.packet.c2s.handshake.HandshakeC2SPacket; -import net.minecraft.server.network.ServerHandshakeNetworkHandler; -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; - -@Mixin(ServerHandshakeNetworkHandler.class) -public class ServerHandshakeNetworkHandlerMixin { - - @Shadow - @Final - private ClientConnection connection; - - @Inject(method = "onHandshake", at = @At("HEAD")) - public void checkForFloodgate(HandshakeC2SPacket packet, CallbackInfo ci) { - QueuedPlayerData playerDara = ScoreboardPlayerInfo.getQueuedPlayerData(this.connection, true); - - if (playerDara.isBedrock == null) { - playerDara.isBedrock = packet.address().contains("^Floodgate^"); - } - } -} diff --git a/src/main/java/net/kyrptonaught/serverutils/mixin/scoreboardsuffix/ServerPlayerEntityMixin.java b/src/main/java/net/kyrptonaught/serverutils/mixin/scoreboardsuffix/ServerPlayerEntityMixin.java index e877cbd..6aae159 100644 --- a/src/main/java/net/kyrptonaught/serverutils/mixin/scoreboardsuffix/ServerPlayerEntityMixin.java +++ b/src/main/java/net/kyrptonaught/serverutils/mixin/scoreboardsuffix/ServerPlayerEntityMixin.java @@ -55,7 +55,7 @@ private void updatePlayerNameWithScore(CallbackInfoReturnable cir) { Style style = newSuffix.displayText.getStyle(); String fontPlaceHolder = style.getFont().toString(); - style = style.withFont(new Identifier(ScoreboardSuffixMod.playerSuffixStorage.getFont(player, fontPlaceHolder))); + style = style.withFont(Identifier.of(ScoreboardSuffixMod.playerSuffixStorage.getFont(player, fontPlaceHolder))); suffix.append(newSuffix.displayText.copy().setStyle(style)); }); diff --git a/src/main/java/net/kyrptonaught/serverutils/mixin/takeeverything/ItemEntityMixin.java b/src/main/java/net/kyrptonaught/serverutils/mixin/takeeverything/ItemEntityMixin.java index c75d453..1181d98 100644 --- a/src/main/java/net/kyrptonaught/serverutils/mixin/takeeverything/ItemEntityMixin.java +++ b/src/main/java/net/kyrptonaught/serverutils/mixin/takeeverything/ItemEntityMixin.java @@ -22,7 +22,7 @@ public ItemEntityMixin(EntityType type, World world) { @Redirect(method = "onPlayerCollision", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerInventory;insertStack(Lnet/minecraft/item/ItemStack;)Z")) public boolean autoEquip(PlayerInventory instance, ItemStack stack) { - if (TakeEverythingHelper.isSwappableItem(stack)) { + if (TakeEverythingHelper.isSwappableItem(instance.player, stack)) { if (TakeEverythingHelper.canEquip(instance.player, stack)) { TakeEverythingHelper.equipOrSwapArmor(instance.player, stack, false); return true; diff --git a/src/main/java/net/kyrptonaught/serverutils/mixin/takeeverything/ScreenHandlerMixin.java b/src/main/java/net/kyrptonaught/serverutils/mixin/takeeverything/ScreenHandlerMixin.java index fc782cf..cadae20 100644 --- a/src/main/java/net/kyrptonaught/serverutils/mixin/takeeverything/ScreenHandlerMixin.java +++ b/src/main/java/net/kyrptonaught/serverutils/mixin/takeeverything/ScreenHandlerMixin.java @@ -31,7 +31,7 @@ public void takeEverything(int slotIndex, int button, SlotActionType actionType, if (!player.getWorld().isClient) { if (actionType.equals(SlotActionType.QUICK_MOVE)) { Slot slot = slots.get(slotIndex); - if (slot.canTakeItems(player) && !(slot.inventory instanceof PlayerInventory) && !slot.getStack().isEmpty() && TakeEverythingHelper.isSwappableItem(slot.getStack())) { + if (slot.canTakeItems(player) && !(slot.inventory instanceof PlayerInventory) && !slot.getStack().isEmpty() && TakeEverythingHelper.isSwappableItem(player, slot.getStack())) { ItemStack oldStack = TakeEverythingHelper.equipOrSwapArmor(player, slot.getStack(), false); //return already equippedStack or empty if (!oldStack.isEmpty()) slot.setStack(oldStack); } diff --git a/src/main/java/net/kyrptonaught/serverutils/noteblockMusic/NoteblockMusicMod.java b/src/main/java/net/kyrptonaught/serverutils/noteblockMusic/NoteblockMusicMod.java index 435927c..427f386 100644 --- a/src/main/java/net/kyrptonaught/serverutils/noteblockMusic/NoteblockMusicMod.java +++ b/src/main/java/net/kyrptonaught/serverutils/noteblockMusic/NoteblockMusicMod.java @@ -135,7 +135,7 @@ private static void primeSongPlayer(SongPlayer songPlayer, CommandContext dispa for (int i = begin; i < end; i++) { String output = "a" + Padder.smartPad(i, "") + "a"; - context.getSource().sendFeedback(CMDHelper.getFeedbackLiteral(output).setStyle(Style.EMPTY.withFont(new Identifier("4jmenu:panorama/1/day/3"))), false); + context.getSource().sendFeedback(CMDHelper.getFeedbackLiteral(output).setStyle(Style.EMPTY.withFont(Identifier.of("4jmenu:panorama/1/day/3"))), false); } return 1; })) .executes(context -> { int begin = IntegerArgumentType.getInteger(context, "begin"); String output = "a" + Padder.smartPad(begin, "") + "a"; - context.getSource().sendFeedback(CMDHelper.getFeedbackLiteral(output).setStyle(Style.EMPTY.withFont(new Identifier("4jmenu:panorama/1/day/3"))), false); + context.getSource().sendFeedback(CMDHelper.getFeedbackLiteral(output).setStyle(Style.EMPTY.withFont(Identifier.of("4jmenu:panorama/1/day/3"))), false); return 1; }))); */ @@ -80,7 +80,7 @@ public static void registerCommands(CommandDispatcher dispa public static int executeClear(CommandContext commandContext, Collection players) { BossBarManager bossMan = commandContext.getSource().getServer().getBossBarManager(); for (String panoramaName : PanoramaViewer.panoramaEntries.keySet()) { - CommandBossBar bossBar = bossMan.get(new Identifier(PanoramaViewer.MOD_ID, panoramaName)); + CommandBossBar bossBar = bossMan.get(Identifier.of(PanoramaViewer.MOD_ID, panoramaName)); if (bossBar != null) { if (players == null) bossBar.clearPlayers(); @@ -113,9 +113,9 @@ public static int execute(CommandContext commandContext, Pa } BossBarManager bossMan = commandContext.getSource().getServer().getBossBarManager(); - CommandBossBar bossBar = bossMan.get(new Identifier(PanoramaViewer.MOD_ID, panorama.panoramaName)); + CommandBossBar bossBar = bossMan.get(Identifier.of(PanoramaViewer.MOD_ID, panorama.panoramaName)); if (bossBar == null) { - bossBar = bossMan.add(new Identifier(PanoramaViewer.MOD_ID, panorama.panoramaName), panorama.getPaddedText()); + bossBar = bossMan.add(Identifier.of(PanoramaViewer.MOD_ID, panorama.panoramaName), panorama.getPaddedText()); } for (ServerPlayerEntity player : players) diff --git a/src/main/java/net/kyrptonaught/serverutils/panoramaViewer/PanoramaViewer.java b/src/main/java/net/kyrptonaught/serverutils/panoramaViewer/PanoramaViewer.java index 34cea41..9555208 100644 --- a/src/main/java/net/kyrptonaught/serverutils/panoramaViewer/PanoramaViewer.java +++ b/src/main/java/net/kyrptonaught/serverutils/panoramaViewer/PanoramaViewer.java @@ -25,7 +25,7 @@ public void onInitialize() { BossBarManager bossMan = server.getBossBarManager(); for (Panorama panorama : panoramaEntries.values()) { - CommandBossBar bossBar = bossMan.get(new Identifier(MOD_ID, panorama.panoramaName)); + CommandBossBar bossBar = bossMan.get(Identifier.of(MOD_ID, panorama.panoramaName)); if (!panorama.frameCounter.doesTick() || bossBar == null || bossBar.getPlayers().isEmpty()) continue; panorama.tickFrameCounter(); diff --git a/src/main/java/net/kyrptonaught/serverutils/playerlockdown/PlayerLockdownMod.java b/src/main/java/net/kyrptonaught/serverutils/playerlockdown/PlayerLockdownMod.java index 2349ea6..b56ada0 100644 --- a/src/main/java/net/kyrptonaught/serverutils/playerlockdown/PlayerLockdownMod.java +++ b/src/main/java/net/kyrptonaught/serverutils/playerlockdown/PlayerLockdownMod.java @@ -46,7 +46,7 @@ public void onInitialize() { for (ServerPlayerEntity player : server.getPlayerManager().getPlayerList()) { Vec3d pos = FROZENPLAYERS.get(player.getUuidAsString()); if (pos != null && !pos.equals(player.getPos())) { - player.teleport(pos.getX(), pos.getY(), pos.getZ()); + player.requestTeleport(pos.getX(), pos.getY(), pos.getZ()); } } } diff --git a/src/main/java/net/kyrptonaught/serverutils/scoreboardPlayerInfo/QueuedPlayerData.java b/src/main/java/net/kyrptonaught/serverutils/scoreboardPlayerInfo/QueuedPlayerData.java index f7b619c..e5f5f86 100644 --- a/src/main/java/net/kyrptonaught/serverutils/scoreboardPlayerInfo/QueuedPlayerData.java +++ b/src/main/java/net/kyrptonaught/serverutils/scoreboardPlayerInfo/QueuedPlayerData.java @@ -7,7 +7,6 @@ public class QueuedPlayerData { public Boolean hasLCH; public Boolean hasOptishit; public Boolean hasController; - public Boolean isBedrock; public Integer guiScale; public Integer panScale; diff --git a/src/main/java/net/kyrptonaught/serverutils/scoreboardPlayerInfo/ScoreboardPlayerInfo.java b/src/main/java/net/kyrptonaught/serverutils/scoreboardPlayerInfo/ScoreboardPlayerInfo.java index 530e48d..6fbd805 100644 --- a/src/main/java/net/kyrptonaught/serverutils/scoreboardPlayerInfo/ScoreboardPlayerInfo.java +++ b/src/main/java/net/kyrptonaught/serverutils/scoreboardPlayerInfo/ScoreboardPlayerInfo.java @@ -34,7 +34,6 @@ public class ScoreboardPlayerInfo extends Module { private static final CustomObjective hasControllerModObjective = createObj("hascontroller", "Client has Controller Mod"); private static final CustomObjective fabricClientObjective = createObj("fabricclient", "Client is using Fabric"); private static final CustomObjective forgeClientObjective = createObj("forgeclient", "Client is using Forge"); - private static final CustomObjective bedrockClientObjective = createObj("bedrockclient", "Client is using Bedrock"); private static final CustomObjective clientGUIScaleObjective = createObj("clientguiscale", "Client's GUI Scale"); private static final CustomObjective clientPanScaleObjective = createObj("clientpanscale", "Client's Panorama Scale"); @@ -97,13 +96,12 @@ public static void onPlayerConnect(ServerPlayNetworkHandler handler, PacketSende setHasLEMClient(handler.player, playerData.hasLCH); setHasOptifine(handler.player, playerData.hasOptishit); setHasControllerMod(handler.player, playerData.hasController); - setBedrockClient(handler.player, playerData.isBedrock); setGUIScale(handler.player, playerData.guiScale); setPanScale(handler.player, playerData.panScale); checkBrand(handler.player, playerData.brand); } - if (ServerPlayNetworking.canSend(handler, new Identifier("fabric:registry/sync"))) + if (ServerPlayNetworking.canSend(handler, Identifier.of("fabric:registry/sync"))) setFabricClient(handler.player, true); } @@ -128,11 +126,6 @@ public static void setForgeClient(PlayerEntity player, boolean forgeClient) { forgeClientObjective.setScore(player, forgeClient ? 2 : 1); } - public static void setBedrockClient(PlayerEntity player, Boolean bedrockClient) { - if (bedrockClient != null) - bedrockClientObjective.setScore(player, bedrockClient ? 2 : 1); - } - public static void addClientConnectionProtocol(ClientConnection connection, int protocol) { getQueuedPlayerData(connection, true).protocolVersion = protocol; } diff --git a/src/main/java/net/kyrptonaught/serverutils/scoreboardPlayerInfo/ScoreboardPlayerInfoNetworking.java b/src/main/java/net/kyrptonaught/serverutils/scoreboardPlayerInfo/ScoreboardPlayerInfoNetworking.java index eddee5b..1a2f754 100644 --- a/src/main/java/net/kyrptonaught/serverutils/scoreboardPlayerInfo/ScoreboardPlayerInfoNetworking.java +++ b/src/main/java/net/kyrptonaught/serverutils/scoreboardPlayerInfo/ScoreboardPlayerInfoNetworking.java @@ -9,7 +9,7 @@ import net.minecraft.util.Identifier; public class ScoreboardPlayerInfoNetworking { - private static final Identifier HAS_MODS_PACKET = new Identifier(ServerUtilsMod.ScoreboardPlayerInfoModule.getMOD_ID(), "has_mods_packet"); + private static final Identifier HAS_MODS_PACKET = Identifier.of(ServerUtilsMod.ScoreboardPlayerInfoModule.getMOD_ID(), "has_mods_packet"); public static void registerReceivePacket() { ServerLoginConnectionEvents.QUERY_START.register((handler, server, sender, synchronizer) -> { diff --git a/src/main/java/net/kyrptonaught/serverutils/scoreboardsuffix/ScoreboardSuffixMod.java b/src/main/java/net/kyrptonaught/serverutils/scoreboardsuffix/ScoreboardSuffixMod.java index 1163508..5454d41 100644 --- a/src/main/java/net/kyrptonaught/serverutils/scoreboardsuffix/ScoreboardSuffixMod.java +++ b/src/main/java/net/kyrptonaught/serverutils/scoreboardsuffix/ScoreboardSuffixMod.java @@ -64,8 +64,8 @@ public void registerCommands(CommandDispatcher dispatcher) } public static int executeSetSuffix(CommandContext context, Collection players) { - String placeholder = new Identifier(StringArgumentType.getString(context, "fontPlaceholder")).toString(); - String font = new Identifier(StringArgumentType.getString(context, "font")).toString(); + String placeholder = Identifier.of(StringArgumentType.getString(context, "fontPlaceholder")).toString(); + String font = Identifier.of(StringArgumentType.getString(context, "font")).toString(); players.forEach(serverPlayerEntity -> { String playerName = serverPlayerEntity.getNameForScoreboard(); playerSuffixStorage.setFont(playerName, placeholder, font); diff --git a/src/main/java/net/kyrptonaught/serverutils/serverTranslator/TranslationLoader.java b/src/main/java/net/kyrptonaught/serverutils/serverTranslator/TranslationLoader.java index be40b2f..8787896 100644 --- a/src/main/java/net/kyrptonaught/serverutils/serverTranslator/TranslationLoader.java +++ b/src/main/java/net/kyrptonaught/serverutils/serverTranslator/TranslationLoader.java @@ -12,7 +12,7 @@ import java.util.Map; public class TranslationLoader implements SimpleSynchronousResourceReloadListener { - public static final Identifier ID = new Identifier(ServerUtilsMod.MOD_ID, ServerUtilsMod.ServerTranslatorModule.getMOD_ID()); + public static final Identifier ID = Identifier.of(ServerUtilsMod.MOD_ID, ServerUtilsMod.ServerTranslatorModule.getMOD_ID()); @Override public Identifier getFabricId() { diff --git a/src/main/java/net/kyrptonaught/serverutils/switchableresourcepacks/SwitchableResourcepacksMod.java b/src/main/java/net/kyrptonaught/serverutils/switchableresourcepacks/SwitchableResourcepacksMod.java index c5367a0..9f8af57 100644 --- a/src/main/java/net/kyrptonaught/serverutils/switchableresourcepacks/SwitchableResourcepacksMod.java +++ b/src/main/java/net/kyrptonaught/serverutils/switchableresourcepacks/SwitchableResourcepacksMod.java @@ -27,8 +27,8 @@ public class SwitchableResourcepacksMod extends ModuleWConfig playerLoaded = new HashMap<>(); private static Collection> RP_FAILED_FUNCTIONS, RP_LOADED_FUNCTIONS, RP_STARTED_FUNCTIONS; - private static final Identifier CUSTOMPACKID = new Identifier("custompack", "enabled"); - private static final Identifier SAFEMUSICID = new Identifier("safemusic", "enabled"); + private static final Identifier CUSTOMPACKID = Identifier.of("custompack", "enabled"); + private static final Identifier SAFEMUSICID = Identifier.of("safemusic", "enabled"); private static final UUID CUSTOMPACKUUID = UUID.nameUUIDFromBytes(CUSTOMPACKID.toString().getBytes(StandardCharsets.UTF_8)); public void onConfigLoad(ResourcePackConfig config) { diff --git a/src/main/java/net/kyrptonaught/serverutils/syncedKeybinds/KeybindPressPacket.java b/src/main/java/net/kyrptonaught/serverutils/syncedKeybinds/KeybindPressPacket.java index d155816..2ee4675 100644 --- a/src/main/java/net/kyrptonaught/serverutils/syncedKeybinds/KeybindPressPacket.java +++ b/src/main/java/net/kyrptonaught/serverutils/syncedKeybinds/KeybindPressPacket.java @@ -9,7 +9,7 @@ import static net.kyrptonaught.serverutils.ServerUtilsMod.SyncedKeybindsModule; public record KeybindPressPacket(Identifier keybind) implements CustomPayload { - public static final CustomPayload.Id PACKET_ID = new CustomPayload.Id<>(new Identifier(SyncedKeybindsModule.getMOD_ID(), "sync_keybinds_packet")); + public static final CustomPayload.Id PACKET_ID = new CustomPayload.Id<>(Identifier.of(SyncedKeybindsModule.getMOD_ID(), "sync_keybinds_packet")); public static final PacketCodec codec = Identifier.PACKET_CODEC.xmap(KeybindPressPacket::new, KeybindPressPacket::keybind).cast(); @Override diff --git a/src/main/java/net/kyrptonaught/serverutils/syncedKeybinds/SyncKeybindsPacket.java b/src/main/java/net/kyrptonaught/serverutils/syncedKeybinds/SyncKeybindsPacket.java index 5eaad7a..e82a6f2 100644 --- a/src/main/java/net/kyrptonaught/serverutils/syncedKeybinds/SyncKeybindsPacket.java +++ b/src/main/java/net/kyrptonaught/serverutils/syncedKeybinds/SyncKeybindsPacket.java @@ -12,7 +12,7 @@ public record SyncKeybindsPacket( HashMap keybinds) implements CustomPayload { - public static final CustomPayload.Id PACKET_ID = new CustomPayload.Id<>(new Identifier(SyncedKeybindsModule.getMOD_ID(), "keybind_pressed_packet")); + public static final CustomPayload.Id PACKET_ID = new CustomPayload.Id<>(Identifier.of(SyncedKeybindsModule.getMOD_ID(), "keybind_pressed_packet")); public static final PacketCodec codec = PacketCodec.of(SyncKeybindsPacket::write, SyncKeybindsPacket::read); public static SyncKeybindsPacket read(RegistryByteBuf buf) { diff --git a/src/main/java/net/kyrptonaught/serverutils/takeEverything/TakeEverythingHelper.java b/src/main/java/net/kyrptonaught/serverutils/takeEverything/TakeEverythingHelper.java index 7a83282..9eb606c 100644 --- a/src/main/java/net/kyrptonaught/serverutils/takeEverything/TakeEverythingHelper.java +++ b/src/main/java/net/kyrptonaught/serverutils/takeEverything/TakeEverythingHelper.java @@ -1,13 +1,18 @@ package net.kyrptonaught.serverutils.takeEverything; +import net.fabricmc.fabric.api.item.v1.EquipmentSlotProvider; import net.minecraft.block.SkullBlock; +import net.minecraft.component.EnchantmentEffectComponentTypes; import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.enchantment.Enchantments; import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.*; import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket; import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.registry.tag.EnchantmentTags; import net.minecraft.screen.PlayerScreenHandler; import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.SlotActionType; @@ -33,14 +38,14 @@ public static boolean takeEverything(ServerPlayerEntity player) { player.currentScreenHandler.onSlotClick(i, 0, SlotActionType.QUICK_MOVE, player); } } - RegistryEntry sound = RegistryEntry.of(SoundEvent.of(new Identifier("serverutils:takeeverything"))); + RegistryEntry sound = RegistryEntry.of(SoundEvent.of(Identifier.of("serverutils:takeeverything"))); Vec3d pos = player.getPos(); player.networkHandler.sendPacket(new PlaySoundS2CPacket(sound, SoundCategory.MASTER, pos.x, pos.y, pos.z, 1, 1, player.getRandom().nextLong())); return true; } public static boolean canEquip(PlayerEntity player, ItemStack armor) { - EquipmentSlot equipmentSlot = getEquipSlot(armor); + EquipmentSlot equipmentSlot = getEquipSlot(player,armor); if (equipmentSlot == null) return false; ItemStack equipped = player.getEquippedStack(equipmentSlot); @@ -48,7 +53,7 @@ public static boolean canEquip(PlayerEntity player, ItemStack armor) { } public static boolean canSwap(PlayerEntity player, ItemStack armor, boolean alwaysSwap) { - EquipmentSlot equipmentSlot = getEquipSlot(armor); + EquipmentSlot equipmentSlot = getEquipSlot(player,armor); if (equipmentSlot == null) return false; ItemStack equipped = player.getEquippedStack(equipmentSlot); @@ -81,7 +86,7 @@ public static boolean isBetter(ItemStack og, ItemStack newStack) { } public static ItemStack equipOrSwapArmor(PlayerEntity player, ItemStack armor, boolean alwaysSwap) { - EquipmentSlot equipmentSlot = getEquipSlot(armor); + EquipmentSlot equipmentSlot = getEquipSlot(player,armor); if (equipmentSlot == null) return ItemStack.EMPTY; @@ -100,20 +105,20 @@ public static ItemStack equipOrSwapArmor(PlayerEntity player, ItemStack armor, b return ItemStack.EMPTY; } - public static EquipmentSlot getEquipSlot(ItemStack stack) { - EquipmentSlot slot = PlayerEntity.getPreferredEquipmentSlot(stack); + public static EquipmentSlot getEquipSlot(LivingEntity entity, ItemStack stack) { + EquipmentSlot slot = entity.getPreferredEquipmentSlot(stack); if (slot == EquipmentSlot.MAINHAND || slot == EquipmentSlot.OFFHAND) return null; return slot; } - public static boolean isSwappableItem(ItemStack stack) { - return getEquipSlot(stack) != null; + public static boolean isSwappableItem(LivingEntity entity,ItemStack stack) { + return getEquipSlot(entity,stack) != null; } public static Boolean hasBinding(ItemStack stack) { - return EnchantmentHelper.hasBindingCurse(stack); + return EnchantmentHelper.hasAnyEnchantmentsWith(stack, EnchantmentEffectComponentTypes.PREVENT_ARMOR_CHANGE); } public static Boolean hasEnchants(PlayerEntity playerEntity, ItemStack stack) { diff --git a/src/main/java/net/kyrptonaught/serverutils/takeEverything/TakeEverythingMod.java b/src/main/java/net/kyrptonaught/serverutils/takeEverything/TakeEverythingMod.java index bce1992..fdaf81e 100644 --- a/src/main/java/net/kyrptonaught/serverutils/takeEverything/TakeEverythingMod.java +++ b/src/main/java/net/kyrptonaught/serverutils/takeEverything/TakeEverythingMod.java @@ -35,7 +35,7 @@ public static TakeEverythingConfig getConfigStatic() { public static void registerItemUse() { UseItemCallback.EVENT.register((player, world, hand) -> { ItemStack stack = player.getStackInHand(hand); - if (!world.isClient && TakeEverythingHelper.isSwappableItem(stack)) { + if (!world.isClient && TakeEverythingHelper.isSwappableItem(player, stack)) { stack = TakeEverythingHelper.equipOrSwapArmor(player, stack, true); //return already equippedStack or empty if (!stack.isEmpty()) player.setStackInHand(hand, stack); return TypedActionResult.success(stack); diff --git a/src/main/java/net/kyrptonaught/serverutils/takeEverything/TakeEverythingPacket.java b/src/main/java/net/kyrptonaught/serverutils/takeEverything/TakeEverythingPacket.java index 707f505..44a5294 100644 --- a/src/main/java/net/kyrptonaught/serverutils/takeEverything/TakeEverythingPacket.java +++ b/src/main/java/net/kyrptonaught/serverutils/takeEverything/TakeEverythingPacket.java @@ -8,7 +8,7 @@ import net.minecraft.util.Identifier; public record TakeEverythingPacket(boolean enabled) implements CustomPayload { - public static final Id PACKET_ID = new Id<>(new Identifier(ServerUtilsMod.TakeEverythingModule.getMOD_ID(), "take_everything_packet")); + public static final Id PACKET_ID = new Id<>(Identifier.of(ServerUtilsMod.TakeEverythingModule.getMOD_ID(), "take_everything_packet")); public static final PacketCodec codec = PacketCodecs.BOOL.xmap(TakeEverythingPacket::new, TakeEverythingPacket::enabled).cast(); @Override diff --git a/src/main/java/net/kyrptonaught/serverutils/userConfig/PlayerConfigs.java b/src/main/java/net/kyrptonaught/serverutils/userConfig/PlayerConfigs.java index 048720a..5bb946f 100644 --- a/src/main/java/net/kyrptonaught/serverutils/userConfig/PlayerConfigs.java +++ b/src/main/java/net/kyrptonaught/serverutils/userConfig/PlayerConfigs.java @@ -52,13 +52,13 @@ public static PlayerConfigs load(JsonObject jsonObject) { JsonObject configs = jsonObject.getAsJsonObject("configs"); if (configs != null) for (Map.Entry innerEntry : configs.entrySet()) - playerConfigs.setValue(new Identifier(innerEntry.getKey()), innerEntry.getValue().getAsString()); + playerConfigs.setValue(Identifier.of(innerEntry.getKey()), innerEntry.getValue().getAsString()); JsonObject presets = jsonObject.getAsJsonObject("presets"); if (presets != null) for (Map.Entry innerEntry : presets.entrySet()) for (Map.Entry innerEntry2 : innerEntry.getValue().getAsJsonObject().entrySet()) - playerConfigs.setPresetValueInternal(new Identifier(innerEntry.getKey()), new Identifier(innerEntry2.getKey()), innerEntry2.getValue().getAsString()); + playerConfigs.setPresetValueInternal(Identifier.of(innerEntry.getKey()), Identifier.of(innerEntry2.getKey()), innerEntry2.getValue().getAsString()); return playerConfigs; } diff --git a/src/main/java/net/kyrptonaught/serverutils/utilityCommands/UtilCommandsMod.java b/src/main/java/net/kyrptonaught/serverutils/utilityCommands/UtilCommandsMod.java index 03a2edc..6cf4fad 100644 --- a/src/main/java/net/kyrptonaught/serverutils/utilityCommands/UtilCommandsMod.java +++ b/src/main/java/net/kyrptonaught/serverutils/utilityCommands/UtilCommandsMod.java @@ -72,7 +72,7 @@ public void registerCommands(CommandDispatcher dispatcher) BlockPos pos = BlockPosArgumentType.getBlockPos(context, "pos"); context.getSource().getServer().execute(() -> { - players.forEach(player -> player.teleport(pos.getX(), pos.getY(), pos.getZ())); + players.forEach(player -> player.requestTeleport(pos.getX(), pos.getY(), pos.getZ())); }); return 1; diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index ff719f0..c8cfa4c 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "serverutils", - "version": "1.1.0-1.20.6", + "version": "1.1.0-1.21", "name": "Server Utils", "description": "A group of utilities for servers", "authors": [ diff --git a/src/main/resources/serverutils.mixins.json b/src/main/resources/serverutils.mixins.json index 82257db..3eb5412 100644 --- a/src/main/resources/serverutils.mixins.json +++ b/src/main/resources/serverutils.mixins.json @@ -24,7 +24,6 @@ "discordBridge.ServerPlayerEntityMixin", "dropevent.ServerPlayNetworkHandlerMixin", "editablePlayerNBT.EntityDataObjectMixin", - "floodgate.ServerHandshakeNetworkHandlerMixin", "healthSpoofer.ServerPlayerEntityMixin", "knockback.LivingEntityMixin", "personatus.FixLuckPermsMixin",