Skip to content

Commit a6f5972

Browse files
committed
no render particles
1 parent 89c4427 commit a6f5972

File tree

4 files changed

+85
-9
lines changed

4 files changed

+85
-9
lines changed

src/main/java/com/lambda/mixin/network/ClientPlayNetworkHandlerMixin.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,4 @@ public boolean onServerMetadata(ClientPlayNetworkHandler clientPlayNetworkHandle
103103
void injectVelocity(ExplosionS2CPacket packet, CallbackInfo ci) {
104104
if (Velocity.getExplosion() && Velocity.INSTANCE.isEnabled()) ci.cancel();
105105
}
106-
107-
/**
108-
* Cancels the world particle if {@link NoRender#getNoExplosion()} is true
109-
*/
110-
@Inject(method = "onExplosion(Lnet/minecraft/network/packet/s2c/play/ExplosionS2CPacket;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;addParticleClient(Lnet/minecraft/particle/ParticleEffect;DDDDDD)V"), cancellable = true)
111-
void injectParticles(ExplosionS2CPacket packet, CallbackInfo ci) {
112-
if (NoRender.getNoExplosion() && NoRender.INSTANCE.isEnabled()) ci.cancel();
113-
}
114106
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright 2025 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.mixin.render;
19+
20+
import com.lambda.module.modules.render.NoRender;
21+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
22+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
23+
import net.minecraft.client.particle.Particle;
24+
import net.minecraft.client.particle.ParticleManager;
25+
import net.minecraft.client.particle.ParticleTextureSheet;
26+
import net.minecraft.client.render.Camera;
27+
import net.minecraft.client.render.VertexConsumerProvider;
28+
import org.spongepowered.asm.mixin.Mixin;
29+
import org.spongepowered.asm.mixin.Unique;
30+
import org.spongepowered.asm.mixin.injection.At;
31+
32+
import java.util.LinkedList;
33+
import java.util.Queue;
34+
import java.util.stream.Collectors;
35+
36+
@Mixin(ParticleManager.class)
37+
public class ParticleManagerMixin {
38+
// prevents the particles from being stored and potential overhead. Downside being they need to spawn back in rather than just enabling rendering again
39+
// @Inject(method = "addParticle(Lnet/minecraft/client/particle/Particle;)V", at = @At("HEAD"), cancellable = true)
40+
// private void injectAddParticle(Particle particle, CallbackInfo ci) {
41+
// if (NoRender.shouldOmitParticle(particle)) ci.cancel();
42+
// }
43+
44+
@WrapOperation(method = "renderParticles(Lnet/minecraft/client/render/Camera;FLnet/minecraft/client/render/VertexConsumerProvider$Immediate;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/ParticleManager;renderParticles(Lnet/minecraft/client/render/Camera;FLnet/minecraft/client/render/VertexConsumerProvider$Immediate;Lnet/minecraft/client/particle/ParticleTextureSheet;Ljava/util/Queue;)V"))
45+
private void wrapRenderParticles(Camera camera, float tickProgress, VertexConsumerProvider.Immediate vertexConsumers, ParticleTextureSheet sheet, Queue<Particle> particles, Operation<Void> original) {
46+
original.call(camera, tickProgress, vertexConsumers, sheet, filterParticles(particles));
47+
}
48+
49+
@WrapOperation(method = "renderParticles(Lnet/minecraft/client/render/Camera;FLnet/minecraft/client/render/VertexConsumerProvider$Immediate;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/ParticleManager;renderCustomParticles(Lnet/minecraft/client/render/Camera;FLnet/minecraft/client/render/VertexConsumerProvider$Immediate;Ljava/util/Queue;)V"))
50+
private void wrapRenderParticles(Camera camera, float tickProgress, VertexConsumerProvider.Immediate vertexConsumers, Queue<Particle> particles, Operation<Void> original) {
51+
original.call(camera, tickProgress, vertexConsumers, filterParticles(particles));
52+
}
53+
54+
@Unique
55+
private Queue<Particle> filterParticles(Queue<Particle> particles) {
56+
return particles.stream().filter(particle ->
57+
!NoRender.shouldOmitParticle(particle)).collect(Collectors.toCollection(LinkedList::new)
58+
);
59+
}
60+
}

src/main/kotlin/com/lambda/module/modules/render/NoRender.kt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ package com.lambda.module.modules.render
1919

2020
import com.lambda.module.Module
2121
import com.lambda.module.tag.ModuleTag
22+
import com.lambda.util.reflections.scanResult
23+
import net.minecraft.client.particle.Particle
2224
import net.minecraft.client.render.BackgroundRenderer.StatusEffectFogModifier
2325
import net.minecraft.entity.effect.StatusEffects
2426

@@ -27,14 +29,35 @@ object NoRender : Module(
2729
description = "Disables rendering of certain things",
2830
tag = ModuleTag.RENDER,
2931
) {
32+
private val particleMap = mutableMapOf<String, String>().apply {
33+
val subClasses = scanResult
34+
.getSubclasses(Particle::class.java)
35+
.filter { !it.isAbstract }
36+
subClasses
37+
.forEach { particle ->
38+
val fullStr = particle.name
39+
if (!fullStr.startsWith("net.minecraft")) return@forEach
40+
val value = fullStr
41+
.replace("net.minecraft.client.particle.", "")
42+
.replace("$", " - ")
43+
.replace("Particle", "")
44+
.replace("(?<!\\s)[A-Z]".toRegex(), " $0")
45+
put(particle.simpleName, value)
46+
}
47+
} as Map<String, String>
48+
3049
@JvmStatic val noBlindness by setting("No Blindness", true)
3150
@JvmStatic val noDarkness by setting("No Darkness", true)
3251
@JvmStatic val noBurning by setting("No Burning Overlay", true)
3352
@JvmStatic val fireOverlayYOffset by setting("Fire Overlay Y Offset", -0.3, -0.8..0.0, 0.1) { !noBurning }
3453
@JvmStatic val noUnderwater by setting("No Underwater Overlay", true)
3554
@JvmStatic val noInWall by setting("No In Wall Overlay", true)
3655
@JvmStatic val noChatVerificationToast by setting("No Chat Verification Toast", true)
37-
@JvmStatic val noExplosion by setting("No Explosions", true)
56+
@JvmStatic val particles by setting("Particles", particleMap.values.toSet(), description = "Particles to omit from rendering")
57+
58+
@JvmStatic
59+
fun shouldOmitParticle(particle: Particle) =
60+
isEnabled && particleMap[particle.javaClass.simpleName] in particles
3861

3962
@JvmStatic
4063
fun shouldAcceptFog(modifier: StatusEffectFogModifier) =

src/main/resources/lambda.mixins.common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"render.InGameOverlayRendererMixin",
4545
"render.LightmapTextureManagerMixin",
4646
"render.LivingEntityRendererMixin",
47+
"render.ParticleManagerMixin",
4748
"render.PlayerListHudMixin",
4849
"render.RenderLayersMixin",
4950
"render.ScreenHandlerMixin",

0 commit comments

Comments
 (0)