From 8c64fa74a4596d6ff126c2f6657618641420c4ab Mon Sep 17 00:00:00 2001 From: RaphiMC <50594595+RaphiMC@users.noreply.github.com> Date: Wed, 17 Apr 2024 23:13:28 +0200 Subject: [PATCH] Initial 1.20.5 port --- build.gradle | 5 +- docs/UPDATE_INSTRUCTIONS.md | 13 +- gradle.properties | 12 +- .../viafabricplus/ViaFabricPlus.java | 15 ++ .../viafabricplus/fixes/ClientsideFixes.java | 7 +- .../fixes/data/EntityDimensionDiff.java | 2 +- .../fixes/data/ItemRegistryDiff.java | 2 +- .../data/recipe/AddBannerPatternRecipe.java | 31 ++-- .../data/recipe/BannerPattern_1_13_2.java | 101 ++++++------- .../visual/EntityRidingOffsetsPre1_20_2.java | 36 ++--- .../visual/FootStepParticle1_12_2.java | 8 +- ...ava => IMultiValueDebugSampleLogImpl.java} | 2 +- .../base/connect/MixinClientConnection.java | 18 +-- ...ltiplayerServerListWidget_ServerEntry.java | 33 ++--- ...=> MixinMultiValueDebugSampleLogImpl.java} | 8 +- .../MixinMultiplayerServerListPinger.java | 13 +- .../classic4j/MixinTextFieldWidget.java | 10 +- ...ixinAutoRefillHandler_ItemSlotMonitor.java | 1 + .../minecraft/MixinEnchantmentHelper.java | 50 ------- .../fixes/minecraft/MixinFontStorage.java | 11 +- .../fixes/minecraft/MixinGameRenderer.java | 2 +- .../block/MixinAbstractSignBlock.java | 10 +- .../block/MixinDecoratedPotBlock.java | 9 +- .../minecraft/block/MixinFenceBlock.java | 10 +- .../fixes/minecraft/block/MixinNoteBlock.java | 8 +- .../minecraft/entity/MixinBoatEntity.java | 2 +- .../fixes/minecraft/entity/MixinEntity.java | 20 +-- .../minecraft/entity/MixinLivingEntity.java | 28 +--- .../minecraft/entity/MixinPlayerEntity.java | 38 ++--- .../minecraft/entity/MixinWolfEntity.java | 11 +- .../fixes/minecraft/item/MixinArmorItem.java | 17 ++- .../minecraft/item/MixinArmorMaterials.java | 54 ------- .../fixes/minecraft/item/MixinAxeItem.java | 84 ----------- .../fixes/minecraft/item/MixinBrushItem.java | 8 +- .../minecraft/item/MixinDrawContext.java | 51 ------- .../fixes/minecraft/item/MixinHoeItem.java | 79 ---------- .../mixin/fixes/minecraft/item/MixinItem.java | 75 ---------- .../fixes/minecraft/item/MixinItemStack.java | 85 ----------- .../minecraft/item/MixinMiningToolItem.java | 100 ------------- .../minecraft/item/MixinPickaxeItem.java | 91 ------------ .../fixes/minecraft/item/MixinShearsItem.java | 61 -------- .../fixes/minecraft/item/MixinShovelItem.java | 82 ----------- .../fixes/minecraft/item/MixinSwordItem.java | 135 ------------------ .../MixinClientCommonNetworkHandler.java | 9 +- .../MixinClientPlayNetworkHandler.java | 7 +- .../MixinClientPlayerInteractionManager.java | 2 +- .../network/MixinCustomPayloadS2CPacket.java | 88 ------------ .../minecraft/network/MixinPacketByteBuf.java | 62 -------- .../screen/MixinMouseOptionsScreen.java | 10 +- .../minecraft/screen/MixinOptionsScreen.java | 49 ------- .../fixes/minecraft/screen/MixinScreen.java | 4 +- .../minecraft/screen/hud/MixinChatHud.java | 2 +- .../minecraft/screen/hud/MixinInGameHud.java | 106 -------------- .../MixinMerchantScreenHandler.java | 20 +-- .../viaversion/MixinInventoryPackets.java | 5 +- .../viaversion/MixinProtocolVersion.java | 1 - .../ProtocolTranslator.java | 4 +- .../ViaFabricPlusTransferProvider.java | 35 +---- .../netty/ViaFabricPlusVLLegacyPipeline.java | 2 +- .../translator/ItemTranslator.java | 19 +-- .../screen/classic4j/BetaCraftScreen.java | 4 +- .../classic4j/ClassiCubeServerListScreen.java | 5 +- .../screen/settings/SettingsScreen.java | 2 +- .../settings/impl/BedrockSettings.java | 1 - .../settings/impl/VisualSettings.java | 1 - .../assets/viafabricplus/lang/de_de.json | 2 - .../assets/viafabricplus/lang/en_us.json | 2 - .../assets/viafabricplus/lang/es_ar.json | 2 - .../assets/viafabricplus/lang/es_cl.json | 2 - .../assets/viafabricplus/lang/es_ec.json | 2 - .../assets/viafabricplus/lang/es_es.json | 2 - .../assets/viafabricplus/lang/es_mx.json | 2 - .../assets/viafabricplus/lang/es_uy.json | 2 - .../assets/viafabricplus/lang/es_ve.json | 2 - .../assets/viafabricplus/lang/hu_hu.json | 2 - .../assets/viafabricplus/lang/pl_pl.json | 2 - .../assets/viafabricplus/lang/ru_ru.json | 2 - .../assets/viafabricplus/lang/uk_ua.json | 1 - .../assets/viafabricplus/lang/zh_cn.json | 2 - .../assets/viafabricplus/lang/zh_hk.json | 2 - .../assets/viafabricplus/lang/zh_tw.json | 2 - src/main/resources/viafabricplus.mixins.json | 18 +-- 82 files changed, 291 insertions(+), 1634 deletions(-) rename src/main/java/de/florianmichael/viafabricplus/injection/access/{IPerformanceLog.java => IMultiValueDebugSampleLogImpl.java} (95%) rename src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/perserverversion/{MixinPerformanceLog.java => MixinMultiValueDebugSampleLogImpl.java} (83%) delete mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinEnchantmentHelper.java delete mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinArmorMaterials.java delete mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinAxeItem.java delete mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinDrawContext.java delete mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHoeItem.java delete mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItem.java delete mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemStack.java delete mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinMiningToolItem.java delete mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinPickaxeItem.java delete mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShearsItem.java delete mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShovelItem.java delete mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinSwordItem.java delete mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinCustomPayloadS2CPacket.java delete mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinPacketByteBuf.java delete mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinOptionsScreen.java delete mode 100644 src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/hud/MixinInGameHud.java diff --git a/build.gradle b/build.gradle index 1d2b2c89..4b4ed136 100644 --- a/build.gradle +++ b/build.gradle @@ -20,6 +20,7 @@ configurations { repositories { mavenCentral() + mavenLocal() maven { name = "Jitpack" url = "https://jitpack.io" @@ -125,8 +126,8 @@ String latestCommitHash() { java { withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } jar { diff --git a/docs/UPDATE_INSTRUCTIONS.md b/docs/UPDATE_INSTRUCTIONS.md index 0b29a0e9..28ace890 100644 --- a/docs/UPDATE_INSTRUCTIONS.md +++ b/docs/UPDATE_INSTRUCTIONS.md @@ -57,14 +57,15 @@ ViaFabricPlus uses Gradle, to make sure that it is installed properly you can ch => If you are unsure if a change is relevant, ask in the ViaVersion discord, in general you should only implement changes which could be detected by a server side anti cheat. -7. Check the ViaVersion/upstream protocol implementation for issues and report them if necessary or if these issues can't be fixed, +7. Update protocol constants in the `ItemTranslator` class +8. Check the ViaVersion/upstream protocol implementation for issues and report them if necessary or if these issues can't be fixed, without tons of work, implement a workaround in ViaFabricPlus. -8. Run the game and check all GUIs and other visuals for issues. -9. Clean your code and make sure it is readable and understandable, clientside fixes are sorted by their protocol versions, having +9. Run the game and check all GUIs and other visuals for issues. +10. Clean your code and make sure it is readable and understandable, clientside fixes are sorted by their protocol versions, having newer fixes at the top of the file. -10. Increment the version number in `gradle.properties` by at least a minor version (e.g. 1.0.0 -> 1.1.0) -11. Create a pull request and wait for it to be reviewed and merged. -12. You're done, congrats! +11. Increment the version number in `gradle.properties` by at least a minor version (e.g. 1.0.0 -> 1.1.0) +12. Create a pull request and wait for it to be reviewed and merged. +13. You're done, congrats! ## Git branches - `main`: The main branch, this is where all changes are merged into diff --git a/gradle.properties b/gradle.properties index 23fa27d9..35672807 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,18 +3,18 @@ org.gradle.jvmargs=-Xmx8G org.gradle.parallel=true # Minecraft/Fabric -minecraft_version=1.20.4 -yarn_mappings=1.20.4+build.3 -loader_version=0.15.7 -fabric_api_version=0.96.11+1.20.4 +minecraft_version=1.20.5-pre4 +yarn_mappings=1.20.5-pre4+build.1 +loader_version=0.15.10 +fabric_api_version=0.97.3+1.20.5 # Project Details -mod_version=3.1.1-SNAPSHOT +mod_version=3.2.0-SNAPSHOT maven_group=de.florianmichael archives_base_name=ViaFabricPlus # ViaVersion Libraries -viaversion_version=4.10.0-24w09a-SNAPSHOT +viaversion_version=4.10.0-1.20.5-pre4-SNAPSHOT viabackwards_version=4.10.0-24w09a-SNAPSHOT vialegacy_version=2.2.22-SNAPSHOT viaaprilfools_version=2.0.11-SNAPSHOT diff --git a/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java b/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java index 4f95409f..49541b6f 100644 --- a/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java +++ b/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java @@ -46,6 +46,21 @@ import java.util.concurrent.CompletableFuture; * - Collision hit boxes has been changed (https://github.com/ViaVersion/ViaFabricPlus/issues/195) * - Blip-jumping is not supported in <= 1.13.2 (https://github.com/ViaVersion/ViaFabricPlus/issues/225) * - Older versions don't clamp positions when teleporting (Is this important?) + * + * TODO | Port + * - Readd MixinCustomPayloadS2CPacket, MixinInGameHud + * - All Update todos + * - Test 1.11.2 banner recipe + * - Test 1.20.1 riding offsets + * - Fix on protocol level: modify1_7StepHeight, modifyReachDistance + * - EntityDimensionDiff: Add eye height and attachment point + * - Test bedrock transfer + * - Readd item fixes on protocol level: MixinAxeItem, MixinHoeItem, MixinPickaxeItem, MixinShearsItem, MixinShovelItem, MixinSwordItem, MixinMiningToolItem, MixinItem + * - Readd item fixes: ArmorMaterials, MixinItemStack, MixinDrawContext, MixinPacketByteBuf + * - Test villager trading in 1.8/1.12.2 + * - Test 1.8 triple chest + * - Figure out how to fix 32k enchantments with codecs (MixinEnchantmentHelper) + * - Test sign interactions */ public class ViaFabricPlus { diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java b/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java index d67c09c7..2a05c685 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java @@ -37,6 +37,7 @@ import net.minecraft.client.font.FontStorage; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.ServerAddress; import net.minecraft.network.PacketByteBuf; +import net.minecraft.network.RegistryByteBuf; import net.minecraft.registry.Registries; import net.raphimc.viabedrock.api.BedrockProtocolVersion; import net.raphimc.viabedrock.protocol.data.ProtocolConstants; @@ -58,7 +59,7 @@ public class ClientsideFixes { /** * Contains all tasks that are waiting for a packet to be received, this system can be used to sync ViaVersion tasks with the correct thread */ - private static final Map> PENDING_EXECUTION_TASKS = new ConcurrentHashMap<>(); + private static final Map> PENDING_EXECUTION_TASKS = new ConcurrentHashMap<>(); /** * This identifier is an internal identifier that is used to identify packets that are sent by ViaFabricPlus @@ -167,7 +168,7 @@ public class ClientsideFixes { * @param task The task to execute * @return The uuid of the task */ - public static String executeSyncTask(final Consumer task) { + public static String executeSyncTask(final Consumer task) { final String uuid = UUID.randomUUID().toString(); PENDING_EXECUTION_TASKS.put(uuid, task); return uuid; @@ -179,7 +180,7 @@ public class ClientsideFixes { if (PENDING_EXECUTION_TASKS.containsKey(uuid)) { MinecraftClient.getInstance().execute(() -> { // Execute the task on the main thread final var task = PENDING_EXECUTION_TASKS.remove(uuid); - task.accept(buf); + task.accept(new RegistryByteBuf(buf, MinecraftClient.getInstance().getNetworkHandler().getRegistryManager())); }); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/data/EntityDimensionDiff.java b/src/main/java/de/florianmichael/viafabricplus/fixes/data/EntityDimensionDiff.java index 4401ff19..561d04d4 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/data/EntityDimensionDiff.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/data/EntityDimensionDiff.java @@ -55,7 +55,7 @@ public class EntityDimensionDiff { ), EntityType.ZOMBIE, linkedHashMap( ProtocolVersion.v1_7_6, EntityDimensions.changing(0.6F, 1.8F), - ProtocolVersion.v1_8, EntityDimensions.fixed(EntityType.ZOMBIE.getDimensions().width, EntityType.ZOMBIE.getDimensions().height), + ProtocolVersion.v1_8, EntityDimensions.fixed(EntityType.ZOMBIE.getDimensions().width(), EntityType.ZOMBIE.getDimensions().height()), ProtocolVersion.v1_9, EntityType.ZOMBIE.getDimensions() ), EntityType.CHICKEN, linkedHashMap( diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/data/ItemRegistryDiff.java b/src/main/java/de/florianmichael/viafabricplus/fixes/data/ItemRegistryDiff.java index 4d12e420..e7cdc416 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/data/ItemRegistryDiff.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/data/ItemRegistryDiff.java @@ -604,7 +604,7 @@ public class ItemRegistryDiff { ITEM_DIFF.put(BLUE_ICE, andNewer(v1_13)); ITEM_DIFF.put(CONDUIT, andNewer(v1_13)); ITEM_DIFF.put(TURTLE_HELMET, andNewer(v1_13)); - ITEM_DIFF.put(SCUTE, andNewer(v1_13)); + ITEM_DIFF.put(TURTLE_SCUTE, andNewer(v1_13)); ITEM_DIFF.put(PUFFERFISH_BUCKET, andNewer(v1_13)); ITEM_DIFF.put(SALMON_BUCKET, andNewer(v1_13)); ITEM_DIFF.put(COD_BUCKET, andNewer(v1_13)); diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/AddBannerPatternRecipe.java b/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/AddBannerPatternRecipe.java index 3049ff87..8a4bf0e0 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/AddBannerPatternRecipe.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/AddBannerPatternRecipe.java @@ -21,19 +21,19 @@ package de.florianmichael.viafabricplus.fixes.data.recipe; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; -import net.minecraft.block.entity.BannerBlockEntity; +import net.minecraft.component.DataComponentTypes; +import net.minecraft.component.type.BannerPatternsComponent; import net.minecraft.inventory.RecipeInputInventory; import net.minecraft.item.BannerItem; import net.minecraft.item.DyeItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtList; import net.minecraft.recipe.RecipeSerializer; import net.minecraft.recipe.SpecialCraftingRecipe; import net.minecraft.recipe.SpecialRecipeSerializer; import net.minecraft.recipe.book.CraftingRecipeCategory; -import net.minecraft.registry.DynamicRegistryManager; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.RegistryWrapper; import net.minecraft.util.DyeColor; import net.minecraft.world.World; @@ -53,7 +53,7 @@ public class AddBannerPatternRecipe extends SpecialCraftingRecipe { if (stack.getItem() instanceof BannerItem) { if (foundBanner) return false; - if (BannerBlockEntity.getPatternCount(stack) >= 6) + if (stack.getOrDefault(DataComponentTypes.BANNER_PATTERNS, BannerPatternsComponent.DEFAULT).layers().size() >= 6) return false; foundBanner = true; } @@ -62,7 +62,7 @@ public class AddBannerPatternRecipe extends SpecialCraftingRecipe { } @Override - public ItemStack craft(RecipeInputInventory inv, DynamicRegistryManager registryManager) { + public ItemStack craft(RecipeInputInventory inv, RegistryWrapper.WrapperLookup lookup) { ItemStack result = ItemStack.EMPTY; for (int i = 0; i < inv.size(); i++) { @@ -74,8 +74,9 @@ public class AddBannerPatternRecipe extends SpecialCraftingRecipe { } } - BannerPattern_1_13_2 pattern = getBannerPattern(inv); + final BannerPattern_1_13_2 pattern = getBannerPattern(inv); if (pattern != null) { + final var patternKey = lookup.getWrapperOrThrow(RegistryKeys.BANNER_PATTERN).getOrThrow(pattern.getKey()); DyeColor color = ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2) ? DyeColor.BLACK : DyeColor.WHITE; for (int i = 0; i < inv.size(); i++) { Item item = inv.getStack(i).getItem(); @@ -84,18 +85,12 @@ public class AddBannerPatternRecipe extends SpecialCraftingRecipe { } } - NbtCompound tileEntityNbt = result.getOrCreateSubNbt("BlockEntityTag"); - NbtList patterns; - if (tileEntityNbt.contains("Patterns", 9)) { - patterns = tileEntityNbt.getList("Patterns", 10); - } else { - patterns = new NbtList(); - tileEntityNbt.put("Patterns", patterns); + final BannerPatternsComponent.Builder patternsBuilder = new BannerPatternsComponent.Builder(); + if (result.contains(DataComponentTypes.BANNER_PATTERNS)) { + patternsBuilder.addAll(result.get(DataComponentTypes.BANNER_PATTERNS)); } - NbtCompound patternNbt = new NbtCompound(); - patternNbt.putString("Pattern", pattern.getId()); - patternNbt.putInt("Color", color.getId()); - patterns.add(patternNbt); + patternsBuilder.add(new BannerPatternsComponent.Layer(patternKey, color)); + result.set(DataComponentTypes.BANNER_PATTERNS, patternsBuilder.build()); } return result; diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/BannerPattern_1_13_2.java b/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/BannerPattern_1_13_2.java index daee2f30..f1504247 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/BannerPattern_1_13_2.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/BannerPattern_1_13_2.java @@ -20,76 +20,79 @@ package de.florianmichael.viafabricplus.fixes.data.recipe; import net.minecraft.block.Blocks; +import net.minecraft.block.entity.BannerPattern; +import net.minecraft.block.entity.BannerPatterns; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.registry.RegistryKey; public enum BannerPattern_1_13_2 { - BASE("b"), - SQUARE_BOTTOM_LEFT("bl", " ", " ", "# "), - SQUARE_BOTTOM_RIGHT("br", " ", " ", " #"), - SQUARE_TOP_LEFT("tl", "# ", " ", " "), - SQUARE_TOP_RIGHT("tr", " #", " ", " "), - STRIPE_BOTTOM("bs", " ", " ", "###"), - STRIPE_TOP("ts", "###", " ", " "), - STRIPE_LEFT("ls", "# ", "# ", "# "), - STRIPE_RIGHT("rs", " #", " #", " #"), - STRIPE_CENTER("cs", " # ", " # ", " # "), - STRIPE_MIDDLE("ms", " ", "###", " "), - STRIPE_DOWNRIGHT("drs", "# ", " # ", " #"), - STRIPE_DOWNLEFT("dls", " #", " # ", "# "), - STRIPE_SMALL("ss", "# #", "# #", " "), - CROSS("cr", "# #", " # ", "# #"), - STRAIGHT_CROSS("sc", " # ", "###", " # "), - TRIANGLE_BOTTOM("bt", " ", " # ", "# #"), - TRIANGLE_TOP("tt", "# #", " # ", " "), - TRIANGLES_BOTTOM("bts", " ", "# #", " # "), - TRIANGLES_TOP("tts", " # ", "# #", " "), - DIAGONAL_LEFT("ld", "## ", "# ", " "), - DIAGONAL_RIGHT("rd", " ", " #", " ##"), - DIAGONAL_LEFT_MIRROR("lud", " ", "# ", "## "), - DIAGONAL_RIGHT_MIRROR("rud", " ##", " #", " "), - CIRCLE_MIDDLE("mc", " ", " # ", " "), - RHOMBUS_MIDDLE("mr", " # ", "# #", " # "), - HALF_VERTICAL("vh", "## ", "## ", "## "), - HALF_HORIZONTAL("hh", "###", "###", " "), - HALF_VERTICAL_MIRROR("vhr", " ##", " ##", " ##"), - HALF_HORIZONTAL_MIRROR("hhb", " ", "###", "###"), - BORDER("bo", "###", "# #", "###"), - CURLY_BORDER("cbo", new ItemStack(Blocks.VINE)), - GRADIENT("gra", "# #", " # ", " # "), - GRADIENT_UP("gru", " # ", " # ", "# #"), - BRICKS("bri", new ItemStack(Blocks.BRICKS)), - GLOBE("glb"), - CREEPER("cre", new ItemStack(Items.CREEPER_HEAD)), - SKULL("sku", new ItemStack(Items.WITHER_SKELETON_SKULL)), - FLOWER("flo", new ItemStack(Blocks.OXEYE_DAISY)), - MOJANG("moj", new ItemStack(Items.ENCHANTED_GOLDEN_APPLE)); + BASE(BannerPatterns.BASE), + SQUARE_BOTTOM_LEFT(BannerPatterns.SQUARE_BOTTOM_LEFT, " ", " ", "# "), + SQUARE_BOTTOM_RIGHT(BannerPatterns.SQUARE_BOTTOM_RIGHT, " ", " ", " #"), + SQUARE_TOP_LEFT(BannerPatterns.SQUARE_TOP_LEFT, "# ", " ", " "), + SQUARE_TOP_RIGHT(BannerPatterns.SQUARE_TOP_RIGHT, " #", " ", " "), + STRIPE_BOTTOM(BannerPatterns.STRIPE_BOTTOM, " ", " ", "###"), + STRIPE_TOP(BannerPatterns.STRIPE_TOP, "###", " ", " "), + STRIPE_LEFT(BannerPatterns.STRIPE_LEFT, "# ", "# ", "# "), + STRIPE_RIGHT(BannerPatterns.STRIPE_RIGHT, " #", " #", " #"), + STRIPE_CENTER(BannerPatterns.STRIPE_CENTER, " # ", " # ", " # "), + STRIPE_MIDDLE(BannerPatterns.STRIPE_MIDDLE, " ", "###", " "), + STRIPE_DOWNRIGHT(BannerPatterns.STRIPE_DOWNRIGHT, "# ", " # ", " #"), + STRIPE_DOWNLEFT(BannerPatterns.STRIPE_DOWNLEFT, " #", " # ", "# "), + STRIPE_SMALL(BannerPatterns.SMALL_STRIPES, "# #", "# #", " "), + CROSS(BannerPatterns.CROSS, "# #", " # ", "# #"), + STRAIGHT_CROSS(BannerPatterns.STRAIGHT_CROSS, " # ", "###", " # "), + TRIANGLE_BOTTOM(BannerPatterns.TRIANGLE_BOTTOM, " ", " # ", "# #"), + TRIANGLE_TOP(BannerPatterns.TRIANGLE_TOP, "# #", " # ", " "), + TRIANGLES_BOTTOM(BannerPatterns.TRIANGLES_BOTTOM, " ", "# #", " # "), + TRIANGLES_TOP(BannerPatterns.TRIANGLES_TOP, " # ", "# #", " "), + DIAGONAL_LEFT(BannerPatterns.DIAGONAL_LEFT, "## ", "# ", " "), + DIAGONAL_RIGHT(BannerPatterns.DIAGONAL_RIGHT, " ", " #", " ##"), + DIAGONAL_LEFT_MIRROR(BannerPatterns.DIAGONAL_UP_LEFT, " ", "# ", "## "), + DIAGONAL_RIGHT_MIRROR(BannerPatterns.DIAGONAL_UP_RIGHT, " ##", " #", " "), + CIRCLE_MIDDLE(BannerPatterns.CIRCLE, " ", " # ", " "), + RHOMBUS_MIDDLE(BannerPatterns.RHOMBUS, " # ", "# #", " # "), + HALF_VERTICAL(BannerPatterns.HALF_VERTICAL, "## ", "## ", "## "), + HALF_HORIZONTAL(BannerPatterns.HALF_HORIZONTAL, "###", "###", " "), + HALF_VERTICAL_MIRROR(BannerPatterns.HALF_VERTICAL_RIGHT, " ##", " ##", " ##"), + HALF_HORIZONTAL_MIRROR(BannerPatterns.HALF_HORIZONTAL_BOTTOM, " ", "###", "###"), + BORDER(BannerPatterns.BORDER, "###", "# #", "###"), + CURLY_BORDER(BannerPatterns.CURLY_BORDER, new ItemStack(Blocks.VINE)), + GRADIENT(BannerPatterns.GRADIENT, "# #", " # ", " # "), + GRADIENT_UP(BannerPatterns.GRADIENT_UP, " # ", " # ", "# #"), + BRICKS(BannerPatterns.BRICKS, new ItemStack(Blocks.BRICKS)), + GLOBE(BannerPatterns.GLOBE), + CREEPER(BannerPatterns.CREEPER, new ItemStack(Items.CREEPER_HEAD)), + SKULL(BannerPatterns.SKULL, new ItemStack(Items.WITHER_SKELETON_SKULL)), + FLOWER(BannerPatterns.FLOWER, new ItemStack(Blocks.OXEYE_DAISY)), + MOJANG(BannerPatterns.MOJANG, new ItemStack(Items.ENCHANTED_GOLDEN_APPLE)); - private final String id; + private final RegistryKey pattern; private final String[] recipePattern; private ItemStack baseStack; - BannerPattern_1_13_2(String id) { + BannerPattern_1_13_2(final RegistryKey pattern) { this.recipePattern = new String[3]; this.baseStack = ItemStack.EMPTY; - this.id = id; + this.pattern = pattern; } - BannerPattern_1_13_2(String id, ItemStack baseStack) { - this(id); + BannerPattern_1_13_2(final RegistryKey pattern, final ItemStack baseStack) { + this(pattern); this.baseStack = baseStack; } - BannerPattern_1_13_2(String id, String recipe1, String recipe2, String recipe3) { - this(id); + BannerPattern_1_13_2(final RegistryKey pattern, final String recipe1, final String recipe2, final String recipe3) { + this(pattern); this.recipePattern[0] = recipe1; this.recipePattern[1] = recipe2; this.recipePattern[2] = recipe3; } - public String getId() { - return this.id; + public RegistryKey getKey() { + return this.pattern; } public boolean isCraftable() { diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/EntityRidingOffsetsPre1_20_2.java b/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/EntityRidingOffsetsPre1_20_2.java index b25beea3..9afe4605 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/EntityRidingOffsetsPre1_20_2.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/EntityRidingOffsetsPre1_20_2.java @@ -34,7 +34,7 @@ import net.minecraft.entity.vehicle.AbstractMinecartEntity; import net.minecraft.entity.vehicle.BoatEntity; import net.minecraft.entity.vehicle.ChestBoatEntity; import net.minecraft.util.math.MathHelper; -import org.joml.Vector3f; +import net.minecraft.util.math.Vec3d; /** * Minecraft 1.20.2 changed the calculation of the mounted height offset for all entities, this class contains the old @@ -49,18 +49,18 @@ public class EntityRidingOffsetsPre1_20_2 { * @param passenger The passenger of the entity. * @return The mounted height offset. */ - public static Vector3f getMountedHeightOffset(final Entity entity, final Entity passenger) { - float yOffset = entity.getHeight() * 0.75F; + public static Vec3d getMountedHeightOffset(final Entity entity, final Entity passenger) { + double yOffset = entity.getHeight() * 0.75F; if (entity instanceof BoatEntity boatEntity) { - if (!boatEntity.hasPassenger(passenger)) return new Vector3f(); + if (!boatEntity.hasPassenger(passenger)) return Vec3d.ZERO; if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) { yOffset = -0.3F; - final float xOffset = MathHelper.cos(boatEntity.getYaw() * MathHelper.PI / 180F); - final float zOffset = MathHelper.sin(boatEntity.getYaw() * MathHelper.PI / 180F); + final double xOffset = MathHelper.cos(boatEntity.getYaw() * MathHelper.PI / 180F); + final double zOffset = MathHelper.sin(boatEntity.getYaw() * MathHelper.PI / 180F); - return new Vector3f(0.4F * xOffset, yOffset, 0.4F * zOffset); + return new Vec3d(0.4F * xOffset, yOffset, 0.4F * zOffset); } else { if (boatEntity.isRemoved()) { yOffset = 0.01F; @@ -68,7 +68,7 @@ public class EntityRidingOffsetsPre1_20_2 { yOffset = boatEntity.getVariant() == BoatEntity.Type.BAMBOO ? 0.25F : -0.1F; } - float xOffset = boatEntity instanceof ChestBoatEntity ? 0.15F : 0F; + double xOffset = boatEntity instanceof ChestBoatEntity ? 0.15F : 0F; if (boatEntity.getPassengerList().size() > 1) { final int idx = boatEntity.getPassengerList().indexOf(passenger); if (idx == 0) { @@ -80,34 +80,34 @@ public class EntityRidingOffsetsPre1_20_2 { if (passenger instanceof AnimalEntity) xOffset += 0.2F; } - return new Vector3f(xOffset, yOffset, 0F); + return new Vec3d(xOffset, yOffset, 0F); } } else if (entity instanceof CamelEntity camelEntity) { - if (!camelEntity.hasPassenger(passenger)) return new Vector3f(); + if (!camelEntity.hasPassenger(passenger)) return Vec3d.ZERO; final boolean firstPassenger = camelEntity.getPassengerList().indexOf(passenger) == 0; - yOffset = camelEntity.getDimensions(camelEntity.isSitting() ? EntityPose.SITTING : EntityPose.STANDING).height - (camelEntity.isBaby() ? 0.35F : 0.6F); + yOffset = camelEntity.getDimensions(camelEntity.isSitting() ? EntityPose.SITTING : EntityPose.STANDING).height() - (camelEntity.isBaby() ? 0.35F : 0.6F); if (camelEntity.isRemoved()) { yOffset = 0.01F; } else { - yOffset = (float) camelEntity.getPassengerAttachmentY(firstPassenger, 0F, EntityDimensions.fixed(0F, (0.375F * camelEntity.getScaleFactor()) + yOffset), camelEntity.getScaleFactor()); + yOffset = camelEntity.getPassengerAttachmentY(firstPassenger, 0F, EntityDimensions.fixed(0F, (float) ((0.375F * camelEntity.getScaleFactor()) + yOffset)), camelEntity.getScaleFactor()); } - float zOffset = 0.5F; + double zOffset = 0.5F; if (camelEntity.getPassengerList().size() > 1) { if (!firstPassenger) zOffset = -0.7F; if (passenger instanceof AnimalEntity) zOffset += 0.2F; } - return new Vector3f(0, yOffset, zOffset); + return new Vec3d(0, yOffset, zOffset); } else if (entity instanceof ChickenEntity chickenEntity) { - return new Vector3f(0, (float) (chickenEntity.getBodyY(0.5D) - chickenEntity.getY()), -0.1F); + return new Vec3d(0, chickenEntity.getBodyY(0.5D) - chickenEntity.getY(), -0.1F); } else if (entity instanceof EnderDragonEntity enderDragonEntity) { yOffset = enderDragonEntity.body.getHeight(); } else if (entity instanceof HoglinEntity hoglinEntity) { yOffset = hoglinEntity.getHeight() - (hoglinEntity.isBaby() ? 0.2F : 0.15F); } else if (entity instanceof LlamaEntity) { - return new Vector3f(0, entity.getHeight() * 0.6F, -0.3F); + return new Vec3d(0, entity.getHeight() * 0.6F, -0.3F); } else if (entity instanceof PhantomEntity) { yOffset = entity.getStandingEyeHeight(); } else if (entity instanceof PiglinEntity) { @@ -134,11 +134,11 @@ public class EntityRidingOffsetsPre1_20_2 { if (entity instanceof AbstractHorseEntity abstractHorseEntity) { if (abstractHorseEntity.lastAngryAnimationProgress > 0.0F) { - return new Vector3f(0, yOffset + 0.15F * abstractHorseEntity.lastAngryAnimationProgress, -0.7F * abstractHorseEntity.lastAngryAnimationProgress); + return new Vec3d(0, yOffset + 0.15F * abstractHorseEntity.lastAngryAnimationProgress, -0.7F * abstractHorseEntity.lastAngryAnimationProgress); } } - return new Vector3f(0, yOffset, 0); + return new Vec3d(0, yOffset, 0); } /** diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/FootStepParticle1_12_2.java b/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/FootStepParticle1_12_2.java index 28080eff..363de87c 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/FootStepParticle1_12_2.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/visual/FootStepParticle1_12_2.java @@ -27,7 +27,7 @@ import net.minecraft.client.particle.*; import net.minecraft.client.render.Camera; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.world.ClientWorld; -import net.minecraft.particle.DefaultParticleType; +import net.minecraft.particle.SimpleParticleType; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.util.Identifier; @@ -78,7 +78,7 @@ public class FootStepParticle1_12_2 extends SpriteBillboardParticle { } public static void init() { - final DefaultParticleType footStepType = FabricParticleTypes.simple(true); + final SimpleParticleType footStepType = FabricParticleTypes.simple(true); Registry.register(Registries.PARTICLE_TYPE, new Identifier("viafabricplus", "footstep"), footStepType); ParticleFactoryRegistry.getInstance().register(footStepType, FootStepParticle1_12_2.Factory::new); @@ -86,7 +86,7 @@ public class FootStepParticle1_12_2 extends SpriteBillboardParticle { ID = Registries.PARTICLE_TYPE.getRawId(footStepType); } - public static class Factory implements ParticleFactory { + public static class Factory implements ParticleFactory { private final SpriteProvider spriteProvider; @@ -95,7 +95,7 @@ public class FootStepParticle1_12_2 extends SpriteBillboardParticle { } @Override - public Particle createParticle(DefaultParticleType parameters, ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ) { + public Particle createParticle(SimpleParticleType parameters, ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ) { if (ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_12_2)) { throw new UnsupportedOperationException("FootStepParticle is not supported on versions newer than 1.12.2"); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/access/IPerformanceLog.java b/src/main/java/de/florianmichael/viafabricplus/injection/access/IMultiValueDebugSampleLogImpl.java similarity index 95% rename from src/main/java/de/florianmichael/viafabricplus/injection/access/IPerformanceLog.java rename to src/main/java/de/florianmichael/viafabricplus/injection/access/IMultiValueDebugSampleLogImpl.java index 474b5bbf..67b03d67 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/access/IPerformanceLog.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/access/IMultiValueDebugSampleLogImpl.java @@ -21,7 +21,7 @@ package de.florianmichael.viafabricplus.injection.access; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -public interface IPerformanceLog { +public interface IMultiValueDebugSampleLogImpl { ProtocolVersion viaFabricPlus$getForcedVersion(); void viaFabricPlus$setForcedVersion(final ProtocolVersion version); diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/connect/MixinClientConnection.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/connect/MixinClientConnection.java index 612a0eb1..59d6a1d7 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/connect/MixinClientConnection.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/connect/MixinClientConnection.java @@ -26,7 +26,7 @@ import com.llamalad7.mixinextras.sugar.Local; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.injection.access.IClientConnection; -import de.florianmichael.viafabricplus.injection.access.IPerformanceLog; +import de.florianmichael.viafabricplus.injection.access.IMultiValueDebugSampleLogImpl; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import de.florianmichael.viafabricplus.protocoltranslator.netty.ViaFabricPlusVLLegacyPipeline; import io.netty.bootstrap.AbstractBootstrap; @@ -39,7 +39,7 @@ import net.minecraft.network.ClientConnection; import net.minecraft.network.encryption.PacketDecryptor; import net.minecraft.network.encryption.PacketEncryptor; import net.minecraft.network.packet.Packet; -import net.minecraft.util.profiler.PerformanceLog; +import net.minecraft.util.profiler.MultiValueDebugSampleLogImpl; import net.raphimc.viabedrock.api.BedrockProtocolVersion; import net.raphimc.vialegacy.api.LegacyProtocolVersion; import net.raphimc.vialoader.netty.CompressionReorderEvent; @@ -122,18 +122,18 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler< return !BedrockProtocolVersion.bedrockLatest.equals(this.viaFabricPlus$serverVersion); } - @Inject(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/util/profiler/PerformanceLog;)Lnet/minecraft/network/ClientConnection;", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", shift = At.Shift.BEFORE)) - private static void setTargetVersion(InetSocketAddress address, boolean useEpoll, PerformanceLog packetSizeLog, CallbackInfoReturnable cir, @Local ClientConnection clientConnection) { + @Inject(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/util/profiler/MultiValueDebugSampleLogImpl;)Lnet/minecraft/network/ClientConnection;", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", shift = At.Shift.BEFORE)) + private static void setTargetVersion(InetSocketAddress address, boolean useEpoll, MultiValueDebugSampleLogImpl packetSizeLog, CallbackInfoReturnable cir, @Local ClientConnection clientConnection) { // Set the target version stored in the PerformanceLog field to the ClientConnection instance - if (packetSizeLog instanceof IPerformanceLog mixinPerformanceLog && mixinPerformanceLog.viaFabricPlus$getForcedVersion() != null) { - ((IClientConnection) clientConnection).viaFabricPlus$setTargetVersion(mixinPerformanceLog.viaFabricPlus$getForcedVersion()); + if (packetSizeLog instanceof IMultiValueDebugSampleLogImpl mixinMultiValueDebugSampleLogImpl && mixinMultiValueDebugSampleLogImpl.viaFabricPlus$getForcedVersion() != null) { + ((IClientConnection) clientConnection).viaFabricPlus$setTargetVersion(mixinMultiValueDebugSampleLogImpl.viaFabricPlus$getForcedVersion()); } } - @WrapWithCondition(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/util/profiler/PerformanceLog;)Lnet/minecraft/network/ClientConnection;", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;resetPacketSizeLog(Lnet/minecraft/util/profiler/PerformanceLog;)V")) - private static boolean dontSetPerformanceLog(ClientConnection instance, PerformanceLog log) { + @WrapWithCondition(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/util/profiler/MultiValueDebugSampleLogImpl;)Lnet/minecraft/network/ClientConnection;", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;resetPacketSizeLog(Lnet/minecraft/util/profiler/MultiValueDebugSampleLogImpl;)V")) + private static boolean dontSetPerformanceLog(ClientConnection instance, MultiValueDebugSampleLogImpl packetSizeLog) { // We need to restore vanilla behaviour since we use the PerformanceLog as a way to store the target version - return !(log instanceof IPerformanceLog mixinPerformanceLog) || mixinPerformanceLog.viaFabricPlus$getForcedVersion() == null; + return !(packetSizeLog instanceof IMultiValueDebugSampleLogImpl mixinMultiValueDebugSampleLogImpl) || mixinMultiValueDebugSampleLogImpl.viaFabricPlus$getForcedVersion() == null; } @Inject(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", at = @At("HEAD")) diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinMultiplayerServerListWidget_ServerEntry.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinMultiplayerServerListWidget_ServerEntry.java index 91b70380..4f0d7605 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinMultiplayerServerListWidget_ServerEntry.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinMultiplayerServerListWidget_ServerEntry.java @@ -19,9 +19,8 @@ package de.florianmichael.viafabricplus.injection.mixin.base.integration; +import com.google.common.collect.Lists; import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.injection.access.IServerInfo; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; @@ -53,9 +52,6 @@ public abstract class MixinMultiplayerServerListWidget_ServerEntry { @Final private ServerInfo server; - @Shadow - protected abstract boolean protocolVersionMatches(); - @Mutable @Shadow @Final @@ -76,12 +72,12 @@ public abstract class MixinMultiplayerServerListWidget_ServerEntry { return !viaFabricPlus$disableServerPinging; } - @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerServerListWidget$ServerEntry;protocolVersionMatches()Z")) - private boolean disableServerPinging(MultiplayerServerListWidget.ServerEntry instance) { + @Redirect(method = "render", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ServerInfo$Status;INCOMPATIBLE:Lnet/minecraft/client/network/ServerInfo$Status;")) + private ServerInfo.Status disableServerPinging() { if (viaFabricPlus$disableServerPinging) { - return false; // server version will always been shown (as we don't have a player count anyway) + return this.server.getStatus(); // server version will always be shown (as we don't have a player count anyway) } else { - return protocolVersionMatches(); + return ServerInfo.Status.INCOMPATIBLE; } } @@ -107,9 +103,9 @@ public abstract class MixinMultiplayerServerListWidget_ServerEntry { return !viaFabricPlus$disableServerPinging; // Remove ping bar } - @WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setMultiplayerScreenTooltip(Ljava/util/List;)V", ordinal = 1)) + @WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setTooltip(Ljava/util/List;)V")) private boolean disableServerPinging(MultiplayerScreen instance, List tooltip) { - return !viaFabricPlus$disableServerPinging; // Remove ping bar tooltip + return !viaFabricPlus$disableServerPinging; // Remove player list tooltip } @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/world/WorldIcon;getTextureId()Lnet/minecraft/util/Identifier;")) @@ -121,20 +117,21 @@ public abstract class MixinMultiplayerServerListWidget_ServerEntry { } } - @WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setMultiplayerScreenTooltip(Ljava/util/List;)V", ordinal = 0)) - private void drawTranslatingState(MultiplayerScreen instance, List tooltip, Operation original) { - if (viaFabricPlus$disableServerPinging) { // Remove player list tooltip + @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setTooltip(Lnet/minecraft/text/Text;)V")) + private void drawTranslatingState(MultiplayerScreen instance, Text text) { + if (viaFabricPlus$disableServerPinging) { // Remove ping bar tooltip return; } - final List tooltipCopy = new ArrayList<>(tooltip); + final List tooltips = new ArrayList<>(); + tooltips.add(text); if (GeneralSettings.global().showAdvertisedServerVersion.getValue()) { final ProtocolVersion version = ((IServerInfo) server).viaFabricPlus$translatingVersion(); if (version != null) { - tooltipCopy.add(Text.translatable("base.viafabricplus.via_translates_to", version.getName() + " (" + version.getOriginalVersion() + ")")); - tooltipCopy.add(Text.translatable("base.viafabricplus.server_version", server.version.getString() + " (" + server.protocolVersion + ")")); + tooltips.add(Text.translatable("base.viafabricplus.via_translates_to", version.getName() + " (" + version.getOriginalVersion() + ")")); + tooltips.add(Text.translatable("base.viafabricplus.server_version", server.version.getString() + " (" + server.protocolVersion + ")")); } } - original.call(instance, tooltipCopy); + instance.setTooltip(Lists.transform(tooltips, Text::asOrderedText)); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/perserverversion/MixinPerformanceLog.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/perserverversion/MixinMultiValueDebugSampleLogImpl.java similarity index 83% rename from src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/perserverversion/MixinPerformanceLog.java rename to src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/perserverversion/MixinMultiValueDebugSampleLogImpl.java index 080302aa..2fefb12b 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/perserverversion/MixinPerformanceLog.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/perserverversion/MixinMultiValueDebugSampleLogImpl.java @@ -20,13 +20,13 @@ package de.florianmichael.viafabricplus.injection.mixin.base.perserverversion; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import de.florianmichael.viafabricplus.injection.access.IPerformanceLog; -import net.minecraft.util.profiler.PerformanceLog; +import de.florianmichael.viafabricplus.injection.access.IMultiValueDebugSampleLogImpl; +import net.minecraft.util.profiler.MultiValueDebugSampleLogImpl; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; -@Mixin(PerformanceLog.class) -public abstract class MixinPerformanceLog implements IPerformanceLog { +@Mixin(MultiValueDebugSampleLogImpl.class) +public abstract class MixinMultiValueDebugSampleLogImpl implements IMultiValueDebugSampleLogImpl { @Unique private ProtocolVersion viaFabricPlus$forcedVersion; diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/perserverversion/MixinMultiplayerServerListPinger.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/perserverversion/MixinMultiplayerServerListPinger.java index 17e811a9..3b051012 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/perserverversion/MixinMultiplayerServerListPinger.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/perserverversion/MixinMultiplayerServerListPinger.java @@ -20,15 +20,14 @@ package de.florianmichael.viafabricplus.injection.mixin.base.perserverversion; import com.llamalad7.mixinextras.sugar.Local; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.fixes.ClientsideFixes; -import de.florianmichael.viafabricplus.injection.access.IPerformanceLog; +import de.florianmichael.viafabricplus.injection.access.IMultiValueDebugSampleLogImpl; import de.florianmichael.viafabricplus.injection.access.IServerInfo; import net.minecraft.client.network.MultiplayerServerListPinger; import net.minecraft.client.network.ServerAddress; import net.minecraft.client.network.ServerInfo; import net.minecraft.network.ClientConnection; -import net.minecraft.util.profiler.PerformanceLog; +import net.minecraft.util.profiler.MultiValueDebugSampleLogImpl; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @@ -44,8 +43,8 @@ public abstract class MixinMultiplayerServerListPinger { return ClientsideFixes.replaceDefaultPort(address, ((IServerInfo) entry).viaFabricPlus$forcedVersion()); } - @Redirect(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/util/profiler/PerformanceLog;)Lnet/minecraft/network/ClientConnection;")) - private ClientConnection setForcedVersion(InetSocketAddress address, boolean useEpoll, PerformanceLog packetSizeLog, @Local(argsOnly = true) ServerInfo serverInfo) { + @Redirect(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/util/profiler/MultiValueDebugSampleLogImpl;)Lnet/minecraft/network/ClientConnection;")) + private ClientConnection setForcedVersion(InetSocketAddress address, boolean useEpoll, MultiValueDebugSampleLogImpl packetSizeLog, @Local(argsOnly = true) ServerInfo serverInfo) { final IServerInfo mixinServerInfo = (IServerInfo) serverInfo; if (mixinServerInfo.viaFabricPlus$forcedVersion() != null && !mixinServerInfo.viaFabricPlus$passedDirectConnectScreen()) { @@ -53,11 +52,11 @@ public abstract class MixinMultiplayerServerListPinger { // So we can create a dummy instance, store the forced version in it and later destroy the instance again // To avoid any side effects, we also support cases where a mod is also creating a PerformanceLog instance if (packetSizeLog == null) { - packetSizeLog = new PerformanceLog(); + packetSizeLog = new MultiValueDebugSampleLogImpl(1); } // Attach the forced version to the PerformanceLog instance - ((IPerformanceLog) packetSizeLog).viaFabricPlus$setForcedVersion(mixinServerInfo.viaFabricPlus$forcedVersion()); + ((IMultiValueDebugSampleLogImpl) packetSizeLog).viaFabricPlus$setForcedVersion(mixinServerInfo.viaFabricPlus$forcedVersion()); mixinServerInfo.viaFabricPlus$passDirectConnectScreen(false); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/compat/classic4j/MixinTextFieldWidget.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/compat/classic4j/MixinTextFieldWidget.java index 98105385..083164ac 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/compat/classic4j/MixinTextFieldWidget.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/compat/classic4j/MixinTextFieldWidget.java @@ -20,8 +20,8 @@ package de.florianmichael.viafabricplus.injection.mixin.compat.classic4j; import de.florianmichael.viafabricplus.injection.access.ITextFieldWidget; -import net.minecraft.SharedConstants; import net.minecraft.client.gui.widget.TextFieldWidget; +import net.minecraft.util.StringHelper; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -37,17 +37,17 @@ public abstract class MixinTextFieldWidget implements ITextFieldWidget { @Unique private boolean viaFabricPlus$forbiddenCharactersUnlocked = false; - @Redirect(method = "charTyped", at = @At(value = "INVOKE", target = "Lnet/minecraft/SharedConstants;isValidChar(C)Z")) + @Redirect(method = "charTyped", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/StringHelper;isValidChar(C)Z")) private boolean allowForbiddenCharacters(char c) { - return this.viaFabricPlus$forbiddenCharactersUnlocked || SharedConstants.isValidChar(c); + return this.viaFabricPlus$forbiddenCharactersUnlocked || StringHelper.isValidChar(c); } - @Redirect(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/SharedConstants;stripInvalidChars(Ljava/lang/String;)Ljava/lang/String;")) + @Redirect(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/StringHelper;stripInvalidChars(Ljava/lang/String;)Ljava/lang/String;")) private String allowForbiddenCharacters(String string) { if (this.viaFabricPlus$forbiddenCharactersUnlocked) { return string; } else { - return SharedConstants.stripInvalidChars(string); + return StringHelper.stripInvalidChars(string); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/compat/ipnext/MixinAutoRefillHandler_ItemSlotMonitor.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/compat/ipnext/MixinAutoRefillHandler_ItemSlotMonitor.java index 767580e2..6b1c986f 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/compat/ipnext/MixinAutoRefillHandler_ItemSlotMonitor.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/compat/ipnext/MixinAutoRefillHandler_ItemSlotMonitor.java @@ -34,6 +34,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; * * Fixes https://github.com/ViaVersion/ViaFabricPlus/issues/209 */ +@SuppressWarnings("UnresolvedMixinReference") @Pseudo @Mixin(targets = "org.anti_ad.mc.ipnext.event.AutoRefillHandler$ItemSlotMonitor", remap = false) public abstract class MixinAutoRefillHandler_ItemSlotMonitor { diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinEnchantmentHelper.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinEnchantmentHelper.java deleted file mode 100644 index 4296f32d..00000000 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinEnchantmentHelper.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus - * Copyright (C) 2021-2024 FlorianMichael/EnZaXD and RK_01/RaphiMC - * Copyright (C) 2023-2024 contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft; - -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; -import net.minecraft.enchantment.EnchantmentHelper; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.Constant; -import org.spongepowered.asm.mixin.injection.ModifyConstant; - -@Mixin(EnchantmentHelper.class) -public abstract class MixinEnchantmentHelper { - - @ModifyConstant(method = "getLevelFromNbt", constant = @Constant(intValue = 0)) - private static int usePossibleMinLevel(int constant) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) { - return Short.MIN_VALUE; - } else { - return constant; - } - } - - @ModifyConstant(method = "getLevelFromNbt", constant = @Constant(intValue = 255)) - private static int usePossibleMaxLevel(int constant) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) { - return Short.MAX_VALUE; - } else { - return constant; - } - } - -} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinFontStorage.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinFontStorage.java index 8f57c3ea..f578864e 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinFontStorage.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinFontStorage.java @@ -19,7 +19,6 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft; -import com.llamalad7.mixinextras.sugar.Local; import de.florianmichael.viafabricplus.fixes.data.RenderableGlyphDiff; import de.florianmichael.viafabricplus.fixes.versioned.visual.BuiltinEmptyGlyph1_12_2; import de.florianmichael.viafabricplus.settings.impl.VisualSettings; @@ -36,8 +35,6 @@ import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.util.List; - @Mixin(FontStorage.class) public abstract class MixinFontStorage { @@ -54,20 +51,20 @@ public abstract class MixinFontStorage { @Unique private GlyphRenderer viaFabricPlus$blankGlyphRenderer1_12_2; - @Inject(method = "setFonts", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/BuiltinEmptyGlyph;bake(Ljava/util/function/Function;)Lnet/minecraft/client/font/GlyphRenderer;", ordinal = 0)) - private void bakeBlankGlyph1_12_2(List fonts, CallbackInfo ci) { + @Inject(method = "clear", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/BuiltinEmptyGlyph;bake(Ljava/util/function/Function;)Lnet/minecraft/client/font/GlyphRenderer;", ordinal = 0)) + private void bakeBlankGlyph1_12_2(CallbackInfo ci) { this.viaFabricPlus$blankGlyphRenderer1_12_2 = BuiltinEmptyGlyph1_12_2.INSTANCE.bake(this::getGlyphRenderer); } @Inject(method = "findGlyph", at = @At("RETURN"), cancellable = true) - private void filterGlyphs1(int codePoint, CallbackInfoReturnable cir, @Local Font font) { + private void filterGlyphs1(int codePoint, CallbackInfoReturnable cir) { if (this.viaFabricPlus$shouldBeInvisible(codePoint)) { cir.setReturnValue(this.viaFabricPlus$getBlankGlyphPair()); } } @Inject(method = "findGlyphRenderer", at = @At("RETURN"), cancellable = true) - private void filterGlyphs2(int codePoint, CallbackInfoReturnable cir, @Local Font font) { + private void filterGlyphs2(int codePoint, CallbackInfoReturnable cir) { if (this.viaFabricPlus$shouldBeInvisible(codePoint)) { cir.setReturnValue(this.viaFabricPlus$getBlankGlyphRenderer()); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinGameRenderer.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinGameRenderer.java index 54539bf6..a4762f09 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinGameRenderer.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/MixinGameRenderer.java @@ -42,7 +42,7 @@ public abstract class MixinGameRenderer { @Final MinecraftClient client; - @ModifyExpressionValue(method = "updateTargetedEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;raycast(DFZ)Lnet/minecraft/util/hit/HitResult;")) + @ModifyExpressionValue(method = "findCrosshairTarget", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;raycast(DFZ)Lnet/minecraft/util/hit/HitResult;")) private HitResult bedrockReachAroundRaycast(HitResult hitResult) { if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { final Entity entity = this.client.getCameraEntity(); diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAbstractSignBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAbstractSignBlock.java index 4a1a1943..cf4a8a8f 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAbstractSignBlock.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinAbstractSignBlock.java @@ -28,8 +28,8 @@ import net.minecraft.item.DyeItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; +import net.minecraft.util.ItemActionResult; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -41,15 +41,15 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(AbstractSignBlock.class) public abstract class MixinAbstractSignBlock { - @Inject(method = "onUse", at = @At("HEAD"), cancellable = true) - private void changeInteractionCalculation(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { + @Inject(method = "onUseWithItem", at = @At("HEAD"), cancellable = true) + private void changeInteractionCalculation(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { if (!world.isClient) { return; } if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) { // <= 1.14.4 doesn't have any sign interactions. - cir.setReturnValue(ActionResult.SUCCESS); + cir.setReturnValue(ItemActionResult.SUCCESS); } else if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_4)) { // Removes the isWaxed() condition and reverts the interaction changes from 1.19.4 -> 1.20 when signs // got a front and back side. @@ -57,7 +57,7 @@ public abstract class MixinAbstractSignBlock { final Item item = itemStack.getItem(); final boolean isSuccess = (item instanceof DyeItem || itemStack.isOf(Items.GLOW_INK_SAC) || itemStack.isOf(Items.INK_SAC)) && player.canModifyBlocks(); - cir.setReturnValue(isSuccess ? ActionResult.SUCCESS : ActionResult.CONSUME); + cir.setReturnValue(isSuccess ? ItemActionResult.SUCCESS : ItemActionResult.CONSUME); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinDecoratedPotBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinDecoratedPotBlock.java index 5b0a0a20..2d7f613b 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinDecoratedPotBlock.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinDecoratedPotBlock.java @@ -24,8 +24,9 @@ import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import net.minecraft.block.BlockState; import net.minecraft.block.DecoratedPotBlock; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.ActionResult; +import net.minecraft.item.ItemStack; import net.minecraft.util.Hand; +import net.minecraft.util.ItemActionResult; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -37,10 +38,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(DecoratedPotBlock.class) public abstract class MixinDecoratedPotBlock { - @Inject(method = "onUse", at = @At("HEAD"), cancellable = true) - private void alwaysPass(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { + @Inject(method = "onUseWithItem", at = @At("HEAD"), cancellable = true) + private void alwaysPass(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable cir) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20_2)) { - cir.setReturnValue(ActionResult.PASS); + cir.setReturnValue(ItemActionResult.SKIP_DEFAULT_BLOCK_INTERACTION); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinFenceBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinFenceBlock.java index 91616342..adc1ef30 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinFenceBlock.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinFenceBlock.java @@ -22,7 +22,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import net.minecraft.block.*; -import net.minecraft.util.ActionResult; +import net.minecraft.util.ItemActionResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; @@ -51,10 +51,10 @@ public abstract class MixinFenceBlock extends HorizontalConnectingBlock { super(radius1, radius2, boundingHeight1, boundingHeight2, collisionHeight, settings); } - @Inject(method = "onUse", at = @At("HEAD"), cancellable = true) - private void alwaysSuccess(CallbackInfoReturnable cir) { + @Inject(method = "onUseWithItem", at = @At("HEAD"), cancellable = true) + private void alwaysSuccess(CallbackInfoReturnable cir) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_10)) { - cir.setReturnValue(ActionResult.SUCCESS); + cir.setReturnValue(ItemActionResult.SUCCESS); } } @@ -97,7 +97,7 @@ public abstract class MixinFenceBlock extends HorizontalConnectingBlock { final VoxelShape southShape = Block.createCuboidShape(h, (float) 0.0, h, i, height, 16.0); final VoxelShape westShape = Block.createCuboidShape(0.0, (float) 0.0, h, i, height, i); final VoxelShape eastShape = Block.createCuboidShape(h, (float) 0.0, h, 16.0, height, i); - final VoxelShape[] voxelShapes = new VoxelShape[] { + final VoxelShape[] voxelShapes = new VoxelShape[]{ VoxelShapes.empty(), Block.createCuboidShape(f, (float) 0.0, h, g, height, 16.0D), Block.createCuboidShape(0.0D, (float) 0.0, f, i, height, g), diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinNoteBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinNoteBlock.java index f19a69b2..381229a9 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinNoteBlock.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinNoteBlock.java @@ -22,7 +22,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import net.minecraft.block.NoteBlock; -import net.minecraft.util.ActionResult; +import net.minecraft.util.ItemActionResult; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -31,10 +31,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(NoteBlock.class) public abstract class MixinNoteBlock { - @Inject(method = "onUse", at = @At("HEAD"), cancellable = true) - private void cancelMobHeadUsage(CallbackInfoReturnable cir) { + @Inject(method = "onUseWithItem", at = @At("HEAD"), cancellable = true) + private void cancelMobHeadUsage(CallbackInfoReturnable cir) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_4)) { - cir.setReturnValue(ActionResult.SUCCESS); + cir.setReturnValue(ItemActionResult.SUCCESS); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinBoatEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinBoatEntity.java index 33c6efa2..24a591f9 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinBoatEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinBoatEntity.java @@ -291,7 +291,7 @@ public abstract class MixinBoatEntity extends VehicleEntity { @Inject(method = "updatePassengerPosition", at = @At(value = "HEAD"), cancellable = true) private void updatePassengerPosition1_8(Entity passenger, PositionUpdater positionUpdater, CallbackInfo ci) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) { - final Vec3d newPosition = new Vec3d(EntityRidingOffsetsPre1_20_2.getMountedHeightOffset(this, passenger)).add(this.getPos()); + final Vec3d newPosition = EntityRidingOffsetsPre1_20_2.getMountedHeightOffset(this, passenger).add(this.getPos()); positionUpdater.accept(passenger, newPosition.x, newPosition.y + EntityRidingOffsetsPre1_20_2.getHeightOffset(passenger), newPosition.z); ci.cancel(); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java index 786fc158..161a81f2 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java @@ -39,7 +39,6 @@ import net.minecraft.util.math.Box; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; -import org.joml.Vector3f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -70,22 +69,27 @@ public abstract class MixinEntity implements IEntity { public abstract void setVelocity(Vec3d velocity); @Shadow - protected abstract Vector3f getPassengerAttachmentPos(Entity passenger, EntityDimensions dimensions, float scaleFactor); + protected abstract Vec3d getPassengerAttachmentPos(Entity passenger, EntityDimensions dimensions, float scaleFactor); + + @Shadow + public abstract float getYaw(); @Unique private boolean viaFabricPlus$isInLoadedChunkAndShouldTick; - @Inject(method = "getRidingOffset", at = @At("HEAD"), cancellable = true) - private void getRidingOffset1_20_1(Entity vehicle, CallbackInfoReturnable cir) { + @Redirect(method = "updatePassengerPosition(Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/Entity$PositionUpdater;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getVehicleAttachmentPos(Lnet/minecraft/entity/Entity;)Lnet/minecraft/util/math/Vec3d;")) + private Vec3d use1_20_1RidingOffset(Entity instance, Entity vehicle) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20)) { - cir.setReturnValue((float) EntityRidingOffsetsPre1_20_2.getHeightOffset((Entity) (Object) this)); + return new Vec3d(0, -EntityRidingOffsetsPre1_20_2.getHeightOffset((Entity) (Object) this), 0); + } else { + return instance.getVehicleAttachmentPos(vehicle); } } - @Redirect(method = "getPassengerRidingPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getPassengerAttachmentPos(Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/EntityDimensions;F)Lorg/joml/Vector3f;")) - private Vector3f getPassengerRidingPos1_20_1(Entity instance, Entity passenger, EntityDimensions dimensions, float scaleFactor) { + @Redirect(method = "getPassengerRidingPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getPassengerAttachmentPos(Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/EntityDimensions;F)Lnet/minecraft/util/math/Vec3d;")) + private Vec3d getPassengerRidingPos1_20_1(Entity instance, Entity passenger, EntityDimensions dimensions, float scaleFactor) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20)) { - return EntityRidingOffsetsPre1_20_2.getMountedHeightOffset(instance, passenger); + return EntityRidingOffsetsPre1_20_2.getMountedHeightOffset(instance, passenger).rotateY(-this.getYaw() * (float) (Math.PI / 180)); } else { return getPassengerAttachmentPos(passenger, dimensions, scaleFactor); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java index d15a4329..2a973f84 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java @@ -32,6 +32,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.fluid.Fluid; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.registry.tag.BlockTags; import net.minecraft.registry.tag.FluidTags; import net.minecraft.registry.tag.TagKey; @@ -41,7 +42,6 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.raphimc.viabedrock.api.BedrockProtocolVersion; import net.raphimc.vialegacy.api.LegacyProtocolVersion; -import org.joml.Vector3f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.*; @@ -66,26 +66,19 @@ public abstract class MixinLivingEntity extends Entity { protected abstract boolean canEnterTrapdoor(BlockPos pos, BlockState state); @Shadow - public abstract boolean hasStatusEffect(StatusEffect effect); + private int jumpingCooldown; @Shadow - private int jumpingCooldown; + public abstract boolean hasStatusEffect(RegistryEntry effect); public MixinLivingEntity(EntityType type, World world) { super(type, world); } - @Inject(method = "getRidingOffset", at = @At("HEAD"), cancellable = true) - private void getRidingOffset1_20_1(Entity vehicle, CallbackInfoReturnable cir) { + @Redirect(method = "getPassengerRidingPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getPassengerAttachmentPos(Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/EntityDimensions;F)Lnet/minecraft/util/math/Vec3d;")) + private Vec3d getPassengerRidingPos1_20_1(LivingEntity instance, Entity entity, EntityDimensions entityDimensions, float v) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20)) { - cir.setReturnValue((float) EntityRidingOffsetsPre1_20_2.getHeightOffset(this)); - } - } - - @Redirect(method = "getPassengerRidingPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getPassengerAttachmentPos(Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/EntityDimensions;F)Lorg/joml/Vector3f;")) - private Vector3f getPassengerRidingPos1_20_1(LivingEntity instance, Entity entity, EntityDimensions entityDimensions, float v) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20)) { - return EntityRidingOffsetsPre1_20_2.getMountedHeightOffset(instance, entity); + return EntityRidingOffsetsPre1_20_2.getMountedHeightOffset(instance, entity).rotateY(-this.getYaw() * (float) (Math.PI / 180)); } else { return getPassengerAttachmentPos(entity, entityDimensions, v); } @@ -140,7 +133,7 @@ public abstract class MixinLivingEntity extends Entity { } @Redirect(method = "travel", - slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/entity/effect/StatusEffects;DOLPHINS_GRACE:Lnet/minecraft/entity/effect/StatusEffect;")), + slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/entity/effect/StatusEffects;DOLPHINS_GRACE:Lnet/minecraft/registry/entry/RegistryEntry;")), at = @At(value = "FIELD", target = "Lnet/minecraft/entity/LivingEntity;horizontalCollision:Z", ordinal = 0)) private boolean disableClimbing(LivingEntity instance) { return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_13_2) && instance.horizontalCollision; @@ -210,13 +203,6 @@ public abstract class MixinLivingEntity extends Entity { } } - @Inject(method = "", at = @At("RETURN")) - private void modify1_7StepHeight(EntityType type, World world, CallbackInfo ci) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_7_6)) { - this.setStepHeight(0.5F); - } - } - @Inject(method = "tickMovement", at = @At("HEAD")) private void removeJumpDelay1_0(CallbackInfo ci) { if (ProtocolTranslator.getTargetVersion().olderThan(LegacyProtocolVersion.r1_0_0tor1_0_1)) { diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java index aa6884a2..5a943538 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java @@ -37,6 +37,7 @@ import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ElytraItem; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.sound.SoundEvent; import net.minecraft.util.Hand; import net.minecraft.util.Identifier; @@ -46,11 +47,12 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.*; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@SuppressWarnings("ConstantValue") @Mixin(PlayerEntity.class) public abstract class MixinPlayerEntity extends LivingEntity { @@ -63,10 +65,10 @@ public abstract class MixinPlayerEntity extends LivingEntity { @Shadow @Final - private PlayerInventory inventory; + PlayerInventory inventory; @Unique - private static final EntityDimensions viaFabricPlus$sneaking_dimensions_v1_13_2 = EntityDimensions.changing(0.6F, 1.65F); + private static final EntityDimensions viaFabricPlus$sneaking_dimensions_v1_13_2 = EntityDimensions.changing(0.6F, 1.65F).withEyeHeight(1.54F); @Unique private static final SoundEvent viaFabricPlus$oof_hurt = SoundEvent.of(new Identifier("viafabricplus", "oof.hurt")); @@ -102,9 +104,9 @@ public abstract class MixinPlayerEntity extends LivingEntity { return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_15_2); } - @Redirect(method = "checkFallFlying", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;hasStatusEffect(Lnet/minecraft/entity/effect/StatusEffect;)Z")) - private boolean allowElytraWhenLevitating(PlayerEntity instance, StatusEffect statusEffect) { - return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_15_2) && instance.hasStatusEffect(statusEffect); + @Redirect(method = "checkFallFlying", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;hasStatusEffect(Lnet/minecraft/registry/entry/RegistryEntry;)Z")) + private boolean allowElytraWhenLevitating(PlayerEntity instance, RegistryEntry registryEntry) { + return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_15_2) && instance.hasStatusEffect(registryEntry); } @Inject(method = "checkFallFlying", at = @At("HEAD"), cancellable = true) @@ -121,15 +123,6 @@ public abstract class MixinPlayerEntity extends LivingEntity { } } - @ModifyConstant(method = "getActiveEyeHeight", constant = @Constant(floatValue = 1.27f)) - private float modifySneakEyeHeight(float prevEyeHeight) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) { - return 1.54F; - } else { - return prevEyeHeight; - } - } - @Inject(method = "updatePose", at = @At("HEAD"), cancellable = true) private void onUpdatePose(CallbackInfo ci) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) { @@ -152,7 +145,7 @@ public abstract class MixinPlayerEntity extends LivingEntity { } } - @Inject(method = "getDimensions", at = @At("HEAD"), cancellable = true) + @Inject(method = "getBaseDimensions", at = @At("HEAD"), cancellable = true) private void modifyDimensions(EntityPose pose, CallbackInfoReturnable cir) { if (pose == EntityPose.CROUCHING) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) { @@ -208,8 +201,8 @@ public abstract class MixinPlayerEntity extends LivingEntity { } } - @Redirect(method = "getBlockBreakingSpeed", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;hasStatusEffect(Lnet/minecraft/entity/effect/StatusEffect;)Z")) - private boolean changeSpeedCalculation(PlayerEntity instance, StatusEffect statusEffect, @Local LocalFloatRef f) { + @Redirect(method = "getBlockBreakingSpeed", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;hasStatusEffect(Lnet/minecraft/registry/entry/RegistryEntry;)Z")) + private boolean changeSpeedCalculation(PlayerEntity instance, RegistryEntry statusEffect, @Local LocalFloatRef f) { final boolean hasMiningFatigue = instance.hasStatusEffect(statusEffect); if (hasMiningFatigue && ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_7_6)) { f.set(f.get() * (1.0F - (this.getStatusEffect(StatusEffects.MINING_FATIGUE).getAmplifier() + 1) * 0.2F)); @@ -219,11 +212,4 @@ public abstract class MixinPlayerEntity extends LivingEntity { return hasMiningFatigue; } - @Inject(method = "getReachDistance", at = @At("RETURN"), cancellable = true) - private static void modifyReachDistance(boolean creative, CallbackInfoReturnable cir) { - if (ProtocolTranslator.getTargetVersion().olderThan(LegacyProtocolVersion.r1_0_0tor1_0_1) && !creative) { - cir.setReturnValue(4F); - } - } - } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinWolfEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinWolfEntity.java index e1068f8c..900480e0 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinWolfEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinWolfEntity.java @@ -22,6 +22,8 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.fixes.tracker.WolfHealthTracker; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; +import net.minecraft.component.DataComponentTypes; +import net.minecraft.component.type.FoodComponent; import net.minecraft.entity.EntityType; import net.minecraft.entity.mob.Angerable; import net.minecraft.entity.passive.TameableEntity; @@ -50,7 +52,7 @@ public abstract class MixinWolfEntity extends TameableEntity implements Angerabl public abstract DyeColor getCollarColor(); @Shadow - public abstract void setCollarColor(DyeColor color); + protected abstract void setCollarColor(DyeColor color); protected MixinWolfEntity(EntityType entityType, World world) { super(entityType, world); @@ -62,10 +64,11 @@ public abstract class MixinWolfEntity extends TameableEntity implements Angerabl final ItemStack itemStack = player.getStackInHand(hand); final Item item = itemStack.getItem(); if (this.isTamed()) { - if (item.isFood()) { - if (item.getFoodComponent().isMeat() && this.viaFabricPlus$getWolfHealth() < 20.0F) { + final FoodComponent foodComponent = itemStack.get(DataComponentTypes.FOOD); + if (foodComponent != null) { + if (this.isBreedingItem(itemStack) && this.viaFabricPlus$getWolfHealth() < 20.0F) { if (!player.getAbilities().creativeMode) itemStack.decrement(1); - this.heal((float) item.getFoodComponent().getHunger()); + this.heal(foodComponent.nutrition()); cir.setReturnValue(ActionResult.SUCCESS); return; } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinArmorItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinArmorItem.java index a3fa57c6..530bc578 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinArmorItem.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinArmorItem.java @@ -19,13 +19,10 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.Multimap; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import com.google.common.base.Suppliers; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import de.florianmichael.viafabricplus.settings.impl.DebugSettings; -import net.minecraft.entity.attribute.EntityAttribute; -import net.minecraft.entity.attribute.EntityAttributeModifier; +import net.minecraft.component.type.AttributeModifiersComponent; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ArmorItem; import net.minecraft.item.ItemStack; @@ -43,15 +40,17 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import java.util.function.Supplier; + @Mixin(ArmorItem.class) public abstract class MixinArmorItem { @Shadow @Final - private Multimap attributeModifiers; + private Supplier attributeModifiers; @Unique - private final Multimap viaFabricPlus$AttributeModifiers_r1_8 = ImmutableMultimap.of(); + private final Supplier viaFabricPlus$AttributeModifiers_r1_8 = Suppliers.memoize(() -> AttributeModifiersComponent.DEFAULT); @Inject(method = "use", at = @At("HEAD"), cancellable = true) private void disableRightClick(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable> cir) { @@ -60,8 +59,8 @@ public abstract class MixinArmorItem { } } - @Redirect(method = "getAttributeModifiers", at = @At(value = "FIELD", target = "Lnet/minecraft/item/ArmorItem;attributeModifiers:Lcom/google/common/collect/Multimap;")) - private Multimap changeAttributeModifiers(ArmorItem instance) { + @Redirect(method = "getAttributeModifiers", at = @At(value = "FIELD", target = "Lnet/minecraft/item/ArmorItem;attributeModifiers:Ljava/util/function/Supplier;")) + private Supplier changeAttributeModifiers(ArmorItem instance) { if (DebugSettings.global().replaceAttributeModifiers.isEnabled()) { return this.viaFabricPlus$AttributeModifiers_r1_8; } else { diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinArmorMaterials.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinArmorMaterials.java deleted file mode 100644 index c4336399..00000000 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinArmorMaterials.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus - * Copyright (C) 2021-2024 FlorianMichael/EnZaXD and RK_01/RaphiMC - * Copyright (C) 2023-2024 contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; - -import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; -import net.minecraft.item.ArmorMaterials; -import net.raphimc.vialegacy.api.LegacyProtocolVersion; -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.Redirect; - -@Mixin(ArmorMaterials.class) -public abstract class MixinArmorMaterials { - - @Shadow - @Final - private int durabilityMultiplier; - - @Redirect(method = "getDurability", at = @At(value = "FIELD", target = "Lnet/minecraft/item/ArmorMaterials;durabilityMultiplier:I")) - private int changeDurabilityMultiplier(ArmorMaterials instance) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) { - if (instance == ArmorMaterials.LEATHER) { - return 3; - } else if (instance == ArmorMaterials.CHAIN || instance == ArmorMaterials.GOLD) { - return 6; - } else if (instance == ArmorMaterials.IRON) { - return 12; - } else if (instance == ArmorMaterials.DIAMOND) { - return 24; - } - } - return this.durabilityMultiplier; - } - -} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinAxeItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinAxeItem.java deleted file mode 100644 index a1b72dc7..00000000 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinAxeItem.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus - * Copyright (C) 2021-2024 FlorianMichael/EnZaXD and RK_01/RaphiMC - * Copyright (C) 2023-2024 contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; - -import com.google.common.collect.ImmutableSet; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import de.florianmichael.viafabricplus.fixes.data.Material1_19_4; -import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.item.*; -import net.minecraft.registry.tag.TagKey; -import net.minecraft.util.ActionResult; -import net.raphimc.vialegacy.api.LegacyProtocolVersion; -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.CallbackInfoReturnable; - -import java.util.Set; - -@Mixin(AxeItem.class) -public abstract class MixinAxeItem extends MiningToolItem { - - @Unique - private static final Set viaFabricPlus$effective_blocks_b1_8_1 = ImmutableSet.of(Blocks.OAK_PLANKS, Blocks.BOOKSHELF, Blocks.OAK_LOG, Blocks.CHEST); - - @Unique - private static final Set viaFabricPlus$effective_blocks_r1_16_5 = ImmutableSet.of(Blocks.LADDER, Blocks.SCAFFOLDING, Blocks.OAK_BUTTON, Blocks.SPRUCE_BUTTON, Blocks.BIRCH_BUTTON, Blocks.JUNGLE_BUTTON, Blocks.DARK_OAK_BUTTON, Blocks.ACACIA_BUTTON, Blocks.CRIMSON_BUTTON, Blocks.WARPED_BUTTON); - - @Unique - private static final Set viaFabricPlus$effective_materials_r1_16_5 = ImmutableSet.of(Material1_19_4.WOOD, Material1_19_4.NETHER_WOOD, Material1_19_4.PLANT, Material1_19_4.REPLACEABLE_PLANT, Material1_19_4.BAMBOO, Material1_19_4.GOURD); - - public MixinAxeItem(float attackDamage, float attackSpeed, ToolMaterial material, TagKey effectiveBlocks, Settings settings) { - super(attackDamage, attackSpeed, material, effectiveBlocks, settings); - } - - @Override - public boolean isSuitableFor(BlockState state) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_4)) { - return false; - } else { - return super.isSuitableFor(state); - } - } - - @Inject(method = "useOnBlock", at = @At("HEAD"), cancellable = true) - private void disableUse(ItemUsageContext context, CallbackInfoReturnable cir) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2)) { - cir.setReturnValue(ActionResult.PASS); - } - } - - @Override - public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) { - return viaFabricPlus$effective_blocks_b1_8_1.contains(state.getBlock()) ? this.miningSpeed : 1.0F; - } else if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_4)) { - return viaFabricPlus$effective_materials_r1_16_5.contains(Material1_19_4.getMaterial(state)) ? this.miningSpeed : viaFabricPlus$effective_blocks_r1_16_5.contains(state.getBlock()) ? this.miningSpeed : 1.0F; - } else { - return super.getMiningSpeedMultiplier(stack, state); - } - } - -} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBrushItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBrushItem.java index 76fcf7df..2c8240f9 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBrushItem.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinBrushItem.java @@ -30,12 +30,12 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(BrushItem.class) public abstract class MixinBrushItem { - @Redirect(method = "getHitResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;getReachDistance(Z)F")) - private float modifyReachDistance(boolean creative) { + @Redirect(method = "getHitResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;getBlockInteractionRange()D")) + private double modifyReachDistance(PlayerEntity instance) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20_2)) { - return 5F; + return 5D; } else { - return PlayerEntity.getReachDistance(creative); + return instance.getBlockInteractionRange(); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinDrawContext.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinDrawContext.java deleted file mode 100644 index c2f5869a..00000000 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinDrawContext.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus - * Copyright (C) 2021-2024 FlorianMichael/EnZaXD and RK_01/RaphiMC - * Copyright (C) 2023-2024 contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; - -import de.florianmichael.viafabricplus.injection.access.IItemStack; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Formatting; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(DrawContext.class) -public abstract class MixinDrawContext { - - @Redirect(method = "drawItemInSlot(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getCount()I")) - private int handleNegativeItemCount(ItemStack instance) { - if (((IItemStack) (Object) instance).viaFabricPlus$has1_10Tag()) { - return ((IItemStack) (Object) instance).viaFabricPlus$get1_10Count(); - } else { - return instance.getCount(); - } - } - - @Redirect(method = "drawItemInSlot(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V", at = @At(value = "INVOKE", target = "Ljava/lang/String;valueOf(I)Ljava/lang/String;", remap = false)) - private String makeTextRed(int count) { - if (count <= 0) { - return Formatting.RED.toString() + count; - } else { - return String.valueOf(count); - } - } - -} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHoeItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHoeItem.java deleted file mode 100644 index 816cba0c..00000000 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHoeItem.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus - * Copyright (C) 2021-2024 FlorianMichael/EnZaXD and RK_01/RaphiMC - * Copyright (C) 2023-2024 contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; - -import com.google.common.collect.ImmutableSet; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.item.HoeItem; -import net.minecraft.item.ItemStack; -import net.minecraft.item.MiningToolItem; -import net.minecraft.item.ToolMaterial; -import net.minecraft.registry.tag.TagKey; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; - -import java.util.Set; - -@Mixin(HoeItem.class) -public abstract class MixinHoeItem extends MiningToolItem { - - @Unique - private static final Set viaFabricPlus$effective_blocks_r1_16_5 = ImmutableSet.of( - Blocks.NETHER_WART_BLOCK, - Blocks.WARPED_WART_BLOCK, - Blocks.HAY_BLOCK, - Blocks.DRIED_KELP_BLOCK, - Blocks.TARGET, - Blocks.SHROOMLIGHT, - Blocks.SPONGE, - Blocks.WET_SPONGE, - Blocks.JUNGLE_LEAVES, - Blocks.OAK_LEAVES, - Blocks.SPRUCE_LEAVES, - Blocks.DARK_OAK_LEAVES, - Blocks.ACACIA_LEAVES, - Blocks.BIRCH_LEAVES - ); - - protected MixinHoeItem(float attackDamage, float attackSpeed, ToolMaterial material, TagKey effectiveBlocks, Settings settings) { - super(attackDamage, attackSpeed, material, effectiveBlocks, settings); - } - - @Override - public boolean isSuitableFor(BlockState state) { - return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_16_4) && super.isSuitableFor(state); - } - - @Override - public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_15_2)) { - return 1.0F; - } else if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_4)) { - return viaFabricPlus$effective_blocks_r1_16_5.contains(state.getBlock()) ? this.miningSpeed : 1.0F; - } else { - return super.getMiningSpeedMultiplier(stack, state); - } - } - -} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItem.java deleted file mode 100644 index f8eebad8..00000000 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItem.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus - * Copyright (C) 2021-2024 FlorianMichael/EnZaXD and RK_01/RaphiMC - * Copyright (C) 2023-2024 contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; - -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; -import net.minecraft.item.ArmorItem; -import net.minecraft.item.CrossbowItem; -import net.minecraft.item.Item; -import net.raphimc.vialegacy.api.LegacyProtocolVersion; -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.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(Item.class) -public abstract class MixinItem { - - @Shadow - @Final - private int maxDamage; - - @Shadow - public abstract boolean isFood(); - - @Redirect(method = {"getMaxDamage", "isDamageable", "getItemBarStep", "getItemBarColor"}, at = @At(value = "FIELD", target = "Lnet/minecraft/item/Item;maxDamage:I")) - private int changeCrossbowDamage(Item instance) { - if (instance instanceof ArmorItem armor && ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) { - // Counterpart in MixinArmorMaterials - return armor.getMaterial().getDurability(armor.getType()); - } else if (instance instanceof CrossbowItem && ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_17_1)) { - return 326; - } else { - return maxDamage; - } - } - - @Inject(method = "getMaxCount", at = @At("HEAD"), cancellable = true) - private void dontStackFood(CallbackInfoReturnable cir) { - if (this.isFood() && ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_7tob1_7_3)) { - cir.setReturnValue(1); - } - } - - @ModifyExpressionValue(method = {"use", "finishUsing", "getUseAction", "getMaxUseTime"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;isFood()Z")) - private boolean makeFoodInstantConsumable(boolean original) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_7tob1_7_3)) { - return false; - } else { - return original; - } - } - -} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemStack.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemStack.java deleted file mode 100644 index 7d027ec1..00000000 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinItemStack.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus - * Copyright (C) 2021-2024 FlorianMichael/EnZaXD and RK_01/RaphiMC - * Copyright (C) 2023-2024 contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; - -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import de.florianmichael.viafabricplus.injection.access.IItemStack; -import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; -import net.minecraft.entity.attribute.EntityAttribute; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -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.Redirect; -import org.spongepowered.asm.mixin.injection.Slice; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(value = ItemStack.class, priority = 1) -public abstract class MixinItemStack implements IItemStack { - - @Shadow - public abstract Item getItem(); - - @Unique - private boolean viaFabricPlus$has1_10Tag; - - @Unique - private int viaFabricPlus$1_10Count; - - @Redirect(method = "getTooltip", - slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/entity/attribute/EntityAttributes;GENERIC_ATTACK_DAMAGE:Lnet/minecraft/entity/attribute/EntityAttribute;", ordinal = 0)), - at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;getAttributeBaseValue(Lnet/minecraft/entity/attribute/EntityAttribute;)D", ordinal = 0)) - private double fixDamageCalculation(PlayerEntity player, EntityAttribute attribute) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) { - return 0; - } else { - return player.getAttributeBaseValue(attribute); - } - } - - @Inject(method = "copy", at = @At("RETURN")) - private void copyViaFabricPlusData(CallbackInfoReturnable cir) { - final IItemStack mixinItemStack = (IItemStack) (Object) cir.getReturnValue(); - if (this.viaFabricPlus$has1_10Tag) { - mixinItemStack.viaFabricPlus$set1_10Count(this.viaFabricPlus$1_10Count); - } - } - - @Override - public boolean viaFabricPlus$has1_10Tag() { - return this.viaFabricPlus$has1_10Tag; - } - - @Override - public int viaFabricPlus$get1_10Count() { - return this.viaFabricPlus$1_10Count; - } - - @Override - public void viaFabricPlus$set1_10Count(final int count) { - this.viaFabricPlus$has1_10Tag = true; - this.viaFabricPlus$1_10Count = count; - } - -} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinMiningToolItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinMiningToolItem.java deleted file mode 100644 index 0efa1936..00000000 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinMiningToolItem.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus - * Copyright (C) 2021-2024 FlorianMichael/EnZaXD and RK_01/RaphiMC - * Copyright (C) 2023-2024 contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; - -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.Multimap; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; -import de.florianmichael.viafabricplus.settings.impl.DebugSettings; -import net.minecraft.block.Block; -import net.minecraft.entity.attribute.EntityAttribute; -import net.minecraft.entity.attribute.EntityAttributeModifier; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.item.*; -import net.minecraft.registry.tag.TagKey; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -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.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(MiningToolItem.class) -public abstract class MixinMiningToolItem extends ToolItem { - - @Shadow - @Final - private float attackDamage; - - @Shadow - @Final - private Multimap attributeModifiers; - - @Unique - private float viaFabricPlus$attackDamage_r1_8; - - @Unique - private Multimap viaFabricPlus$AttributeModifiers_r1_8; - - public MixinMiningToolItem(ToolMaterial material, Settings settings) { - super(material, settings); - } - - @Inject(method = "", at = @At("RETURN")) - private void init1_8Fields(float attackDamage, float attackSpeed, ToolMaterial material, TagKey effectiveBlocks, Settings settings, CallbackInfo ci) { - final float materialAttackDamage = material.getAttackDamage(); - if ((Item) this instanceof PickaxeItem) { - this.viaFabricPlus$attackDamage_r1_8 = 2 + materialAttackDamage; - } else if ((Item) this instanceof ShovelItem) { - this.viaFabricPlus$attackDamage_r1_8 = 1 + materialAttackDamage; - } else if ((Item) this instanceof AxeItem) { - this.viaFabricPlus$attackDamage_r1_8 = 3 + materialAttackDamage; - } else { // HoeItem didn't use MiningToolItem abstraction in 1.8 - this.viaFabricPlus$AttributeModifiers_r1_8 = ImmutableMultimap.of(); - return; - } - - final ImmutableMultimap.Builder builder = ImmutableMultimap.builder(); - builder.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(ATTACK_DAMAGE_MODIFIER_ID, "Tool modifier", this.viaFabricPlus$attackDamage_r1_8, EntityAttributeModifier.Operation.ADDITION)); - this.viaFabricPlus$AttributeModifiers_r1_8 = builder.build(); - } - - @Redirect(method = "getAttackDamage", at = @At(value = "FIELD", target = "Lnet/minecraft/item/MiningToolItem;attackDamage:F")) - private float changeAttackDamage(MiningToolItem instance) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) { - return this.viaFabricPlus$attackDamage_r1_8; - } else { - return this.attackDamage; - } - } - - @Redirect(method = "getAttributeModifiers", at = @At(value = "FIELD", target = "Lnet/minecraft/item/MiningToolItem;attributeModifiers:Lcom/google/common/collect/Multimap;")) - private Multimap changeAttributeModifiers(MiningToolItem instance) { - if (DebugSettings.global().replaceAttributeModifiers.isEnabled()) { - return this.viaFabricPlus$AttributeModifiers_r1_8; - } else { - return this.attributeModifiers; - } - } - -} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinPickaxeItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinPickaxeItem.java deleted file mode 100644 index 970b68f2..00000000 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinPickaxeItem.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus - * Copyright (C) 2021-2024 FlorianMichael/EnZaXD and RK_01/RaphiMC - * Copyright (C) 2023-2024 contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; - -import com.google.common.collect.ImmutableSet; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import de.florianmichael.viafabricplus.fixes.data.Material1_19_4; -import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; -import net.fabricmc.yarn.constants.MiningLevels; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.item.MiningToolItem; -import net.minecraft.item.PickaxeItem; -import net.minecraft.item.ToolMaterial; -import net.minecraft.registry.tag.TagKey; -import net.raphimc.vialegacy.api.LegacyProtocolVersion; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; - -import java.util.Set; - -@Mixin(PickaxeItem.class) -public abstract class MixinPickaxeItem extends MiningToolItem { - - @Unique - private static final Set viaFabricPlus$effective_blocks_b1_8_1 = ImmutableSet.of(Blocks.COBBLESTONE, Blocks.SMOOTH_STONE_SLAB, Blocks.SANDSTONE_SLAB, Blocks.PETRIFIED_OAK_SLAB, Blocks.COBBLESTONE_SLAB, Blocks.BRICK_SLAB, Blocks.STONE_BRICK_SLAB, Blocks.STONE, Blocks.SANDSTONE, Blocks.MOSSY_COBBLESTONE, Blocks.IRON_ORE, Blocks.IRON_BLOCK, Blocks.COAL_ORE, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.DIAMOND_ORE, Blocks.DIAMOND_BLOCK, Blocks.ICE, Blocks.NETHERRACK, Blocks.LAPIS_ORE, Blocks.LAPIS_BLOCK); - - @Unique - private static final Set viaFabricPlus$effective_blocks_r1_15_2 = ImmutableSet.of(Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.POWERED_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.BLUE_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.CUT_SANDSTONE, Blocks.CHISELED_RED_SANDSTONE, Blocks.CUT_RED_SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.GRANITE, Blocks.POLISHED_GRANITE, Blocks.DIORITE, Blocks.POLISHED_DIORITE, Blocks.ANDESITE, Blocks.POLISHED_ANDESITE, Blocks.STONE_SLAB, Blocks.SMOOTH_STONE_SLAB, Blocks.SANDSTONE_SLAB, Blocks.PETRIFIED_OAK_SLAB, Blocks.COBBLESTONE_SLAB, Blocks.BRICK_SLAB, Blocks.STONE_BRICK_SLAB, Blocks.NETHER_BRICK_SLAB, Blocks.QUARTZ_SLAB, Blocks.RED_SANDSTONE_SLAB, Blocks.PURPUR_SLAB, Blocks.SMOOTH_QUARTZ, Blocks.SMOOTH_RED_SANDSTONE, Blocks.SMOOTH_SANDSTONE, Blocks.SMOOTH_STONE, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE, Blocks.POLISHED_GRANITE_SLAB, Blocks.SMOOTH_RED_SANDSTONE_SLAB, Blocks.MOSSY_STONE_BRICK_SLAB, Blocks.POLISHED_DIORITE_SLAB, Blocks.MOSSY_COBBLESTONE_SLAB, Blocks.END_STONE_BRICK_SLAB, Blocks.SMOOTH_SANDSTONE_SLAB, Blocks.SMOOTH_QUARTZ_SLAB, Blocks.GRANITE_SLAB, Blocks.ANDESITE_SLAB, Blocks.RED_NETHER_BRICK_SLAB, Blocks.POLISHED_ANDESITE_SLAB, Blocks.DIORITE_SLAB, Blocks.SHULKER_BOX, Blocks.BLACK_SHULKER_BOX, Blocks.BLUE_SHULKER_BOX, Blocks.BROWN_SHULKER_BOX, Blocks.CYAN_SHULKER_BOX, Blocks.GRAY_SHULKER_BOX, Blocks.GREEN_SHULKER_BOX, Blocks.LIGHT_BLUE_SHULKER_BOX, Blocks.LIGHT_GRAY_SHULKER_BOX, Blocks.LIME_SHULKER_BOX, Blocks.MAGENTA_SHULKER_BOX, Blocks.ORANGE_SHULKER_BOX, Blocks.PINK_SHULKER_BOX, Blocks.PURPLE_SHULKER_BOX, Blocks.RED_SHULKER_BOX, Blocks.WHITE_SHULKER_BOX, Blocks.YELLOW_SHULKER_BOX); - - @Unique - private static final Set viaFabricPlus$effective_blocks_r1_16_5 = ImmutableSet.of(Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.POWERED_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.NETHER_GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.BLUE_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.CUT_SANDSTONE, Blocks.CHISELED_RED_SANDSTONE, Blocks.CUT_RED_SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.GRANITE, Blocks.POLISHED_GRANITE, Blocks.DIORITE, Blocks.POLISHED_DIORITE, Blocks.ANDESITE, Blocks.POLISHED_ANDESITE, Blocks.STONE_SLAB, Blocks.SMOOTH_STONE_SLAB, Blocks.SANDSTONE_SLAB, Blocks.PETRIFIED_OAK_SLAB, Blocks.COBBLESTONE_SLAB, Blocks.BRICK_SLAB, Blocks.STONE_BRICK_SLAB, Blocks.NETHER_BRICK_SLAB, Blocks.QUARTZ_SLAB, Blocks.RED_SANDSTONE_SLAB, Blocks.PURPUR_SLAB, Blocks.SMOOTH_QUARTZ, Blocks.SMOOTH_RED_SANDSTONE, Blocks.SMOOTH_SANDSTONE, Blocks.SMOOTH_STONE, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE, Blocks.POLISHED_GRANITE_SLAB, Blocks.SMOOTH_RED_SANDSTONE_SLAB, Blocks.MOSSY_STONE_BRICK_SLAB, Blocks.POLISHED_DIORITE_SLAB, Blocks.MOSSY_COBBLESTONE_SLAB, Blocks.END_STONE_BRICK_SLAB, Blocks.SMOOTH_SANDSTONE_SLAB, Blocks.SMOOTH_QUARTZ_SLAB, Blocks.GRANITE_SLAB, Blocks.ANDESITE_SLAB, Blocks.RED_NETHER_BRICK_SLAB, Blocks.POLISHED_ANDESITE_SLAB, Blocks.DIORITE_SLAB, Blocks.SHULKER_BOX, Blocks.BLACK_SHULKER_BOX, Blocks.BLUE_SHULKER_BOX, Blocks.BROWN_SHULKER_BOX, Blocks.CYAN_SHULKER_BOX, Blocks.GRAY_SHULKER_BOX, Blocks.GREEN_SHULKER_BOX, Blocks.LIGHT_BLUE_SHULKER_BOX, Blocks.LIGHT_GRAY_SHULKER_BOX, Blocks.LIME_SHULKER_BOX, Blocks.MAGENTA_SHULKER_BOX, Blocks.ORANGE_SHULKER_BOX, Blocks.PINK_SHULKER_BOX, Blocks.PURPLE_SHULKER_BOX, Blocks.RED_SHULKER_BOX, Blocks.WHITE_SHULKER_BOX, Blocks.YELLOW_SHULKER_BOX, Blocks.PISTON, Blocks.STICKY_PISTON, Blocks.PISTON_HEAD); - - @Unique - private static final Set viaFabricPlus$effective_materials_r1_16_5 = ImmutableSet.of(Material1_19_4.METAL, Material1_19_4.REPAIR_STATION, Material1_19_4.STONE); - - protected MixinPickaxeItem(float attackDamage, float attackSpeed, ToolMaterial material, TagKey effectiveBlocks, Settings settings) { - super(attackDamage, attackSpeed, material, effectiveBlocks, settings); - } - - @Override - public boolean isSuitableFor(BlockState state) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_4)) { - final int miningLevel = this.getMaterial().getMiningLevel(); - if (state.isOf(Blocks.OBSIDIAN) || state.isOf(Blocks.CRYING_OBSIDIAN) || state.isOf(Blocks.NETHERITE_BLOCK) || state.isOf(Blocks.RESPAWN_ANCHOR) || state.isOf(Blocks.ANCIENT_DEBRIS)) { - return miningLevel >= MiningLevels.DIAMOND; - } else if (state.isOf(Blocks.DIAMOND_BLOCK) || state.isOf(Blocks.DIAMOND_ORE) || state.isOf(Blocks.EMERALD_ORE) || state.isOf(Blocks.EMERALD_BLOCK) || state.isOf(Blocks.GOLD_BLOCK) || state.isOf(Blocks.GOLD_ORE) || state.isOf(Blocks.REDSTONE_ORE)) { - return miningLevel >= MiningLevels.IRON; - } else if (state.isOf(Blocks.IRON_BLOCK) || state.isOf(Blocks.IRON_ORE) || state.isOf(Blocks.LAPIS_BLOCK) || state.isOf(Blocks.LAPIS_ORE)) { - return miningLevel >= MiningLevels.STONE; - } else { - return viaFabricPlus$effective_materials_r1_16_5.contains(Material1_19_4.getMaterial(state)) || state.isOf(Blocks.NETHER_GOLD_ORE); - } - } else { - return super.isSuitableFor(state); - } - } - - @Override - public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) { - return viaFabricPlus$effective_blocks_b1_8_1.contains(state.getBlock()) ? this.miningSpeed : 1.0F; - } else if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_15_2)) { - return viaFabricPlus$effective_materials_r1_16_5.contains(Material1_19_4.getMaterial(state)) ? this.miningSpeed : viaFabricPlus$effective_blocks_r1_15_2.contains(state.getBlock()) ? this.miningSpeed : 1.0F; - } else if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_4)) { - return viaFabricPlus$effective_materials_r1_16_5.contains(Material1_19_4.getMaterial(state)) ? this.miningSpeed : viaFabricPlus$effective_blocks_r1_16_5.contains(state.getBlock()) ? this.miningSpeed : 1.0F; - } - - return super.getMiningSpeedMultiplier(stack, state); - } - -} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShearsItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShearsItem.java deleted file mode 100644 index 8f5450e8..00000000 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShearsItem.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus - * Copyright (C) 2021-2024 FlorianMichael/EnZaXD and RK_01/RaphiMC - * Copyright (C) 2023-2024 contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; - -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ShearsItem; -import net.minecraft.registry.tag.BlockTags; -import net.raphimc.vialegacy.api.LegacyProtocolVersion; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(ShearsItem.class) -public abstract class MixinShearsItem extends Item { - - public MixinShearsItem(Settings settings) { - super(settings); - } - - @Inject(method = "getMiningSpeedMultiplier", at = @At("HEAD"), cancellable = true) - private void changeMiningSpeed(ItemStack stack, BlockState state, CallbackInfoReturnable cir) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_4)) { - if (!state.isOf(Blocks.COBWEB) && !state.isIn(BlockTags.LEAVES)) { - cir.setReturnValue(state.isIn(BlockTags.WOOL) ? 5.0F : super.getMiningSpeedMultiplier(stack, state)); - } else { - cir.setReturnValue(15.0F); - } - } - } - - @Inject(method = "isSuitableFor", at = @At("HEAD"), cancellable = true) - private void changeEffectiveBlocks(BlockState state, CallbackInfoReturnable cir) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) { - cir.setReturnValue(state.isOf(Blocks.COBWEB)); - } - } - -} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShovelItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShovelItem.java deleted file mode 100644 index e7b0d396..00000000 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinShovelItem.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus - * Copyright (C) 2021-2024 FlorianMichael/EnZaXD and RK_01/RaphiMC - * Copyright (C) 2023-2024 contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; - -import com.google.common.collect.ImmutableSet; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.item.*; -import net.minecraft.registry.tag.TagKey; -import net.raphimc.vialegacy.api.LegacyProtocolVersion; -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.Redirect; -import org.spongepowered.asm.mixin.injection.Slice; - -import java.util.Map; -import java.util.Set; - -@Mixin(ShovelItem.class) -public abstract class MixinShovelItem extends MiningToolItem { - - @Unique - private static final Set viaFabricPlus$effective_blocks_b1_8_1 = ImmutableSet.of(Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.SAND, Blocks.GRAVEL, Blocks.SNOW, Blocks.SNOW_BLOCK, Blocks.CLAY, Blocks.FARMLAND); - - @Unique - private static final Set viaFabricPlus$effective_blocks_r1_16_5 = ImmutableSet.of(Blocks.CLAY, Blocks.DIRT, Blocks.COARSE_DIRT, Blocks.PODZOL, Blocks.FARMLAND, Blocks.GRASS_BLOCK, Blocks.GRAVEL, Blocks.MYCELIUM, Blocks.SAND, Blocks.RED_SAND, Blocks.SNOW_BLOCK, Blocks.SNOW, Blocks.SOUL_SAND, Blocks.DIRT_PATH, Blocks.WHITE_CONCRETE_POWDER, Blocks.ORANGE_CONCRETE_POWDER, Blocks.MAGENTA_CONCRETE_POWDER, Blocks.LIGHT_BLUE_CONCRETE_POWDER, Blocks.YELLOW_CONCRETE_POWDER, Blocks.LIME_CONCRETE_POWDER, Blocks.PINK_CONCRETE_POWDER, Blocks.GRAY_CONCRETE_POWDER, Blocks.LIGHT_GRAY_CONCRETE_POWDER, Blocks.CYAN_CONCRETE_POWDER, Blocks.PURPLE_CONCRETE_POWDER, Blocks.BLUE_CONCRETE_POWDER, Blocks.BROWN_CONCRETE_POWDER, Blocks.GREEN_CONCRETE_POWDER, Blocks.RED_CONCRETE_POWDER, Blocks.BLACK_CONCRETE_POWDER, Blocks.SOUL_SOIL); - - protected MixinShovelItem(float attackDamage, float attackSpeed, ToolMaterial material, TagKey effectiveBlocks, Item.Settings settings) { - super(attackDamage, attackSpeed, material, effectiveBlocks, settings); - } - - @Override - public boolean isSuitableFor(BlockState state) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_4)) { - return state.isOf(Blocks.SNOW) || state.isOf(Blocks.SNOW_BLOCK); - } else { - return super.isSuitableFor(state); - } - } - - @Redirect(method = "useOnBlock", slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/item/ShovelItem;PATH_STATES:Ljava/util/Map;")), at = @At(value = "INVOKE", target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;", ordinal = 0, remap = false)) - private Object disablePathAction(Map instance, Object grassBlock) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) { - return null; - } else { - return instance.get(grassBlock); - } - } - - @Override - public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) { - return viaFabricPlus$effective_blocks_b1_8_1.contains(state.getBlock()) ? this.miningSpeed : 1.0F; - } else if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_4)) { - return viaFabricPlus$effective_blocks_r1_16_5.contains(state.getBlock()) ? this.miningSpeed : 1.0F; - } - - return super.getMiningSpeedMultiplier(stack, state); - } - -} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinSwordItem.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinSwordItem.java deleted file mode 100644 index 3dda4acb..00000000 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinSwordItem.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus - * Copyright (C) 2021-2024 FlorianMichael/EnZaXD and RK_01/RaphiMC - * Copyright (C) 2023-2024 contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item; - -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.Multimap; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; -import de.florianmichael.viafabricplus.settings.impl.DebugSettings; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.attribute.EntityAttribute; -import net.minecraft.entity.attribute.EntityAttributeModifier; -import net.minecraft.entity.attribute.EntityAttributes; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.SwordItem; -import net.minecraft.item.ToolItem; -import net.minecraft.item.ToolMaterial; -import net.minecraft.util.Hand; -import net.minecraft.util.TypedActionResult; -import net.minecraft.util.UseAction; -import net.minecraft.world.World; -import net.raphimc.vialegacy.api.LegacyProtocolVersion; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -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.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(SwordItem.class) -public abstract class MixinSwordItem extends ToolItem { - - @Shadow - @Final - private float attackDamage; - - @Shadow - @Final - private Multimap attributeModifiers; - - @Unique - private float viaFabricPlus$attackDamage_r1_8; - - @Unique - private Multimap viaFabricPlus$AttributeModifiers_r1_8; - - public MixinSwordItem(ToolMaterial material, Settings settings) { - super(material, settings); - } - - @Inject(method = "", at = @At("RETURN")) - private void init1_8Fields(ToolMaterial toolMaterial, int attackDamage, float attackSpeed, Settings settings, CallbackInfo ci) { - this.viaFabricPlus$attackDamage_r1_8 = 4 + toolMaterial.getAttackDamage(); - final ImmutableMultimap.Builder builder = ImmutableMultimap.builder(); - builder.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(ATTACK_DAMAGE_MODIFIER_ID, "Weapon modifier", this.viaFabricPlus$attackDamage_r1_8, EntityAttributeModifier.Operation.ADDITION)); - this.viaFabricPlus$AttributeModifiers_r1_8 = builder.build(); - } - - @Override - public TypedActionResult use(World world, PlayerEntity user, Hand hand) { - if (ProtocolTranslator.getTargetVersion().betweenInclusive(LegacyProtocolVersion.b1_8tob1_8_1, ProtocolVersion.v1_8)) { - ItemStack itemStack = user.getStackInHand(hand); - user.setCurrentHand(hand); - return TypedActionResult.consume(itemStack); - } else { - return super.use(world, user, hand); - } - } - - @Override - public UseAction getUseAction(ItemStack stack) { - if (ProtocolTranslator.getTargetVersion().betweenInclusive(LegacyProtocolVersion.b1_8tob1_8_1, ProtocolVersion.v1_8)) { - return UseAction.BLOCK; - } else { - return super.getUseAction(stack); - } - } - - @Override - public int getMaxUseTime(ItemStack stack) { - if (ProtocolTranslator.getTargetVersion().betweenInclusive(LegacyProtocolVersion.b1_8tob1_8_1, ProtocolVersion.v1_8)) { - return 72000; - } else { - return super.getMaxUseTime(stack); - } - } - - @Redirect(method = "getAttackDamage", at = @At(value = "FIELD", target = "Lnet/minecraft/item/SwordItem;attackDamage:F")) - private float changeAttackDamage(SwordItem instance) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) { - return this.viaFabricPlus$attackDamage_r1_8; - } else { - return this.attackDamage; - } - } - - @Redirect(method = "getAttributeModifiers", at = @At(value = "FIELD", target = "Lnet/minecraft/item/SwordItem;attributeModifiers:Lcom/google/common/collect/Multimap;")) - private Multimap changeAttributeModifiers(SwordItem instance) { - if (DebugSettings.global().replaceAttributeModifiers.isEnabled()) { - return this.viaFabricPlus$AttributeModifiers_r1_8; - } else { - return this.attributeModifiers; - } - } - - @Inject(method = "getMiningSpeedMultiplier", at = @At("HEAD"), cancellable = true) - private void changeMiningSpeed(ItemStack stack, BlockState state, CallbackInfoReturnable cir) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) { - cir.setReturnValue(state.isOf(Blocks.COBWEB) ? 15.0F : 1.5F); - } - } - -} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientCommonNetworkHandler.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientCommonNetworkHandler.java index c305d3dc..12a89a92 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientCommonNetworkHandler.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientCommonNetworkHandler.java @@ -21,11 +21,8 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.network; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.storage.InventoryAcknowledgements; -import de.florianmichael.viafabricplus.fixes.ClientsideFixes; import de.florianmichael.viafabricplus.injection.access.IClientConnection; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; -import net.fabricmc.fabric.impl.networking.payload.ResolvablePayload; -import net.fabricmc.fabric.impl.networking.payload.UntypedPayload; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientCommonNetworkHandler; import net.minecraft.network.ClientConnection; @@ -49,7 +46,6 @@ import java.net.URL; import java.time.Duration; import java.util.function.BooleanSupplier; -@SuppressWarnings("UnstableApiUsage") @Mixin(value = ClientCommonNetworkHandler.class, priority = 1 /* Has to be applied before Fabric's Networking API, so it doesn't cancel our custom-payload packets */) public abstract class MixinClientCommonNetworkHandler { @@ -104,10 +100,11 @@ public abstract class MixinClientCommonNetworkHandler { @Inject(method = "onCustomPayload(Lnet/minecraft/network/packet/s2c/common/CustomPayloadS2CPacket;)V", at = @At("HEAD"), cancellable = true) private void handleSyncTask(CustomPayloadS2CPacket packet, CallbackInfo ci) { - if (packet.payload().id().toString().equals(ClientsideFixes.PACKET_SYNC_IDENTIFIER) && packet.payload() instanceof ResolvablePayload payload) { + // TODO: Update: Fix + /*if (packet.payload().id().toString().equals(ClientsideFixes.PACKET_SYNC_IDENTIFIER) && packet.payload() instanceof ResolvablePayload payload) { ClientsideFixes.handleSyncTask(((UntypedPayload) payload.resolve(null)).buffer()); ci.cancel(); // Cancel the packet, so it doesn't get processed by the client - } + }*/ } @Inject(method = "onResourcePackSend", at = @At("HEAD"), cancellable = true) diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayNetworkHandler.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayNetworkHandler.java index f50851ea..f5145f44 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayNetworkHandler.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayNetworkHandler.java @@ -28,6 +28,7 @@ import de.florianmichael.viafabricplus.injection.access.IDownloadingTerrainScree import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import de.florianmichael.viafabricplus.settings.impl.VisualSettings; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.DownloadingTerrainScreen; import net.minecraft.client.network.*; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; @@ -81,8 +82,8 @@ public abstract class MixinClientPlayNetworkHandler extends ClientCommonNetworkH super(client, connection, connectionState); } - @WrapWithCondition(method = "onPlayerRespawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;startWorldLoading(Lnet/minecraft/client/network/ClientPlayerEntity;Lnet/minecraft/client/world/ClientWorld;)V")) - private boolean checkDimensionChange(ClientPlayNetworkHandler instance, ClientPlayerEntity player, ClientWorld world, @Local RegistryKey registryKey) { + @WrapWithCondition(method = "onPlayerRespawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;startWorldLoading(Lnet/minecraft/client/network/ClientPlayerEntity;Lnet/minecraft/client/world/ClientWorld;Lnet/minecraft/client/gui/screen/DownloadingTerrainScreen$WorldEntryReason;)V")) + private boolean checkDimensionChange(ClientPlayNetworkHandler instance, ClientPlayerEntity player, ClientWorld world, DownloadingTerrainScreen.WorldEntryReason worldEntryReason, @Local(ordinal = 0) RegistryKey registryKey) { return ProtocolTranslator.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_20_3) || registryKey != this.client.player.getWorld().getRegistryKey(); } @@ -124,7 +125,7 @@ public abstract class MixinClientPlayNetworkHandler extends ClientCommonNetworkH } } - @Redirect(method = "onServerMetadata", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;isSecureChatEnforced()Z")) + @Redirect(method = "onGameJoin", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;isSecureChatEnforced()Z")) private boolean removeSecureChatWarning(ClientPlayNetworkHandler instance) { return isSecureChatEnforced() || VisualSettings.global().disableSecureChatWarning.isEnabled(); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayerInteractionManager.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayerInteractionManager.java index e5b2d2ba..4af53799 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayerInteractionManager.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayerInteractionManager.java @@ -171,7 +171,7 @@ public abstract class MixinClientPlayerInteractionManager implements IClientPlay } @Redirect(method = {"method_41936", "method_41935"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;breakBlock(Lnet/minecraft/util/math/BlockPos;)Z")) - private boolean checkFireBlock(ClientPlayerInteractionManager instance, BlockPos pos, @Local Direction direction) { + private boolean checkFireBlock(ClientPlayerInteractionManager instance, BlockPos pos, @Local(argsOnly = true) Direction direction) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_15_2)) { return !this.viaFabricPlus$extinguishFire(pos, direction) && instance.breakBlock(pos); } else { diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinCustomPayloadS2CPacket.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinCustomPayloadS2CPacket.java deleted file mode 100644 index 801d8c58..00000000 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinCustomPayloadS2CPacket.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus - * Copyright (C) 2021-2024 FlorianMichael/EnZaXD and RK_01/RaphiMC - * Copyright (C) 2023-2024 contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.network; - -import com.google.common.collect.ImmutableMap; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; -import net.minecraft.network.PacketByteBuf; -import net.minecraft.network.packet.BrandCustomPayload; -import net.minecraft.network.packet.CustomPayload; -import net.minecraft.network.packet.s2c.common.CustomPayloadS2CPacket; -import net.minecraft.network.packet.s2c.custom.DebugGameTestAddMarkerCustomPayload; -import net.minecraft.network.packet.s2c.custom.DebugGameTestClearCustomPayload; -import net.minecraft.util.Identifier; -import net.raphimc.vialegacy.api.LegacyProtocolVersion; -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.Redirect; - -import java.util.Map; - -@Mixin(CustomPayloadS2CPacket.class) -public abstract class MixinCustomPayloadS2CPacket { - - @Unique - private static final Map viaFabricPlus$PAYLOAD_DIFF = ImmutableMap.builder() - .put(BrandCustomPayload.ID, LegacyProtocolVersion.c0_0_15a_1) - .put(DebugGameTestAddMarkerCustomPayload.ID, ProtocolVersion.v1_14) - .put(DebugGameTestClearCustomPayload.ID, ProtocolVersion.v1_14) - .build(); - - @Redirect(method = "readPayload", at = @At(value = "INVOKE", target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;", remap = false)) - private static Object filterAllowedCustomPayloads(Map> instance, Object object) { - final Identifier identifier = (Identifier) object; - if (instance.containsKey(identifier)) { - final PacketByteBuf.PacketReader reader = instance.get(identifier); - - // Mods might add custom payloads that we don't want to filter, so we check for the namespace. - // Mods should NEVER use the default namespace of the game, not only to not break this code, - // but also to not break other mods and the game itself. - if (!identifier.getNamespace().equals(Identifier.DEFAULT_NAMESPACE)) { - return reader; - } - - // Technically it's wrong to just drop all payloads, but ViaVersion doesn't translate them and the server can't detect if - // we handled the payload or not, so dropping them is easier than adding a bunch of useless translations for payloads - // which doesn't do anything on the client anyway. - if (!viaFabricPlus$PAYLOAD_DIFF.containsKey(identifier) || ProtocolTranslator.getTargetVersion().olderThan(viaFabricPlus$PAYLOAD_DIFF.get(identifier))) { - return null; - } - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20)) { - // Skip remaining bytes after reading the payload and return null if the payload fails to read - return (PacketByteBuf.PacketReader) packetByteBuf -> { - try { - final CustomPayload result = reader.apply(packetByteBuf); - packetByteBuf.skipBytes(packetByteBuf.readableBytes()); - return result; - } catch (Exception e) { - return null; - } - }; - } else { - return reader; - } - } else { - return null; - } - } - -} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinPacketByteBuf.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinPacketByteBuf.java deleted file mode 100644 index 72887488..00000000 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinPacketByteBuf.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus - * Copyright (C) 2021-2024 FlorianMichael/EnZaXD and RK_01/RaphiMC - * Copyright (C) 2023-2024 contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.network; - -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import de.florianmichael.viafabricplus.fixes.ClientsideFixes; -import de.florianmichael.viafabricplus.injection.access.IItemStack; -import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtElement; -import net.minecraft.network.PacketByteBuf; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(value = PacketByteBuf.class) -public abstract class MixinPacketByteBuf { - - @Redirect(method = "readItemStack", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;setNbt(Lnet/minecraft/nbt/NbtCompound;)V")) - private void removeViaFabricPlusTag(ItemStack instance, NbtCompound tag) { - if (tag != null && tag.contains(ClientsideFixes.ITEM_COUNT_NBT_TAG, NbtElement.BYTE_TYPE) && ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_10)) { - final IItemStack mixinItemStack = ((IItemStack) (Object) instance); - mixinItemStack.viaFabricPlus$set1_10Count(tag.getByte(ClientsideFixes.ITEM_COUNT_NBT_TAG)); - tag.remove(ClientsideFixes.ITEM_COUNT_NBT_TAG); - if (tag.isEmpty()) tag = null; - } - - instance.setNbt(tag); - } - - @Redirect(method = "writeItemStack", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getNbt()Lnet/minecraft/nbt/NbtCompound;")) - private NbtCompound addViaFabricPlusTag(ItemStack instance) { - NbtCompound tag = instance.getNbt(); - - final IItemStack mixinItemStack = ((IItemStack) (Object) instance); - if (mixinItemStack.viaFabricPlus$has1_10Tag()) { - if (tag == null) tag = new NbtCompound(); - tag.putByte(ClientsideFixes.ITEM_COUNT_NBT_TAG, (byte) mixinItemStack.viaFabricPlus$get1_10Count()); - } - - return tag; - } - -} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinMouseOptionsScreen.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinMouseOptionsScreen.java index 56ec7fe0..0c77558e 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinMouseOptionsScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinMouseOptionsScreen.java @@ -31,9 +31,6 @@ import net.minecraft.client.option.GameOptions; import net.minecraft.text.Text; 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(MouseOptionsScreen.class) public abstract class MixinMouseOptionsScreen extends GameOptionsScreen { @@ -45,10 +42,11 @@ public abstract class MixinMouseOptionsScreen extends GameOptionsScreen { super(parent, gameOptions, title); } - @Inject(method = "render", at = @At("RETURN")) - private void render1_13SliderValue(DrawContext drawContext, int mouseX, int mouseY, float delta, CallbackInfo ci) { + @Override + public void render(DrawContext context, int mouseX, int mouseY, float delta) { + super.render(context, mouseX, mouseY, delta); if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2) && this.buttonList.getWidgetFor(this.gameOptions.getMouseSensitivity()).isHovered()) { - drawContext.drawTooltip(textRenderer, Text.of("<=1.13.2 Sensitivity: " + MathUtil.get1_13SliderValue(this.gameOptions.getMouseSensitivity().getValue().floatValue()).valueInt() + "%"), mouseX, mouseY); + context.drawTooltip(textRenderer, Text.of("<=1.13.2 Sensitivity: " + MathUtil.get1_13SliderValue(this.gameOptions.getMouseSensitivity().getValue().floatValue()).valueInt() + "%"), mouseX, mouseY); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinOptionsScreen.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinOptionsScreen.java deleted file mode 100644 index daf3f682..00000000 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinOptionsScreen.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus - * Copyright (C) 2021-2024 FlorianMichael/EnZaXD and RK_01/RaphiMC - * Copyright (C) 2023-2024 contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen; - -import de.florianmichael.viafabricplus.settings.impl.VisualSettings; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.screen.option.OptionsScreen; -import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.client.gui.widget.GridWidget; -import net.minecraft.text.Text; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -@Mixin(OptionsScreen.class) -public abstract class MixinOptionsScreen extends Screen { - - protected MixinOptionsScreen(Text title) { - super(title); - } - - @Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/GridWidget$Adder;add(Lnet/minecraft/client/gui/widget/Widget;)Lnet/minecraft/client/gui/widget/Widget;", ordinal = 10, shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD) - private void showSuperSecretSettings(CallbackInfo ci, GridWidget gridWidget, GridWidget.Adder adder) { - if (VisualSettings.global().showSuperSecretSettings.isEnabled() && MinecraftClient.getInstance().player != null) { - this.addDrawableChild(ButtonWidget.builder(Text.literal("Super Secret Settings..."), button -> MinecraftClient.getInstance().gameRenderer.cycleSuperSecretSetting()).dimensions(this.width / 2 + 5, this.height / 6 + 18, 150, 20).build()); - } - } - -} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinScreen.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinScreen.java index ef9b37b0..42b5af10 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinScreen.java @@ -21,10 +21,10 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; -import net.minecraft.SharedConstants; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.Screen; import net.minecraft.text.Style; +import net.minecraft.util.StringHelper; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -42,7 +42,7 @@ public abstract class MixinScreen { @Inject(method = "handleTextClick", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;)V", shift = At.Shift.BEFORE, ordinal = 1, remap = false), cancellable = true) private void allowRunCommandAction(Style style, CallbackInfoReturnable cir) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19)) { - this.client.player.networkHandler.sendChatMessage(SharedConstants.stripInvalidChars(style.getClickEvent().getValue())); + this.client.player.networkHandler.sendChatMessage(StringHelper.stripInvalidChars(style.getClickEvent().getValue())); cir.setReturnValue(true); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/hud/MixinChatHud.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/hud/MixinChatHud.java index 55820743..04310e02 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/hud/MixinChatHud.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/hud/MixinChatHud.java @@ -29,7 +29,7 @@ import org.spongepowered.asm.mixin.injection.ModifyVariable; @Mixin(ChatHud.class) public abstract class MixinChatHud { - @ModifyVariable(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;ILnet/minecraft/client/gui/hud/MessageIndicator;Z)V", at = @At("HEAD"), ordinal = 0, argsOnly = true) + @ModifyVariable(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V", at = @At("HEAD"), ordinal = 0, argsOnly = true) private MessageIndicator removeIndicator(MessageIndicator instance) { return VisualSettings.global().hideSignatureIndicator.isEnabled() ? null : instance; } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/hud/MixinInGameHud.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/hud/MixinInGameHud.java deleted file mode 100644 index e92fe55a..00000000 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/hud/MixinInGameHud.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus - * Copyright (C) 2021-2024 FlorianMichael/EnZaXD and RK_01/RaphiMC - * Copyright (C) 2023-2024 contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.screen.hud; - -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import de.florianmichael.viafabricplus.settings.impl.VisualSettings; -import net.minecraft.client.gui.hud.InGameHud; -import net.minecraft.entity.LivingEntity; -import org.objectweb.asm.Opcodes; -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.ModifyArg; -import org.spongepowered.asm.mixin.injection.Slice; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(InGameHud.class) -public abstract class MixinInGameHud { - - @Shadow - private int scaledWidth; - - // Removing newer elements - - @Inject(method = {"renderMountJumpBar", "renderMountHealth"}, at = @At("HEAD"), cancellable = true) - private void removeMountJumpBar(CallbackInfo ci) { - if (VisualSettings.global().removeNewerHudElements.isEnabled()) { - ci.cancel(); - } - } - - @Inject(method = "getHeartCount", at = @At("HEAD"), cancellable = true) - private void removeHungerBar(LivingEntity entity, CallbackInfoReturnable cir) { - if (VisualSettings.global().removeNewerHudElements.isEnabled()) { - cir.setReturnValue(1); - } - } - - // Moving down all remaining elements - - @ModifyExpressionValue(method = "renderStatusBars", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/hud/InGameHud;scaledHeight:I", opcode = Opcodes.GETFIELD), - require = 0) - private int moveHealthDown(int originalValue) { - if (VisualSettings.global().removeNewerHudElements.isEnabled()) { - return originalValue + 6; - } else { - return originalValue; - } - } - - @ModifyArg(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lnet/minecraft/util/Identifier;IIII)V"), slice = @Slice( - from = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;push(Ljava/lang/String;)V"), - to = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 0)), index = 1, - require = 0) - private int moveArmorNextToHealth(int oldX) { - if (VisualSettings.global().removeNewerHudElements.isEnabled()) { - return scaledWidth - oldX - 9; - } else { - return oldX; - } - } - - @ModifyArg(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lnet/minecraft/util/Identifier;IIII)V"), slice = @Slice( - from = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;push(Ljava/lang/String;)V"), - to = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 1)), index = 2, - require = 0) - private int moveArmorDown(int oldY) { - if (VisualSettings.global().removeNewerHudElements.isEnabled()) { - return oldY + 9; - } else { - return oldY; - } - } - - @ModifyArg(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lnet/minecraft/util/Identifier;IIII)V"), slice = @Slice( - from = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 2), - to = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;pop()V")), index = 1, - require = 0) - private int moveAir(int oldY) { - if (VisualSettings.global().removeNewerHudElements.isEnabled()) { - return scaledWidth - oldY - 9; - } else { - return oldY; - } - } - -} diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/screenhandler/MixinMerchantScreenHandler.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/screenhandler/MixinMerchantScreenHandler.java index f566406f..7f63d97e 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/screenhandler/MixinMerchantScreenHandler.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/screenhandler/MixinMerchantScreenHandler.java @@ -31,7 +31,9 @@ import net.minecraft.screen.ScreenHandlerType; import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.SlotActionType; import net.minecraft.village.MerchantInventory; +import net.minecraft.village.TradeOffer; import net.minecraft.village.TradeOfferList; +import net.minecraft.village.TradedItem; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -82,8 +84,9 @@ public abstract class MixinMerchantScreenHandler extends ScreenHandler { // refill the slots if (this.merchantInventory.getStack(0).isEmpty() && this.merchantInventory.getStack(1).isEmpty()) { - this.viaFabricPlus$autofill(interactionManager, player, 0, this.getRecipes().get(recipeId).getAdjustedFirstBuyItem()); - this.viaFabricPlus$autofill(interactionManager, player, 1, this.getRecipes().get(recipeId).getSecondBuyItem()); + final TradeOffer tradeOffer = this.getRecipes().get(recipeId); + this.viaFabricPlus$autofill(interactionManager, player, 0, tradeOffer.getFirstBuyItem()); + tradeOffer.getSecondBuyItem().ifPresent(item -> this.viaFabricPlus$autofill(interactionManager, player, 1, item)); } } } @@ -96,14 +99,15 @@ public abstract class MixinMerchantScreenHandler extends ScreenHandler { } @Unique - private void viaFabricPlus$autofill(ClientPlayerInteractionManager interactionManager, ClientPlayerEntity player, int inputSlot, ItemStack stackNeeded) { - if (stackNeeded.isEmpty()) return; - + private void viaFabricPlus$autofill(ClientPlayerInteractionManager interactionManager, ClientPlayerEntity player, int inputSlot, TradedItem stackNeeded) { int slot; for (slot = 3; slot < 39; slot++) { - final ItemStack stack = slots.get(slot).getStack(); - if (ItemStack.canCombine(stack, stackNeeded)) { - break; + final ItemStack itemStack = this.slots.get(slot).getStack(); + if (!itemStack.isEmpty() && stackNeeded.matches(itemStack)) { + final ItemStack itemStack2 = this.merchantInventory.getStack(slot); + if (ItemStack.areItemsAndComponentsEqual(itemStack, itemStack2)) { + break; + } } } if (slot == 39) return; diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinInventoryPackets.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinInventoryPackets.java index 81f74e79..cb52627c 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinInventoryPackets.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinInventoryPackets.java @@ -31,6 +31,7 @@ import net.minecraft.client.gui.screen.ingame.GenericContainerScreen; import net.minecraft.inventory.SimpleInventory; import net.minecraft.screen.GenericContainerScreenHandler; import net.minecraft.text.Text; +import net.minecraft.text.TextCodecs; import net.minecraft.util.math.MathHelper; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -52,11 +53,11 @@ public abstract class MixinInventoryPackets { try { final int syncId = data.readUnsignedByte(); final int size = data.readUnsignedByte(); - final Text title1_20 = data.readText(); + final Text mcTitle = TextCodecs.UNLIMITED_REGISTRY_PACKET_CODEC.decode(data); final GenericContainerScreenHandler screenHandler = new GenericContainerScreenHandler(null, syncId, mc.player.getInventory(), new SimpleInventory(size), MathHelper.ceil(size / 9F)); mc.player.currentScreenHandler = screenHandler; - mc.setScreen(new GenericContainerScreen(screenHandler, mc.player.getInventory(), title1_20)); + mc.setScreen(new GenericContainerScreen(screenHandler, mc.player.getInventory(), mcTitle)); } catch (Throwable t) { throw new RuntimeException("Failed to handle OpenWindow packet data", t); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/viaversion/MixinProtocolVersion.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/viaversion/MixinProtocolVersion.java index ccbbe470..1dcdf49d 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/viaversion/MixinProtocolVersion.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/viaversion/MixinProtocolVersion.java @@ -48,7 +48,6 @@ public abstract class MixinProtocolVersion { viaFabricPlus$remaps.put("1.19.1/1.19.2", new Pair<>("1.19.1-1.19.2", null)); viaFabricPlus$remaps.put("1.20/1.20.1", new Pair<>("1.20-1.20.1", null)); viaFabricPlus$remaps.put("1.20.3/1.20.4", new Pair<>("1.20.3-1.20.4", null)); - viaFabricPlus$remaps.put("1.20.5", new Pair<>("24w09a", null)); } @Redirect(method = "", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/protocol/version/ProtocolVersion;register(ILjava/lang/String;)Lcom/viaversion/viaversion/api/protocol/version/ProtocolVersion;")) diff --git a/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/ProtocolTranslator.java b/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/ProtocolTranslator.java index 3e968ffe..e8b0813a 100644 --- a/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/ProtocolTranslator.java +++ b/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/ProtocolTranslator.java @@ -85,7 +85,7 @@ public class ProtocolTranslator { /** * The native version of the client */ - public static final ProtocolVersion NATIVE_VERSION = ProtocolVersion.v1_20_3; + public static final ProtocolVersion NATIVE_VERSION = ProtocolVersion.v1_20_5; /** * Protocol version that is used to enable protocol auto-detect @@ -234,7 +234,7 @@ public class ProtocolTranslator { public static UserConnection getPlayNetworkUserConnection() { final ClientPlayNetworkHandler handler = MinecraftClient.getInstance().getNetworkHandler(); if (handler == null) { - throw new IllegalStateException("The player is not connected to a server"); + return null; } return ((IClientConnection) handler.getConnection()).viaFabricPlus$getUserConnection(); diff --git a/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/impl/provider/viabedrock/ViaFabricPlusTransferProvider.java b/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/impl/provider/viabedrock/ViaFabricPlusTransferProvider.java index 3c076115..402d2fb6 100644 --- a/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/impl/provider/viabedrock/ViaFabricPlusTransferProvider.java +++ b/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/impl/provider/viabedrock/ViaFabricPlusTransferProvider.java @@ -20,15 +20,8 @@ package de.florianmichael.viafabricplus.protocoltranslator.impl.provider.viabedrock; import com.viaversion.viaversion.api.connection.UserConnection; -import de.florianmichael.viafabricplus.settings.impl.BedrockSettings; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.ConfirmScreen; -import net.minecraft.client.gui.screen.TitleScreen; -import net.minecraft.client.gui.screen.multiplayer.ConnectScreen; -import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen; -import net.minecraft.client.network.ServerAddress; -import net.minecraft.client.network.ServerInfo; -import net.minecraft.text.Text; +import net.minecraft.network.packet.s2c.common.ServerTransferS2CPacket; import net.raphimc.viabedrock.protocol.providers.TransferProvider; import java.net.InetSocketAddress; @@ -37,31 +30,7 @@ public class ViaFabricPlusTransferProvider extends TransferProvider { @Override public void connectToServer(UserConnection user, InetSocketAddress newAddress) { - final var mc = MinecraftClient.getInstance(); - mc.execute(() -> { - if (BedrockSettings.global().openPromptGUIToConfirmTransfer.getValue()) { - mc.setScreen(new ConfirmScreen((bl) -> { - if (bl) { - connect(newAddress); - } else { - mc.setScreen(null); - } - }, - Text.of("ViaFabricPlus"), - Text.translatable("bedrock.viafabricplus.confirm_transfer_server_prompt", newAddress.getHostName() + ":" + newAddress.getPort()) - )); - } else { - connect(newAddress); - } - }); - } - - private void connect(final InetSocketAddress newAddress) { - final var mc = MinecraftClient.getInstance(); - mc.world.disconnect(); - - final var serverInfo = new ServerInfo(newAddress.getHostName(), newAddress.getHostName() + ":" + newAddress.getPort(), ServerInfo.ServerType.OTHER); - ConnectScreen.connect(new MultiplayerScreen(new TitleScreen()), mc, ServerAddress.parse(serverInfo.address), serverInfo, false); + MinecraftClient.getInstance().getNetworkHandler().onServerTransfer(new ServerTransferS2CPacket(newAddress.getHostString(), newAddress.getPort())); } } diff --git a/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/netty/ViaFabricPlusVLLegacyPipeline.java b/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/netty/ViaFabricPlusVLLegacyPipeline.java index 0fc3e631..416c3c74 100644 --- a/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/netty/ViaFabricPlusVLLegacyPipeline.java +++ b/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/netty/ViaFabricPlusVLLegacyPipeline.java @@ -67,7 +67,7 @@ public class ViaFabricPlusVLLegacyPipeline extends VLLegacyPipeline { @Override protected String packetDecoderName() { - return "decoder"; + return "inbound_config"; } @Override diff --git a/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/translator/ItemTranslator.java b/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/translator/ItemTranslator.java index da90c348..8e1e7fbb 100644 --- a/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/translator/ItemTranslator.java +++ b/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/translator/ItemTranslator.java @@ -26,14 +26,14 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.types.version.Types1_20_5; +import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ServerboundPackets1_20_5; import de.florianmichael.viafabricplus.ViaFabricPlus; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import io.netty.buffer.Unpooled; +import net.minecraft.client.MinecraftClient; import net.minecraft.item.ItemStack; -import net.minecraft.network.NetworkSide; -import net.minecraft.network.NetworkState; -import net.minecraft.network.PacketByteBuf; -import net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket; +import net.minecraft.network.RegistryByteBuf; import net.minecraft.registry.Registries; import net.raphimc.vialegacy.api.LegacyProtocolVersion; import net.raphimc.vialegacy.protocols.beta.protocol1_0_0_1tob1_8_0_1.ClientboundPacketsb1_8; @@ -43,7 +43,6 @@ import net.raphimc.vialegacy.protocols.release.protocol1_4_4_5to1_4_2.types.Type public class ItemTranslator { private static final UserConnection VIA_B1_8_TO_MC_USER_CONNECTION = ProtocolTranslator.createDummyUserConnection(ProtocolTranslator.NATIVE_VERSION, LegacyProtocolVersion.b1_8tob1_8_1); - private static final int CREATIVE_INVENTORY_ACTION_ID = NetworkState.PLAY.getHandler(NetworkSide.SERVERBOUND).getId(new CreativeInventoryActionC2SPacket(0, ItemStack.EMPTY)); /** * Converts a Minecraft item stack to a ViaVersion item stack @@ -56,11 +55,11 @@ public class ItemTranslator { final UserConnection user = ProtocolTranslator.createDummyUserConnection(ProtocolTranslator.NATIVE_VERSION, targetVersion); try { - final PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer()); + final RegistryByteBuf buf = new RegistryByteBuf(Unpooled.buffer(), MinecraftClient.getInstance().getNetworkHandler().getRegistryManager()); buf.writeShort(0); // slot - buf.writeItemStack(stack); // item + ItemStack.OPTIONAL_PACKET_CODEC.encode(buf, stack); // item - final PacketWrapper wrapper = PacketWrapper.create(CREATIVE_INVENTORY_ACTION_ID, buf, user); + final PacketWrapper wrapper = PacketWrapper.create(ServerboundPackets1_20_5.CREATIVE_INVENTORY_ACTION.getId(), buf, user); user.getProtocolInfo().getPipeline().transform(Direction.SERVERBOUND, State.PLAY, wrapper); wrapper.read(Type.SHORT); // slot @@ -86,8 +85,10 @@ public class ItemTranslator { return Type.ITEM1_13; } else if (targetVersion.olderThanOrEqualTo(ProtocolVersion.v1_20_2)) { return Type.ITEM1_13_2; - } else { + } else if (targetVersion.olderThanOrEqualTo(ProtocolVersion.v1_20_3)) { return Type.ITEM1_20_2; + } else { + return Types1_20_5.ITEM; } } diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/BetaCraftScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/BetaCraftScreen.java index 7fdc19ea..891c9865 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/BetaCraftScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/BetaCraftScreen.java @@ -93,7 +93,7 @@ public class BetaCraftScreen extends VFPScreen { } @Override - protected int getScrollbarPositionX() { + protected int getScrollbarX() { return this.width - 5; } } @@ -115,7 +115,7 @@ public class BetaCraftScreen extends VFPScreen { final ServerAddress serverAddress = ServerAddress.parse(server.socketAddress()); final ServerInfo entry = new ServerInfo(server.name(), serverAddress.getAddress(), ServerInfo.ServerType.OTHER); - ConnectScreen.connect(MinecraftClient.getInstance().currentScreen, MinecraftClient.getInstance(), serverAddress, entry, false); + ConnectScreen.connect(MinecraftClient.getInstance().currentScreen, MinecraftClient.getInstance(), serverAddress, entry, false, null); super.mappedMouseClicked(mouseX, mouseY, button); } diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java index 61a670ed..bdd0b9b9 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java @@ -28,7 +28,6 @@ import de.florianmichael.viafabricplus.injection.access.IServerInfo; import de.florianmichael.viafabricplus.protocoltranslator.impl.provider.vialegacy.ViaFabricPlusClassicMPPassProvider; import de.florianmichael.viafabricplus.screen.VFPListEntry; import de.florianmichael.viafabricplus.screen.VFPScreen; -import de.florianmichael.viafabricplus.screen.base.ProtocolSelectionScreen; import de.florianmichael.viafabricplus.settings.impl.AuthenticationSettings; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; @@ -111,7 +110,7 @@ public class ClassiCubeServerListScreen extends VFPScreen { } @Override - protected int getScrollbarPositionX() { + protected int getScrollbarX() { return this.width - 5; } } @@ -139,7 +138,7 @@ public class ClassiCubeServerListScreen extends VFPScreen { ((IServerInfo) entry).viaFabricPlus$forceVersion(LegacyProtocolVersion.c0_30cpe); } - ConnectScreen.connect(MinecraftClient.getInstance().currentScreen, MinecraftClient.getInstance(), serverAddress, entry, false); + ConnectScreen.connect(MinecraftClient.getInstance().currentScreen, MinecraftClient.getInstance(), serverAddress, entry, false, null); super.mappedMouseClicked(mouseX, mouseY, button); } diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/settings/SettingsScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/settings/SettingsScreen.java index 377067d6..3e35de1b 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/settings/SettingsScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/settings/SettingsScreen.java @@ -72,7 +72,7 @@ public class SettingsScreen extends VFPScreen { } @Override - protected int getScrollbarPositionX() { + protected int getScrollbarX() { return this.width - 5; } } diff --git a/src/main/java/de/florianmichael/viafabricplus/settings/impl/BedrockSettings.java b/src/main/java/de/florianmichael/viafabricplus/settings/impl/BedrockSettings.java index c53a34bb..decc10aa 100644 --- a/src/main/java/de/florianmichael/viafabricplus/settings/impl/BedrockSettings.java +++ b/src/main/java/de/florianmichael/viafabricplus/settings/impl/BedrockSettings.java @@ -54,7 +54,6 @@ public class BedrockSettings extends SettingGroup { } } }; - public final BooleanSetting openPromptGUIToConfirmTransfer = new BooleanSetting(this, Text.translatable("bedrock_settings.viafabricplus.confirm_transfer_server_prompt"), true); public final BooleanSetting replaceDefaultPort = new BooleanSetting(this, Text.translatable("bedrock_settings.viafabricplus.replace_default_port"), true); public BedrockSettings() { diff --git a/src/main/java/de/florianmichael/viafabricplus/settings/impl/VisualSettings.java b/src/main/java/de/florianmichael/viafabricplus/settings/impl/VisualSettings.java index cff7b53b..7636e274 100644 --- a/src/main/java/de/florianmichael/viafabricplus/settings/impl/VisualSettings.java +++ b/src/main/java/de/florianmichael/viafabricplus/settings/impl/VisualSettings.java @@ -46,7 +46,6 @@ public class VisualSettings extends SettingGroup { // 1.9 -> 1.8.x public final VersionedBooleanSetting emulateArmorHud = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.emulate_armor_hud"), VersionRange.andOlder(ProtocolVersion.v1_8)); public final VersionedBooleanSetting removeNewerFeaturesFromCommandBlockScreen = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.remove_newer_features_from_command_block_screen"), VersionRange.andOlder(ProtocolVersion.v1_8)); - public final VersionedBooleanSetting showSuperSecretSettings = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.show_super_secret_settings"), VersionRange.andOlder(ProtocolVersion.v1_8)); public final VersionedBooleanSetting enableSwordBlocking = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.enable_sword_blocking"), VersionRange.andOlder(ProtocolVersion.v1_8)); // 1.8.x -> 1.7.6 - 1.7.10 diff --git a/src/main/resources/assets/viafabricplus/lang/de_de.json b/src/main/resources/assets/viafabricplus/lang/de_de.json index b3fc304d..32e11bb5 100644 --- a/src/main/resources/assets/viafabricplus/lang/de_de.json +++ b/src/main/resources/assets/viafabricplus/lang/de_de.json @@ -46,7 +46,6 @@ "general_settings.viafabricplus.load_skins_and_skulls_in_legacy_versions": "Skins und Schädel in alten Versionen laden", "general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions": "Inventaraktionen in Alpha-Versionen emulieren", - "bedrock_settings.viafabricplus.confirm_transfer_server_prompt": "Bestätigungsfenster öffnen, um das Transferieren zu anderen Servern zu bestätigen", "bedrock_settings.viafabricplus.click_to_set_bedrock_account": "Klicke, um den Account für die Bedrock-Edition einzustellen", "bedrock_settings.viafabricplus.replace_default_port": "Standardport in der Serverliste ersetzen", @@ -70,7 +69,6 @@ "authentication_settings.viafabricplus.automatically_select_cpe_when_using_classicube": "Automatisch CPE auswählen, wenn du die ClassiCube-Serverliste verwendest.", "authentication_settings.viafabricplus.set_session_name_to_classicube_name": "Session-Namen auf ClassiCube-Namen setzen, wenn du die ClassiCube-Serverliste verwendest.", - "visual_settings.viafabricplus.show_super_secret_settings": "Geheime Einstellungen anzeigen", "visual_settings.viafabricplus.disable_secure_chat_warning": "Warnung für sicheren Chat deaktivieren", "visual_settings.viafabricplus.hide_signature_indicator": "Signaturanzeige verstecken", "visual_settings.viafabricplus.remove_newer_features_from_jigsaw_screen": "Neuere Funktionen vom Puzzle-Block entfernen", diff --git a/src/main/resources/assets/viafabricplus/lang/en_us.json b/src/main/resources/assets/viafabricplus/lang/en_us.json index d7a9957a..adb35854 100644 --- a/src/main/resources/assets/viafabricplus/lang/en_us.json +++ b/src/main/resources/assets/viafabricplus/lang/en_us.json @@ -46,7 +46,6 @@ "general_settings.viafabricplus.load_skins_and_skulls_in_legacy_versions": "Load skins and skulls in legacy versions", "general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions": "Emulate inventory actions in alpha versions", - "bedrock_settings.viafabricplus.confirm_transfer_server_prompt": "Open prompt GUI to confirm transferring to other servers", "bedrock_settings.viafabricplus.click_to_set_bedrock_account": "Click to set account for Bedrock Edition", "bedrock_settings.viafabricplus.replace_default_port": "Replace default port in server list", @@ -70,7 +69,6 @@ "authentication_settings.viafabricplus.automatically_select_cpe_when_using_classicube": "Automatically select CPE when using the ClassiCube server list", "authentication_settings.viafabricplus.set_session_name_to_classicube_name": "Set session name to ClassiCube name when using the ClassiCube server list", - "visual_settings.viafabricplus.show_super_secret_settings": "Show Super Secret Settings", "visual_settings.viafabricplus.disable_secure_chat_warning": "Disable Secure Chat warning", "visual_settings.viafabricplus.hide_signature_indicator": "Hide signature indicator", "visual_settings.viafabricplus.remove_newer_features_from_jigsaw_screen": "Remove newer features from the Jigsaw screen", diff --git a/src/main/resources/assets/viafabricplus/lang/es_ar.json b/src/main/resources/assets/viafabricplus/lang/es_ar.json index 27f17d33..bea6c731 100644 --- a/src/main/resources/assets/viafabricplus/lang/es_ar.json +++ b/src/main/resources/assets/viafabricplus/lang/es_ar.json @@ -46,7 +46,6 @@ "general_settings.viafabricplus.load_skins_and_skulls_in_legacy_versions": "cargar skins y cabezas en versiones legacy", "general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions": "emular acciones de inventario en versiones alpha", - "bedrock_settings.viafabricplus.confirm_transfer_server_prompt": "Abrir UI de pregunta para confirmar la transferencia a otros servidores", "bedrock_settings.viafabricplus.click_to_set_bedrock_account": "Click para asignar cuenta de Bedrock", "debug_settings.viafabricplus.queue_config_packets": "cola de configuración de paquetes", @@ -69,7 +68,6 @@ "authentication_settings.viafabricplus.automatically_select_cpe_when_using_classicube": "Forzar version CPE si se usa la lista de servidores de ClassiCube.", "authentication_settings.viafabricplus.set_session_name_to_classicube_name": "Asignar nombre de sesión a ClassiCube cuando se usa ClassiCube la lista de ClassiCube.", - "visual_settings.viafabricplus.show_super_secret_settings": "Mostrar los ajustes super secretos", "visual_settings.viafabricplus.disable_secure_chat_warning": "Desactivar la advertencia de chat seguro", "visual_settings.viafabricplus.hide_signature_indicator": "Ocultar el indicador de firmas", "visual_settings.viafabricplus.remove_newer_features_from_jigsaw_screen": "Eliminar características nuevas de la pantalla de Jigsaw", diff --git a/src/main/resources/assets/viafabricplus/lang/es_cl.json b/src/main/resources/assets/viafabricplus/lang/es_cl.json index 27f17d33..bea6c731 100644 --- a/src/main/resources/assets/viafabricplus/lang/es_cl.json +++ b/src/main/resources/assets/viafabricplus/lang/es_cl.json @@ -46,7 +46,6 @@ "general_settings.viafabricplus.load_skins_and_skulls_in_legacy_versions": "cargar skins y cabezas en versiones legacy", "general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions": "emular acciones de inventario en versiones alpha", - "bedrock_settings.viafabricplus.confirm_transfer_server_prompt": "Abrir UI de pregunta para confirmar la transferencia a otros servidores", "bedrock_settings.viafabricplus.click_to_set_bedrock_account": "Click para asignar cuenta de Bedrock", "debug_settings.viafabricplus.queue_config_packets": "cola de configuración de paquetes", @@ -69,7 +68,6 @@ "authentication_settings.viafabricplus.automatically_select_cpe_when_using_classicube": "Forzar version CPE si se usa la lista de servidores de ClassiCube.", "authentication_settings.viafabricplus.set_session_name_to_classicube_name": "Asignar nombre de sesión a ClassiCube cuando se usa ClassiCube la lista de ClassiCube.", - "visual_settings.viafabricplus.show_super_secret_settings": "Mostrar los ajustes super secretos", "visual_settings.viafabricplus.disable_secure_chat_warning": "Desactivar la advertencia de chat seguro", "visual_settings.viafabricplus.hide_signature_indicator": "Ocultar el indicador de firmas", "visual_settings.viafabricplus.remove_newer_features_from_jigsaw_screen": "Eliminar características nuevas de la pantalla de Jigsaw", diff --git a/src/main/resources/assets/viafabricplus/lang/es_ec.json b/src/main/resources/assets/viafabricplus/lang/es_ec.json index 27f17d33..bea6c731 100644 --- a/src/main/resources/assets/viafabricplus/lang/es_ec.json +++ b/src/main/resources/assets/viafabricplus/lang/es_ec.json @@ -46,7 +46,6 @@ "general_settings.viafabricplus.load_skins_and_skulls_in_legacy_versions": "cargar skins y cabezas en versiones legacy", "general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions": "emular acciones de inventario en versiones alpha", - "bedrock_settings.viafabricplus.confirm_transfer_server_prompt": "Abrir UI de pregunta para confirmar la transferencia a otros servidores", "bedrock_settings.viafabricplus.click_to_set_bedrock_account": "Click para asignar cuenta de Bedrock", "debug_settings.viafabricplus.queue_config_packets": "cola de configuración de paquetes", @@ -69,7 +68,6 @@ "authentication_settings.viafabricplus.automatically_select_cpe_when_using_classicube": "Forzar version CPE si se usa la lista de servidores de ClassiCube.", "authentication_settings.viafabricplus.set_session_name_to_classicube_name": "Asignar nombre de sesión a ClassiCube cuando se usa ClassiCube la lista de ClassiCube.", - "visual_settings.viafabricplus.show_super_secret_settings": "Mostrar los ajustes super secretos", "visual_settings.viafabricplus.disable_secure_chat_warning": "Desactivar la advertencia de chat seguro", "visual_settings.viafabricplus.hide_signature_indicator": "Ocultar el indicador de firmas", "visual_settings.viafabricplus.remove_newer_features_from_jigsaw_screen": "Eliminar características nuevas de la pantalla de Jigsaw", diff --git a/src/main/resources/assets/viafabricplus/lang/es_es.json b/src/main/resources/assets/viafabricplus/lang/es_es.json index 731dc2e1..c12e1f00 100644 --- a/src/main/resources/assets/viafabricplus/lang/es_es.json +++ b/src/main/resources/assets/viafabricplus/lang/es_es.json @@ -46,7 +46,6 @@ "general_settings.viafabricplus.load_skins_and_skulls_in_legacy_versions": "cargar skins y cabezas en versiones legacy", "general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions": "emular acciones de inventario en versiones alpha", - "bedrock_settings.viafabricplus.confirm_transfer_server_prompt": "Abrir UI de pregunta para confirmar la transferencia a otros servidores", "bedrock_settings.viafabricplus.click_to_set_bedrock_account": "Click para asignar cuenta de Bedrock", "debug_settings.viafabricplus.queue_config_packets": "cola de configuración de paquetes", @@ -69,7 +68,6 @@ "authentication_settings.viafabricplus.automatically_select_cpe_when_using_classicube": "Forzar version CPE si se usa la lista de servidores de ClassiCube.", "authentication_settings.viafabricplus.set_session_name_to_classicube_name": "Asignar nombre de sesión a ClassiCube cuando se usa ClassiCube la lista de ClassiCube.", - "visual_settings.viafabricplus.show_super_secret_settings": "Mostrar los ajustes super secretos", "visual_settings.viafabricplus.disable_secure_chat_warning": "Desactivar la advertencia de chat seguro", "visual_settings.viafabricplus.hide_signature_indicator": "Ocultar el indicador de firmas", "visual_settings.viafabricplus.remove_newer_features_from_jigsaw_screen": "Eliminar características nuevas de la pantalla de Jigsaw", diff --git a/src/main/resources/assets/viafabricplus/lang/es_mx.json b/src/main/resources/assets/viafabricplus/lang/es_mx.json index 27f17d33..bea6c731 100644 --- a/src/main/resources/assets/viafabricplus/lang/es_mx.json +++ b/src/main/resources/assets/viafabricplus/lang/es_mx.json @@ -46,7 +46,6 @@ "general_settings.viafabricplus.load_skins_and_skulls_in_legacy_versions": "cargar skins y cabezas en versiones legacy", "general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions": "emular acciones de inventario en versiones alpha", - "bedrock_settings.viafabricplus.confirm_transfer_server_prompt": "Abrir UI de pregunta para confirmar la transferencia a otros servidores", "bedrock_settings.viafabricplus.click_to_set_bedrock_account": "Click para asignar cuenta de Bedrock", "debug_settings.viafabricplus.queue_config_packets": "cola de configuración de paquetes", @@ -69,7 +68,6 @@ "authentication_settings.viafabricplus.automatically_select_cpe_when_using_classicube": "Forzar version CPE si se usa la lista de servidores de ClassiCube.", "authentication_settings.viafabricplus.set_session_name_to_classicube_name": "Asignar nombre de sesión a ClassiCube cuando se usa ClassiCube la lista de ClassiCube.", - "visual_settings.viafabricplus.show_super_secret_settings": "Mostrar los ajustes super secretos", "visual_settings.viafabricplus.disable_secure_chat_warning": "Desactivar la advertencia de chat seguro", "visual_settings.viafabricplus.hide_signature_indicator": "Ocultar el indicador de firmas", "visual_settings.viafabricplus.remove_newer_features_from_jigsaw_screen": "Eliminar características nuevas de la pantalla de Jigsaw", diff --git a/src/main/resources/assets/viafabricplus/lang/es_uy.json b/src/main/resources/assets/viafabricplus/lang/es_uy.json index 27f17d33..bea6c731 100644 --- a/src/main/resources/assets/viafabricplus/lang/es_uy.json +++ b/src/main/resources/assets/viafabricplus/lang/es_uy.json @@ -46,7 +46,6 @@ "general_settings.viafabricplus.load_skins_and_skulls_in_legacy_versions": "cargar skins y cabezas en versiones legacy", "general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions": "emular acciones de inventario en versiones alpha", - "bedrock_settings.viafabricplus.confirm_transfer_server_prompt": "Abrir UI de pregunta para confirmar la transferencia a otros servidores", "bedrock_settings.viafabricplus.click_to_set_bedrock_account": "Click para asignar cuenta de Bedrock", "debug_settings.viafabricplus.queue_config_packets": "cola de configuración de paquetes", @@ -69,7 +68,6 @@ "authentication_settings.viafabricplus.automatically_select_cpe_when_using_classicube": "Forzar version CPE si se usa la lista de servidores de ClassiCube.", "authentication_settings.viafabricplus.set_session_name_to_classicube_name": "Asignar nombre de sesión a ClassiCube cuando se usa ClassiCube la lista de ClassiCube.", - "visual_settings.viafabricplus.show_super_secret_settings": "Mostrar los ajustes super secretos", "visual_settings.viafabricplus.disable_secure_chat_warning": "Desactivar la advertencia de chat seguro", "visual_settings.viafabricplus.hide_signature_indicator": "Ocultar el indicador de firmas", "visual_settings.viafabricplus.remove_newer_features_from_jigsaw_screen": "Eliminar características nuevas de la pantalla de Jigsaw", diff --git a/src/main/resources/assets/viafabricplus/lang/es_ve.json b/src/main/resources/assets/viafabricplus/lang/es_ve.json index 27f17d33..bea6c731 100644 --- a/src/main/resources/assets/viafabricplus/lang/es_ve.json +++ b/src/main/resources/assets/viafabricplus/lang/es_ve.json @@ -46,7 +46,6 @@ "general_settings.viafabricplus.load_skins_and_skulls_in_legacy_versions": "cargar skins y cabezas en versiones legacy", "general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions": "emular acciones de inventario en versiones alpha", - "bedrock_settings.viafabricplus.confirm_transfer_server_prompt": "Abrir UI de pregunta para confirmar la transferencia a otros servidores", "bedrock_settings.viafabricplus.click_to_set_bedrock_account": "Click para asignar cuenta de Bedrock", "debug_settings.viafabricplus.queue_config_packets": "cola de configuración de paquetes", @@ -69,7 +68,6 @@ "authentication_settings.viafabricplus.automatically_select_cpe_when_using_classicube": "Forzar version CPE si se usa la lista de servidores de ClassiCube.", "authentication_settings.viafabricplus.set_session_name_to_classicube_name": "Asignar nombre de sesión a ClassiCube cuando se usa ClassiCube la lista de ClassiCube.", - "visual_settings.viafabricplus.show_super_secret_settings": "Mostrar los ajustes super secretos", "visual_settings.viafabricplus.disable_secure_chat_warning": "Desactivar la advertencia de chat seguro", "visual_settings.viafabricplus.hide_signature_indicator": "Ocultar el indicador de firmas", "visual_settings.viafabricplus.remove_newer_features_from_jigsaw_screen": "Eliminar características nuevas de la pantalla de Jigsaw", diff --git a/src/main/resources/assets/viafabricplus/lang/hu_hu.json b/src/main/resources/assets/viafabricplus/lang/hu_hu.json index 503cb4d9..99beca43 100644 --- a/src/main/resources/assets/viafabricplus/lang/hu_hu.json +++ b/src/main/resources/assets/viafabricplus/lang/hu_hu.json @@ -44,7 +44,6 @@ "general_settings.viafabricplus.load_skins_and_skulls_in_legacy_versions": "Skinek és fejek betöltése elavult verziókban", "general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions": "Felszerelési műveletek emulálása alpha verziókban", - "bedrock_settings.viafabricplus.confirm_transfer_server_prompt": "Kérdő GUI megnyitása szerverváltás megerősítéséhez", "bedrock_settings.viafabricplus.click_to_set_bedrock_account": "Kattints egy Bedrock Edition fiók beállításához", "debug_settings.viafabricplus.queue_config_packets": "Konfigurációs adatcsomagok várólistára állítása", @@ -67,7 +66,6 @@ "authentication_settings.viafabricplus.automatically_select_cpe_when_using_classicube": "CPE verzió kényszerítése ClassiCube használata esetén", "authentication_settings.viafabricplus.set_session_name_to_classicube_name": "Felh. név hamisítása a ClassiCube névre C. Cube használata esetén", - "visual_settings.viafabricplus.show_super_secret_settings": "Super Secret Settings mutatása", "visual_settings.viafabricplus.disable_secure_chat_warning": "Biztonságos chat figyelmeztetés kikapcsolása", "visual_settings.viafabricplus.hide_signature_indicator": "Aláírásjelző elrejtése", "visual_settings.viafabricplus.remove_newer_features_from_jigsaw_screen": "Újabb funkciók eltávolítása a Kirakósblokk képernyőről", diff --git a/src/main/resources/assets/viafabricplus/lang/pl_pl.json b/src/main/resources/assets/viafabricplus/lang/pl_pl.json index 6cf66961..6dc775da 100644 --- a/src/main/resources/assets/viafabricplus/lang/pl_pl.json +++ b/src/main/resources/assets/viafabricplus/lang/pl_pl.json @@ -46,7 +46,6 @@ "general_settings.viafabricplus.load_skins_and_skulls_in_legacy_versions": "Ładuj skórki graczy w starszych wersjach gry", "general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions": "Emuluj akcje ekwipunku w wersjach alpha", - "bedrock_settings.viafabricplus.confirm_transfer_server_prompt": "Pytaj, żeby potwierdzić przełączanie do innych serwerów", "bedrock_settings.viafabricplus.click_to_set_bedrock_account": "Naciśnij, aby ustawić konto dla minecraft bedrock edition", "bedrock_settings.viafabricplus.replace_default_port": "Zamień domyślny port w liście serwerów", @@ -70,7 +69,6 @@ "authentication_settings.viafabricplus.automatically_select_cpe_when_using_classicube": "Automatycznie wybieraj wersję CPE podczas korzystania z listy serwerów ClassiCube", "authentication_settings.viafabricplus.set_session_name_to_classicube_name": "Ustaw nazwę sesji na nazwę ClassiCube podczas korzystania z listy serwerów ClassiCube", - "visual_settings.viafabricplus.show_super_secret_settings": "Pokazuj super secret settings", "visual_settings.viafabricplus.disable_secure_chat_warning": "Wyłącz ostrzeżenie dotyczące bezpiecznego czatu", "visual_settings.viafabricplus.hide_signature_indicator": "Ukrywaj wskaźnik podpisywania wiadomości na czacie", "visual_settings.viafabricplus.remove_newer_features_from_jigsaw_screen": "Usuń nowsze funkcje z ekranu bloku konstrukcyjnego", diff --git a/src/main/resources/assets/viafabricplus/lang/ru_ru.json b/src/main/resources/assets/viafabricplus/lang/ru_ru.json index 315baa0d..d7fc9980 100644 --- a/src/main/resources/assets/viafabricplus/lang/ru_ru.json +++ b/src/main/resources/assets/viafabricplus/lang/ru_ru.json @@ -47,7 +47,6 @@ "general_settings.viafabricplus.load_skins_and_skulls_in_legacy_versions": "Скины и головы игроков в старых версиях", "general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions": "Эмулировать действия в инвентаре в alpha-версиях", - "bedrock_settings.viafabricplus.confirm_transfer_server_prompt": "Экран подтверждения перехода на другой сервер", "bedrock_settings.viafabricplus.click_to_set_bedrock_account": "Нажмите для настройки учётной записи Bedrock Edition", "debug_settings.viafabricplus.queue_config_packets": "Очередь пакетов этапа настройки", @@ -70,7 +69,6 @@ "authentication_settings.viafabricplus.automatically_select_cpe_when_using_classicube": "Устанавливать версию CPE при использовании ClassiCube", "authentication_settings.viafabricplus.set_session_name_to_classicube_name": "Имя пользователя ClassiCube при его использовании", - "visual_settings.viafabricplus.show_super_secret_settings": "Вернуть Super Secret Settings", "visual_settings.viafabricplus.disable_secure_chat_warning": "Удалять уведомления о безопасности чата", "visual_settings.viafabricplus.hide_signature_indicator": "Скрывать индикатор цифровой подписи в чате", "visual_settings.viafabricplus.remove_newer_features_from_jigsaw_screen": "Старый блок головоломки", diff --git a/src/main/resources/assets/viafabricplus/lang/uk_ua.json b/src/main/resources/assets/viafabricplus/lang/uk_ua.json index 32360629..26c3e964 100644 --- a/src/main/resources/assets/viafabricplus/lang/uk_ua.json +++ b/src/main/resources/assets/viafabricplus/lang/uk_ua.json @@ -43,7 +43,6 @@ "general_settings.viafabricplus.load_skins_and_skulls_in_legacy_versions": "Завантажувати скіни та черепи на старих версіях", "general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions": "Симулювати дії інветаря на альфа версіях", - "bedrock_settings.viafabricplus.confirm_transfer_server_prompt": "Відкрити GUI підказку для підтвердження переміщення до іншого серверу", "bedrock_settings.viafabricplus.click_to_set_bedrock_account": "Нажміть, щоб встановити аккаунт для Bedrock", "debug_settings.viafabricplus.disable_sequencing": "Вимкнути послідовності", diff --git a/src/main/resources/assets/viafabricplus/lang/zh_cn.json b/src/main/resources/assets/viafabricplus/lang/zh_cn.json index 15624d1c..de4befc6 100644 --- a/src/main/resources/assets/viafabricplus/lang/zh_cn.json +++ b/src/main/resources/assets/viafabricplus/lang/zh_cn.json @@ -46,7 +46,6 @@ "general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions": "模拟Alpha版本的物品栏动作", "general_settings.viafabricplus.direct_connect_screen_button_orientation": "直接连接 界面的按钮位置", - "bedrock_settings.viafabricplus.confirm_transfer_server_prompt": "显示“确认转移到其他服务器”提示", "bedrock_settings.viafabricplus.click_to_set_bedrock_account": "点此连接到基岩版账户", "debug_settings.viafabricplus.queue_config_packets": "排列配置数据包", @@ -69,7 +68,6 @@ "authentication_settings.viafabricplus.automatically_select_cpe_when_using_classicube": "如果使用ClassicCube MP Pass,则强制CPE版本", "authentication_settings.viafabricplus.set_session_name_to_classicube_name": "如果使用ClassiCube,则将用户名显示为ClassiCube名称", - "visual_settings.viafabricplus.show_super_secret_settings": "显示“Super Secret Settings”(超级秘密设置)", "visual_settings.viafabricplus.disable_secure_chat_warning": "禁用安全聊天警告", "visual_settings.viafabricplus.hide_signature_indicator": "隐藏聊天签名提示", "visual_settings.viafabricplus.remove_newer_features_from_jigsaw_screen": "从§o拼图方块§r界面中移除新版本特性", diff --git a/src/main/resources/assets/viafabricplus/lang/zh_hk.json b/src/main/resources/assets/viafabricplus/lang/zh_hk.json index 73b07f2e..5f9fc3ec 100644 --- a/src/main/resources/assets/viafabricplus/lang/zh_hk.json +++ b/src/main/resources/assets/viafabricplus/lang/zh_hk.json @@ -46,7 +46,6 @@ "general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions": "模擬Alpha版本嘅物品欄動作", "general_settings.viafabricplus.direct_connect_screen_button_orientation": "直接連缐 熒幕嘅按鈕方位", - "bedrock_settings.viafabricplus.confirm_transfer_server_prompt": "打開GUI以確認切換到其它伺服器", "bedrock_settings.viafabricplus.click_to_set_bedrock_account": "點擊以設定基岩版帳戶", "debug_settings.viafabricplus.queue_config_packets": "排列配置數據包", @@ -69,7 +68,6 @@ "authentication_settings.viafabricplus.automatically_select_cpe_when_using_classicube": "如果使用 ClassicCube MP Pass,則強制 CPE 版本", "authentication_settings.viafabricplus.set_session_name_to_classicube_name": "如果使用 ClassiCube ,則顯示為 ClassiCube 名稱", - "visual_settings.viafabricplus.show_super_secret_settings": "顯示 “Super Secret Settings”(超級秘密設定)", "visual_settings.viafabricplus.disable_secure_chat_warning": "禁用安全聊天警告", "visual_settings.viafabricplus.hide_signature_indicator": "隱藏聊天簽名提示", "visual_settings.viafabricplus.remove_newer_features_from_jigsaw_screen": "從\u00a7o拼圖方塊\u00a7r介面中移除新版本特性", diff --git a/src/main/resources/assets/viafabricplus/lang/zh_tw.json b/src/main/resources/assets/viafabricplus/lang/zh_tw.json index 2eef460d..e71a31f3 100644 --- a/src/main/resources/assets/viafabricplus/lang/zh_tw.json +++ b/src/main/resources/assets/viafabricplus/lang/zh_tw.json @@ -46,7 +46,6 @@ "general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions": "模擬 Alpha 版本物品欄動作", "general_settings.viafabricplus.direct_connect_screen_button_orientation": "直接連缐 熒幕的按鈕方位", - "bedrock_settings.viafabricplus.confirm_transfer_server_prompt": "開啟提示視窗以確認轉換到其他伺服器", "bedrock_settings.viafabricplus.click_to_set_bedrock_account": "點擊以設定 Bedrock 版帳號", "debug_settings.viafabricplus.queue_config_packets": "佇列設定封包", @@ -69,7 +68,6 @@ "authentication_settings.viafabricplus.automatically_select_cpe_when_using_classicube": "如果使用 ClassiCube,強制使用 CPE 版本", "authentication_settings.viafabricplus.set_session_name_to_classicube_name": "如果使用 ClassiCube,偽造使用者名稱為 ClassiCube 名稱", - "visual_settings.viafabricplus.show_super_secret_settings": "顯示超級祕密設定(Super Secret Settings)", "visual_settings.viafabricplus.disable_secure_chat_warning": "停用受保護的聊天內容警告", "visual_settings.viafabricplus.hide_signature_indicator": "隱藏簽章指示器", "visual_settings.viafabricplus.remove_newer_features_from_jigsaw_screen": "從拼圖方塊畫面中移除較新的功能", diff --git a/src/main/resources/viafabricplus.mixins.json b/src/main/resources/viafabricplus.mixins.json index 7faa9fd3..0e07ba08 100644 --- a/src/main/resources/viafabricplus.mixins.json +++ b/src/main/resources/viafabricplus.mixins.json @@ -23,7 +23,7 @@ "base.integration.MixinRakSessionCodec", "base.perserverversion.MixinMultiplayerScreen", "base.perserverversion.MixinMultiplayerServerListPinger", - "base.perserverversion.MixinPerformanceLog", + "base.perserverversion.MixinMultiValueDebugSampleLogImpl", "base.perserverversion.MixinServerInfo", "compat.classic4j.MixinCCAuthenticationResponse", "compat.classic4j.MixinTextFieldWidget", @@ -40,7 +40,6 @@ "fixes.minecraft.MixinChatInputSuggestor", "fixes.minecraft.MixinClientCommandSource", "fixes.minecraft.MixinClientWorld", - "fixes.minecraft.MixinEnchantmentHelper", "fixes.minecraft.MixinFlowableFluid", "fixes.minecraft.MixinFontStorage", "fixes.minecraft.MixinGameOptions", @@ -112,38 +111,25 @@ "fixes.minecraft.entity.MixinSquidEntity", "fixes.minecraft.entity.MixinWolfEntity", "fixes.minecraft.item.MixinArmorItem", - "fixes.minecraft.item.MixinArmorMaterials", - "fixes.minecraft.item.MixinAxeItem", "fixes.minecraft.item.MixinBlockItem", "fixes.minecraft.item.MixinBowItem", "fixes.minecraft.item.MixinBrushItem", - "fixes.minecraft.item.MixinDrawContext", "fixes.minecraft.item.MixinEnderPearlItem", "fixes.minecraft.item.MixinEquipment", "fixes.minecraft.item.MixinFireworkRocketItem", "fixes.minecraft.item.MixinHeldItemRenderer", - "fixes.minecraft.item.MixinHoeItem", - "fixes.minecraft.item.MixinItem", "fixes.minecraft.item.MixinItemCooldownManager", "fixes.minecraft.item.MixinItemGroup_EntriesImpl", "fixes.minecraft.item.MixinItemGroups", "fixes.minecraft.item.MixinItemPlacementContext", "fixes.minecraft.item.MixinItemRenderer", - "fixes.minecraft.item.MixinItemStack", - "fixes.minecraft.item.MixinMiningToolItem", - "fixes.minecraft.item.MixinPickaxeItem", - "fixes.minecraft.item.MixinShearsItem", - "fixes.minecraft.item.MixinShovelItem", - "fixes.minecraft.item.MixinSwordItem", "fixes.minecraft.network.MixinChatMessageC2SPacket", "fixes.minecraft.network.MixinClientCommonNetworkHandler", "fixes.minecraft.network.MixinClientConfigurationNetworkHandler", "fixes.minecraft.network.MixinClientLoginNetworkHandler", "fixes.minecraft.network.MixinClientPlayerInteractionManager", "fixes.minecraft.network.MixinClientPlayNetworkHandler", - "fixes.minecraft.network.MixinCustomPayloadS2CPacket", "fixes.minecraft.network.MixinMultiplayerServerListPinger", - "fixes.minecraft.network.MixinPacketByteBuf", "fixes.minecraft.network.MixinUpdatePlayerAbilitiesC2SPacket", "fixes.minecraft.screen.MixinAbstractCommandBlockScreen", "fixes.minecraft.screen.MixinAbstractSignEditScreen", @@ -157,11 +143,9 @@ "fixes.minecraft.screen.MixinGameModeSelectionScreen_GameModeSelection", "fixes.minecraft.screen.MixinJigsawBlockScreen", "fixes.minecraft.screen.MixinMouseOptionsScreen", - "fixes.minecraft.screen.MixinOptionsScreen", "fixes.minecraft.screen.MixinScreen", "fixes.minecraft.screen.MixinStructureBlockScreen_1", "fixes.minecraft.screen.hud.MixinChatHud", - "fixes.minecraft.screen.hud.MixinInGameHud", "fixes.minecraft.screen.screenhandler.MixinAbstractFurnaceScreenHandler", "fixes.minecraft.screen.screenhandler.MixinBrewingStandScreenHandler_FuelSlot", "fixes.minecraft.screen.screenhandler.MixinCraftingScreenHandler",