From 30f1fb19d8d01bed271d7de9b95e2c78886e5037 Mon Sep 17 00:00:00 2001 From: Me <135455255+IcarussOne@users.noreply.github.com> Date: Tue, 6 Feb 2024 08:41:23 -0600 Subject: [PATCH 1/3] Spectator Menu Bugfix --- README.md | 1 + .../mixin/UTPlayerMenuObjectMixin.java | 42 +++++++++++++++++++ .../config/UTConfigBugfixes.java | 5 +++ .../universaltweaks/core/UTLoadingPlugin.java | 3 ++ .../mixins.bugfixes.misc.spectatormenu.json | 7 ++++ 5 files changed, 58 insertions(+) create mode 100644 src/main/java/mod/acgaming/universaltweaks/bugfixes/misc/spectatormenu/mixin/UTPlayerMenuObjectMixin.java create mode 100644 src/main/resources/mixins.bugfixes.misc.spectatormenu.json diff --git a/README.md b/README.md index 91bd0b62..b7e7b39a 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ All changes are toggleable via config files. * **Shear Mooshroom Dupe:** Fixes a duplication exploit connected to shearing mooshrooms * **Skeleton Aim:** Fixes skeletons not looking at their targets when strafing * **Sleep Resets Weather:** Fixes sleeping always resetting rain and thunder times +* **Spectator Menu:** Fixes the spectator menu not showing player skins * **Tile Entity Map:** Replaces the chunk position data table to prevent tile entity related issues * **Villager Mantle:** Returns missing hoods to villager mantles * **Witch Huts:** Fixes witch hut structure data not accounting for the height it is generated at diff --git a/src/main/java/mod/acgaming/universaltweaks/bugfixes/misc/spectatormenu/mixin/UTPlayerMenuObjectMixin.java b/src/main/java/mod/acgaming/universaltweaks/bugfixes/misc/spectatormenu/mixin/UTPlayerMenuObjectMixin.java new file mode 100644 index 00000000..aa5576da --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/bugfixes/misc/spectatormenu/mixin/UTPlayerMenuObjectMixin.java @@ -0,0 +1,42 @@ +package mod.acgaming.universaltweaks.bugfixes.misc.spectator.mixin; + +import com.mojang.authlib.GameProfile; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.spectator.PlayerMenuObject; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.util.ResourceLocation; +import mod.acgaming.universaltweaks.config.UTConfigBugfixes; +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; + +// MC-125157 +// https://bugs.mojang.com/browse/MC-125157 +// Courtesy of mrgrim +@Mixin(PlayerMenuObject.class) +public abstract class UTPlayerMenuObjectMixin +{ + @Shadow + @Final + private GameProfile profile; + + @Redirect(method = "renderIcon", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/texture/TextureManager;bindTexture(Lnet/minecraft/util/ResourceLocation;)V")) + private void redirectbindTexture(TextureManager textureManager, ResourceLocation resource) + { + if (UTConfigBugfixes.MISC.utSpectatorMenuToggle) + { + final Minecraft mc = Minecraft.getMinecraft(); + final NetworkPlayerInfo npi = mc.player.connection.getPlayerInfo(this.profile.getName()); + if (npi != null) + { + mc.getTextureManager().bindTexture(npi.getLocationSkin()); + } + } else + { + textureManager.bindTexture(resource); + } + } +} \ No newline at end of file diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java index 56a300a4..6b8f9d52 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java @@ -327,6 +327,11 @@ public static class MiscCategory @Config.Name("Potion Amplifier Visibility") @Config.Comment("Fixes potion effects not displaying their level above 'IV'") public boolean utPotionAmplifierVisibilityToggle = true; + + @Config.RequiresMcRestart + @Config.Name("Spectator Menu") + @Config.Comment("Fixes the spectator menu not showing player skins") + public boolean utSpectatorMenuToggle = true; @Config.RequiresMcRestart @Config.Name("Packet Size") diff --git a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java index 5ce71635..64a32a4f 100644 --- a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java +++ b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java @@ -114,6 +114,7 @@ public List getMixinConfigs() configs.add("mixins.bugfixes.misc.modelgap.json"); configs.add("mixins.bugfixes.misc.potionamplifier.json"); configs.add("mixins.bugfixes.misc.smoothlighting.json"); + configs.add("mixins.bugfixes.misc.spectatormenu.json"); configs.add("mixins.bugfixes.misc.startup.json"); configs.add("mixins.bugfixes.world.frustumculling.json"); configs.add("mixins.tweaks.entities.autojump.json"); @@ -280,6 +281,8 @@ public boolean shouldMixinConfigQueue(String mixinConfig) return UTConfigBugfixes.MISC.utPotionAmplifierVisibilityToggle; case "mixins.bugfixes.misc.smoothlighting.json": return UTConfigBugfixes.MISC.utAccurateSmoothLighting; + case "mixins.bugfixes.misc.spectatormenu.json": + return UTConfigBugfixes.MISC.utSpectatorMenuToggle; case "mixins.bugfixes.misc.startup.json": return UTConfigTweaks.PERFORMANCE.utFasterBackgroundStartupToggle; case "mixins.bugfixes.world.frustumculling.json": diff --git a/src/main/resources/mixins.bugfixes.misc.spectatormenu.json b/src/main/resources/mixins.bugfixes.misc.spectatormenu.json new file mode 100644 index 00000000..da1e25b0 --- /dev/null +++ b/src/main/resources/mixins.bugfixes.misc.spectatormenu.json @@ -0,0 +1,7 @@ +{ + "package": "mod.acgaming.universaltweaks.bugfixes.misc.spectatormenu.mixin", + "refmap": "universaltweaks.refmap.json", + "minVersion": "0.8", + "compatibilityLevel": "JAVA_8", + "client": ["UTPlayerMenuObjectMixin"] +} \ No newline at end of file From 469cacec79e0253ef7a6bde17a567378c57d40d9 Mon Sep 17 00:00:00 2001 From: Me <135455255+IcarussOne@users.noreply.github.com> Date: Tue, 6 Feb 2024 09:09:14 -0600 Subject: [PATCH 2/3] Crafted Item Statistics Bugfix --- README.md | 1 + .../mixin/UTSlotCraftingMixin.java | 40 +++++++++++++++++++ .../mixin/UTPlayerMenuObjectMixin.java | 2 +- .../config/UTConfigBugfixes.java | 5 +++ .../universaltweaks/core/UTLoadingPlugin.java | 3 ++ ...s.bugfixes.misc.crafteditemstatistics.json | 7 ++++ 6 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/main/java/mod/acgaming/universaltweaks/bugfixes/misc/crafteditemstatistics/mixin/UTSlotCraftingMixin.java create mode 100644 src/main/resources/mixins.bugfixes.misc.crafteditemstatistics.json diff --git a/README.md b/README.md index b7e7b39a..62cfbf70 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ All changes are toggleable via config files. * **Chunk Saving:** Fixes loading of outdated chunks to prevent duplications, deletions and data corruption * **Comparator Timing:** Fixes inconsistent delays of comparators to prevent redstone timing issues * **Concurrent Entity AI Tasks:** Replaces linked entity AI task sets with concurrent sets to avoid mod exception concerning entity AI +* **Crafted Item Statistics:** Fixes crafted item statistics not increasing correctly when items are crafted with shift-click or drop methods * **Death Time:** Fixes corrupted entities exceeding the allowed death time * **Depth Mask:** Fixes entity and particle rendering issues by enabling depth buffer writing * **Destroy Entity Packets:** Fixes lag caused by dead entities by sending additional packets when the player is not alive diff --git a/src/main/java/mod/acgaming/universaltweaks/bugfixes/misc/crafteditemstatistics/mixin/UTSlotCraftingMixin.java b/src/main/java/mod/acgaming/universaltweaks/bugfixes/misc/crafteditemstatistics/mixin/UTSlotCraftingMixin.java new file mode 100644 index 00000000..dc4b4af6 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/bugfixes/misc/crafteditemstatistics/mixin/UTSlotCraftingMixin.java @@ -0,0 +1,40 @@ +package mod.acgaming.universaltweaks.bugfixes.misc.crafteditemstatistics.mixin; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.inventory.SlotCrafting; +import net.minecraft.item.ItemStack; +import mod.acgaming.universaltweaks.config.UTConfigBugfixes; +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.CallbackInfoReturnable; + +// MC-65198, MC-161869 +// https://bugs.mojang.com/browse/MC-65198 +// https://bugs.mojang.com/browse/MC-161869 +// Courtesy of mrgrim +@Mixin(SlotCrafting.class) +public abstract class UTSlotCraftingMixin extends Slot +{ + @Shadow + private int amountCrafted; + + public UTSlotCraftingMixin(IInventory inventoryIn, int index, int xPosition, int yPosition) + { + super(inventoryIn, index, xPosition, yPosition); + } + + @Inject(method = "decrStackSize", at = @At("HEAD"), cancellable = true) + private void utFixCraftingStats(int amount, CallbackInfoReturnable cir) + { + if (UTConfigBugfixes.MISC.utCraftedItemStatisticsToggle) + { + ItemStack ret = super.decrStackSize(amount); + this.amountCrafted += ret.getCount(); + + cir.setReturnValue(ret); + } + } +} \ No newline at end of file diff --git a/src/main/java/mod/acgaming/universaltweaks/bugfixes/misc/spectatormenu/mixin/UTPlayerMenuObjectMixin.java b/src/main/java/mod/acgaming/universaltweaks/bugfixes/misc/spectatormenu/mixin/UTPlayerMenuObjectMixin.java index aa5576da..20960d29 100644 --- a/src/main/java/mod/acgaming/universaltweaks/bugfixes/misc/spectatormenu/mixin/UTPlayerMenuObjectMixin.java +++ b/src/main/java/mod/acgaming/universaltweaks/bugfixes/misc/spectatormenu/mixin/UTPlayerMenuObjectMixin.java @@ -24,7 +24,7 @@ public abstract class UTPlayerMenuObjectMixin private GameProfile profile; @Redirect(method = "renderIcon", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/texture/TextureManager;bindTexture(Lnet/minecraft/util/ResourceLocation;)V")) - private void redirectbindTexture(TextureManager textureManager, ResourceLocation resource) + private void utRedirectBindTexture(TextureManager textureManager, ResourceLocation resource) { if (UTConfigBugfixes.MISC.utSpectatorMenuToggle) { diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java index 6b8f9d52..32396c83 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java @@ -303,6 +303,11 @@ public static class MiscCategory @Config.Name("Blast Protection Knockback") @Config.Comment("Fixes the blast protection enchantment not reducing knockback from explosions except at very high levels") public boolean utBlastProtectionKnockbackToggle = false; + + @Config.RequiresMcRestart + @Config.Name("Crafted Item Statistics") + @Config.Comment("Fixes crafted item statistics not increasing correctly when items are crafted with shift-click or drop methods") + public boolean utCraftedItemStatisticsToggle = true; @Config.RequiresMcRestart @Config.Name("Depth Mask") diff --git a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java index 64a32a4f..eb61cc67 100644 --- a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java +++ b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java @@ -179,6 +179,7 @@ public List getMixinConfigs() configs.add("mixins.bugfixes.entities.skeletonaim.json"); configs.add("mixins.bugfixes.entities.suffocation.json"); configs.add("mixins.bugfixes.entities.tracker.json"); + configs.add("mixins.bugfixes.misc.crafteditemstatistics.json"); configs.add("mixins.bugfixes.misc.enchantment.json"); configs.add("mixins.bugfixes.misc.packetsize.json"); configs.add("mixins.bugfixes.misc.particlespawning.json"); @@ -355,6 +356,8 @@ public boolean shouldMixinConfigQueue(String mixinConfig) return UTConfigBugfixes.BLOCKS.utPistonRetractionToggle; case "mixins.bugfixes.blocks.bed.json": return UTConfigBugfixes.BLOCKS.utSleepResetsWeatherToggle; + case "mixins.bugfixes.misc.crafteditemstatistics.json": + return UTConfigBugfixes.MISC.utCraftedItemStatisticsToggle; case "mixins.bugfixes.misc.enchantment.json": return UTConfigBugfixes.MISC.utBlastProtectionKnockbackToggle; case "mixins.bugfixes.misc.packetsize.json": diff --git a/src/main/resources/mixins.bugfixes.misc.crafteditemstatistics.json b/src/main/resources/mixins.bugfixes.misc.crafteditemstatistics.json new file mode 100644 index 00000000..c4bd2cd9 --- /dev/null +++ b/src/main/resources/mixins.bugfixes.misc.crafteditemstatistics.json @@ -0,0 +1,7 @@ +{ + "package": "mod.acgaming.universaltweaks.bugfixes.misc.crafteditemstatistics.mixin", + "refmap": "universaltweaks.refmap.json", + "minVersion": "0.8", + "compatibilityLevel": "JAVA_8", + "mixins": ["UTSlotCraftingMixin"] +} \ No newline at end of file From fa75acdb61b6decd74fb5bbee81bb4b57c61e63b Mon Sep 17 00:00:00 2001 From: Me <135455255+IcarussOne@users.noreply.github.com> Date: Tue, 6 Feb 2024 15:23:49 -0600 Subject: [PATCH 3/3] Corrections --- .../blocks/piston/retraction/mixin/UTPistonBaseBlockMixin.java | 2 +- .../mod/acgaming/universaltweaks/config/UTConfigTweaks.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/mod/acgaming/universaltweaks/bugfixes/blocks/piston/retraction/mixin/UTPistonBaseBlockMixin.java b/src/main/java/mod/acgaming/universaltweaks/bugfixes/blocks/piston/retraction/mixin/UTPistonBaseBlockMixin.java index 025d9277..f404ce84 100644 --- a/src/main/java/mod/acgaming/universaltweaks/bugfixes/blocks/piston/retraction/mixin/UTPistonBaseBlockMixin.java +++ b/src/main/java/mod/acgaming/universaltweaks/bugfixes/blocks/piston/retraction/mixin/UTPistonBaseBlockMixin.java @@ -15,7 +15,7 @@ // MC-88959 // https://bugs.mojang.com/browse/MC-88959 -// Courtesy of mrgrim +// Courtesy of Nessiesson @Mixin(BlockPistonBase.class) public abstract class UTPistonBaseBlockMixin { diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java index bba8a656..a9524585 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java @@ -1027,7 +1027,7 @@ public static class ItemEntitiesCategory @Config.Name("[17] Slowed Movement") @Config.Comment("Slows how often item entities update their position to improve performance") - public boolean utIEUpdateToggle = true; + public boolean utIEUpdateToggle = false; } public static class MendingCategory