From fe7af11906751edb58f4c0457654ef2a22a70699 Mon Sep 17 00:00:00 2001 From: Me <135455255+IcarussOne@users.noreply.github.com> Date: Sat, 13 Jan 2024 07:12:43 -0600 Subject: [PATCH] Particle Spawning Bugfix --- README.md | 1 + .../UTParticleSpawningMixin.java | 34 +++++++++++++++++++ .../UTServerWorldEventHandlerAccessor.java | 19 +++++++++++ .../UTPortalDuplicationFix.java | 4 +-- .../config/UTConfigBugfixes.java | 5 +++ .../universaltweaks/core/UTLoadingPlugin.java | 5 +++ .../soulboundvexes/UTSoulboundVexes.java | 2 +- ...mixins.bugfixes.misc.particlespawning.json | 7 ++++ 8 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 src/main/java/mod/acgaming/universaltweaks/bugfixes/misc/particlespawning/UTParticleSpawningMixin.java create mode 100644 src/main/java/mod/acgaming/universaltweaks/bugfixes/misc/particlespawning/UTServerWorldEventHandlerAccessor.java rename src/main/java/mod/acgaming/universaltweaks/bugfixes/world/{portalduplicationfixes => portal}/UTPortalDuplicationFix.java (87%) create mode 100644 src/main/resources/mixins.bugfixes.misc.particlespawning.json diff --git a/README.md b/README.md index 54c38f3a..a665419a 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ All changes are toggleable via config files. * **Model Gap:** Fixes transparent gaps in all 3D models of blocks and items * **Mount Desync:** Fixes mounts and boats sometimes disappearing after dismounting * **Packet Size:** Increases the packet size limit to account for large packets in modded environments +* **Particle Spawning:** Fixes various particle types not showing up on the client * **Piston Progress:** Properly saves the last state of pistons to tags * **Portal Duplication Fix:** Fixes duplication issues that can occur when entities travel through portals * **Shear Mooshroom Dupe:** Fixes a duplication exploit connected to shearing mooshrooms diff --git a/src/main/java/mod/acgaming/universaltweaks/bugfixes/misc/particlespawning/UTParticleSpawningMixin.java b/src/main/java/mod/acgaming/universaltweaks/bugfixes/misc/particlespawning/UTParticleSpawningMixin.java new file mode 100644 index 00000000..c3a965d1 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/bugfixes/misc/particlespawning/UTParticleSpawningMixin.java @@ -0,0 +1,34 @@ +package mod.acgaming.universaltweaks.bugfixes.misc.particlespawning.mixin; + +import java.util.Objects; + +import net.minecraft.util.EnumParticleTypes; +import net.minecraft.world.ServerWorldEventHandler; +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 mod.acgaming.universaltweaks.config.UTConfigBugfixes; + +// MC-10369, MC-93826 +// https://bugs.mojang.com/browse/MC-10369 +// https://bugs.mojang.com/browse/MC-93826 +// Courtesy of Fuzs, TheRandomLabs, fonnymunkey +@Mixin(ServerWorldEventHandler.class) +public abstract class UTParticleSpawningMixin +{ + /** + * Fixes particles not properly being spawned on the client + * Based on a patch by RandomPatches + * https://github.com/TheRandomLabs/RandomPatches/blob/1.12/src/main/java/com/therandomlabs/randompatches/patch/ServerWorldEventHandlerPatch.java + */ + @Inject(method = "spawnParticle(IZDDDDDD[I)V", at = @At("HEAD")) + public void utSpawnParticle(int particleID, boolean ignoreRange, double xCoord, double yCoord, double zCoord, double xSpeed, double ySpeed, double zSpeed, int[] parameters, CallbackInfo ci) + { + EnumParticleTypes particle = Objects.requireNonNull(EnumParticleTypes.getParticleFromId(particleID)); + if (particle == EnumParticleTypes.SPELL_MOB || particle == EnumParticleTypes.SPELL_MOB_AMBIENT || !UTConfigBugfixes.MISC.utParticleSpawningToggle) return; + if (parameters.length == particle.getArgumentCount()) + ((UTServerWorldEventHandlerAccessor) this).getWorld().spawnParticle(particle, xCoord, yCoord, zCoord, 0, xSpeed, ySpeed, zSpeed, 1.0, parameters); + } +} \ No newline at end of file diff --git a/src/main/java/mod/acgaming/universaltweaks/bugfixes/misc/particlespawning/UTServerWorldEventHandlerAccessor.java b/src/main/java/mod/acgaming/universaltweaks/bugfixes/misc/particlespawning/UTServerWorldEventHandlerAccessor.java new file mode 100644 index 00000000..d4ac63f3 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/bugfixes/misc/particlespawning/UTServerWorldEventHandlerAccessor.java @@ -0,0 +1,19 @@ +package mod.acgaming.universaltweaks.bugfixes.misc.particlespawning.mixin; + +import java.util.Objects; + +import net.minecraft.world.ServerWorldEventHandler; +import net.minecraft.world.WorldServer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +// MC-10369, MC-93826 +// https://bugs.mojang.com/browse/MC-10369 +// https://bugs.mojang.com/browse/MC-93826 +// Courtesy of Fuzs, TheRandomLabs, fonnymunkey +@Mixin(ServerWorldEventHandler.class) +public interface UTServerWorldEventHandlerAccessor +{ + @Accessor("world") + WorldServer getWorld(); +} \ No newline at end of file diff --git a/src/main/java/mod/acgaming/universaltweaks/bugfixes/world/portalduplicationfixes/UTPortalDuplicationFix.java b/src/main/java/mod/acgaming/universaltweaks/bugfixes/world/portal/UTPortalDuplicationFix.java similarity index 87% rename from src/main/java/mod/acgaming/universaltweaks/bugfixes/world/portalduplicationfixes/UTPortalDuplicationFix.java rename to src/main/java/mod/acgaming/universaltweaks/bugfixes/world/portal/UTPortalDuplicationFix.java index 23f0ec3c..668b7a95 100644 --- a/src/main/java/mod/acgaming/universaltweaks/bugfixes/world/portalduplicationfixes/UTPortalDuplicationFix.java +++ b/src/main/java/mod/acgaming/universaltweaks/bugfixes/world/portal/UTPortalDuplicationFix.java @@ -1,4 +1,4 @@ -package mod.acgaming.universaltweaks.bugfixes.world.portalduplicationfixes; +package mod.acgaming.universaltweaks.bugfixes.world.portal; import org.apache.logging.log4j.Level; import net.minecraft.entity.EntityLiving; @@ -18,7 +18,7 @@ public class UTPortalDuplicationFix @SubscribeEvent public static void dimensionChangeEvent(EntityTravelToDimensionEvent event) { - if (event.getEntity().world.isRemote || !(UTConfigBugfixes.WORLD.utPortalDuplicationFixToggle)) return; + if (event.getEntity().world.isRemote || !UTConfigBugfixes.WORLD.utPortalDuplicationFixToggle) return; if (event.getEntity() instanceof EntityLiving && !(event.getEntity() instanceof EntityPlayer)) { EntityLiving entity = (EntityLiving) event.getEntity(); diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java index 659e9b07..21260ad9 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigBugfixes.java @@ -308,6 +308,11 @@ public static class MiscCategory @Config.Comment("Prevents various crashes with Turkish locale") public boolean utLocaleToggle = true; + @Config.RequiresMcRestart + @Config.Name("Particle Spawning") + @Config.Comment("Fixes various particle types not showing up on the client") + public boolean utParticleSpawningToggle = true; + @Config.RequiresMcRestart @Config.Name("Packet Size") @Config.Comment diff --git a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java index 9d997035..afb17fc4 100644 --- a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java +++ b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java @@ -146,6 +146,7 @@ public List getMixinConfigs() configs.add("mixins.tweaks.misc.difficulty.server.json"); } // COMMON + configs.add("mixins.bugfixes.blocks.bed.json"); configs.add("mixins.bugfixes.blocks.comparatortiming.json"); configs.add("mixins.bugfixes.blocks.fallingblockdamage.json"); configs.add("mixins.bugfixes.blocks.hopper.boundingbox.json"); @@ -173,7 +174,9 @@ 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.enchantment.json"); configs.add("mixins.bugfixes.misc.packetsize.json"); + configs.add("mixins.bugfixes.misc.particlespawning.json"); configs.add("mixins.bugfixes.world.chunksaving.json"); configs.add("mixins.bugfixes.world.tileentities.json"); configs.add("mixins.tweaks.blocks.bedobstruction.json"); @@ -328,6 +331,8 @@ public boolean shouldMixinConfigQueue(String mixinConfig) return UTConfigBugfixes.MISC.utBlastProtectionKnockbackToggle; case "mixins.bugfixes.misc.packetsize.json": return UTConfigBugfixes.MISC.utPacketSize > 0x200000 && !spongeForgeLoaded && !randomPatchesLoaded; + case "mixins.tweaks.misc.particlespawning.json": + return UTConfigBugfixes.MISC.utParticleSpawningToggle; case "mixins.bugfixes.entities.ai.json": return UTConfigBugfixes.ENTITIES.utEntityAITasksToggle; case "mixins.bugfixes.entities.attackradius.json": diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/soulboundvexes/UTSoulboundVexes.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/soulboundvexes/UTSoulboundVexes.java index 2dc11c3e..c177a766 100644 --- a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/soulboundvexes/UTSoulboundVexes.java +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/soulboundvexes/UTSoulboundVexes.java @@ -16,7 +16,7 @@ public class UTSoulboundVexes @SubscribeEvent public static void soulboundVexesEvent(LivingUpdateEvent event) { - if (!(UTConfigTweaks.ENTITIES.utSoulboundVexesToggle)) return; + if (!UTConfigTweaks.ENTITIES.utSoulboundVexesToggle) return; if (event.getEntity() instanceof EntityVex) { diff --git a/src/main/resources/mixins.bugfixes.misc.particlespawning.json b/src/main/resources/mixins.bugfixes.misc.particlespawning.json new file mode 100644 index 00000000..e3f4ce86 --- /dev/null +++ b/src/main/resources/mixins.bugfixes.misc.particlespawning.json @@ -0,0 +1,7 @@ +{ + "package": "mod.acgaming.universaltweaks.bugfixes.misc.particlespawning.mixin", + "refmap": "universaltweaks.refmap.json", + "minVersion": "0.8", + "compatibilityLevel": "JAVA_8", + "mixins": ["UTParticleSpawningMixin", "UTServerWorldEventHandlerAccessor"] +} \ No newline at end of file