Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Particle Spawning Bugfix #358

Merged
merged 1 commit into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public List<String> 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");
Expand Down Expand Up @@ -173,7 +174,9 @@ public List<String> 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");
Expand Down Expand Up @@ -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":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/mixins.bugfixes.misc.particlespawning.json
Original file line number Diff line number Diff line change
@@ -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"]
}