From 33c62f734593bbd650b02c1c970b5002c0de0501 Mon Sep 17 00:00:00 2001 From: Me <135455255+IcarussOne@users.noreply.github.com> Date: Sun, 25 Feb 2024 01:11:16 -0600 Subject: [PATCH 1/2] Untipped Arrow Particles Bugfix -MC-107941 --- README.md | 1 + .../arrow/mixin/UTEntityTippedArrowMixin.java | 35 +++++++++++++++++++ .../config/UTConfigBugfixes.java | 5 +++ .../universaltweaks/core/UTLoadingPlugin.java | 3 ++ ...fixes.entities.untippedarrowparticles.json | 7 ++++ 5 files changed, 51 insertions(+) create mode 100644 src/main/java/mod/acgaming/universaltweaks/bugfixes/entities/arrow/mixin/UTEntityTippedArrowMixin.java create mode 100644 src/main/resources/mixins.bugfixes.entities.untippedarrowparticles.json diff --git a/README.md b/README.md index 53c6012e..dc83d66f 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ All changes are toggleable via config files. * **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 +* **Untipped Arrow Particles:** Fixes untipped arrows emitting blue tipped arrow particles upon reloading a world * **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/entities/arrow/mixin/UTEntityTippedArrowMixin.java b/src/main/java/mod/acgaming/universaltweaks/bugfixes/entities/arrow/mixin/UTEntityTippedArrowMixin.java new file mode 100644 index 00000000..32e07fb1 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/bugfixes/entities/arrow/mixin/UTEntityTippedArrowMixin.java @@ -0,0 +1,35 @@ +package mod.acgaming.universaltweaks.bugfixes.entities.arrow.mixin; + +import net.minecraft.entity.projectile.EntityTippedArrow; +import net.minecraft.init.PotionTypes; +import net.minecraft.potion.PotionEffect; +import net.minecraft.potion.PotionType; + +import java.util.Set; + +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-107941 +// https://bugs.mojang.com/browse/MC-107941 +// Courtesy of fonnymunkey +@Mixin(EntityTippedArrow.class) +public abstract class UTEntityTippedArrowMixin +{ + @Shadow + private PotionType potion; + @Shadow + @Final + private Set customPotionEffects; + + @Redirect(method = "refreshColor", at = @At(value = "INVOKE", target = "Ljava/lang/Integer;valueOf(I)Ljava/lang/Integer;")) + public Integer rlmixins_vanillaEntityTippedArrow_refreshColor(int i) + { + if (UTConfigBugfixes.ENTITIES.utUntippedArrowParticlesToggle && potion == PotionTypes.EMPTY && customPotionEffects.isEmpty()) return -1; + return i; + } +} \ 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 32396c83..b11873c9 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java @@ -256,6 +256,11 @@ public static class EntitiesCategory @Config.Name("Skeleton Aim") @Config.Comment("Fixes skeletons not looking at their targets when strafing") public boolean utSkeletonAimToggle = true; + + @Config.RequiresMcRestart + @Config.Name("Untipped Arrow Particles") + @Config.Comment("Fixes untipped arrows emitting blue tipped arrow particles upon reloading a world") + public boolean utUntippedArrowParticlesToggle = true; @Config.RequiresMcRestart @Config.Name("Villager Mantle Hoods") diff --git a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java index a583ada7..7d3df0ab 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.entities.untippedarrowparticles.json"); configs.add("mixins.bugfixes.misc.crafteditemstatistics.json"); configs.add("mixins.bugfixes.misc.enchantment.json"); configs.add("mixins.bugfixes.misc.packetsize.json"); @@ -404,6 +405,8 @@ public boolean shouldMixinConfigQueue(String mixinConfig) return UTConfigBugfixes.ENTITIES.utEntitySuffocationToggle; case "mixins.bugfixes.entities.tracker.json": return UTConfigBugfixes.ENTITIES.utEntityTrackerToggle && !spongeForgeLoaded; + case "mixins.bugfixes.entities.untippedarrowparticles.json": + return UTConfigBugfixes.ENTITIES.utUntippedArrowParticlesToggle; case "mixins.bugfixes.world.chunksaving.json": return UTConfigBugfixes.WORLD.utChunkSavingToggle && !spongeForgeLoaded; case "mixins.bugfixes.world.tileentities.json": diff --git a/src/main/resources/mixins.bugfixes.entities.untippedarrowparticles.json b/src/main/resources/mixins.bugfixes.entities.untippedarrowparticles.json new file mode 100644 index 00000000..1298b162 --- /dev/null +++ b/src/main/resources/mixins.bugfixes.entities.untippedarrowparticles.json @@ -0,0 +1,7 @@ +{ + "package": "mod.acgaming.universaltweaks.bugfixes.entities.arrow.mixin", + "refmap": "universaltweaks.refmap.json", + "minVersion": "0.8", + "compatibilityLevel": "JAVA_8", + "mixins": ["UTEntityTippedArrowMixin"] +} \ No newline at end of file From 96677a474acb09a06893d2d38b8ae079b7bf9a28 Mon Sep 17 00:00:00 2001 From: Me <135455255+IcarussOne@users.noreply.github.com> Date: Sun, 25 Feb 2024 01:14:18 -0600 Subject: [PATCH 2/2] Formatting --- .../bugfixes/entities/arrow/mixin/UTEntityTippedArrowMixin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/mod/acgaming/universaltweaks/bugfixes/entities/arrow/mixin/UTEntityTippedArrowMixin.java b/src/main/java/mod/acgaming/universaltweaks/bugfixes/entities/arrow/mixin/UTEntityTippedArrowMixin.java index 32e07fb1..553327cd 100644 --- a/src/main/java/mod/acgaming/universaltweaks/bugfixes/entities/arrow/mixin/UTEntityTippedArrowMixin.java +++ b/src/main/java/mod/acgaming/universaltweaks/bugfixes/entities/arrow/mixin/UTEntityTippedArrowMixin.java @@ -27,7 +27,7 @@ public abstract class UTEntityTippedArrowMixin private Set customPotionEffects; @Redirect(method = "refreshColor", at = @At(value = "INVOKE", target = "Ljava/lang/Integer;valueOf(I)Ljava/lang/Integer;")) - public Integer rlmixins_vanillaEntityTippedArrow_refreshColor(int i) + public Integer utTippedArrowRefreshColor(int i) { if (UTConfigBugfixes.ENTITIES.utUntippedArrowParticlesToggle && potion == PotionTypes.EMPTY && customPotionEffects.isEmpty()) return -1; return i;