NoLag: Completely disable fireworks from being added, also new World & Chunk Patch

This commit is contained in:
noil 2021-03-15 19:39:58 -04:00
parent 1b65dd928f
commit e32c74f67d
6 changed files with 109 additions and 6 deletions

View File

@ -1,12 +1,13 @@
package me.rigamortis.seppuku.api.event.world;
import me.rigamortis.seppuku.api.event.EventCancellable;
import net.minecraft.entity.Entity;
/**
* Author Seth
* 11/10/2019 @ 3:30 PM.
*/
public class EventAddEntity {
public class EventAddEntity extends EventCancellable {
private Entity entity;

View File

@ -522,6 +522,7 @@ public final class ModuleListComponent extends ResizableHudComponent {
}
};
components.add(valueButton);
this.addComponentToButtons(valueButton);
} else if (value.getValue() instanceof Number) {
/*TextComponent valueNumberText = new TextComponent(value.getName(), value.getValue().toString(), true);
valueNumberText.setTooltipText(value.getDesc() + " " + ChatFormatting.GRAY + "(" + value.getMin() + " - " + value.getMax() + ")");

View File

@ -3,6 +3,7 @@ package me.rigamortis.seppuku.impl.module.render;
import me.rigamortis.seppuku.api.event.EventStageable;
import me.rigamortis.seppuku.api.event.network.EventReceivePacket;
import me.rigamortis.seppuku.api.event.render.*;
import me.rigamortis.seppuku.api.event.world.EventAddEntity;
import me.rigamortis.seppuku.api.event.world.EventLightUpdate;
import me.rigamortis.seppuku.api.event.world.EventSpawnParticle;
import me.rigamortis.seppuku.api.module.Module;
@ -51,6 +52,7 @@ public final class NoLagModule extends Module {
public final Value<Boolean> tnt = new Value<Boolean>("TNT", new String[]{"Dynamite", "explosives", "tn"}, "Disables the rendering of (primed) TNT.", false);
public final Value<Boolean> torches = new Value<Boolean>("Torches", new String[]{"Torch", "t"}, "Disables the rendering of torches.", false);
public final Value<Boolean> fireworks = new Value<Boolean>("Fireworks", new String[]{"FireW", "Fworks", "fw"}, "Disables the rendering of fireworks.", false);
public final Value<Boolean> fireworksEffects = new Value<Boolean>("FireworksEffects", new String[]{"FireWE", "Fworkfx", "fwe"}, "Disables the rendering of firework effects.", false);
public final Value<Boolean> redstone = new Value<Boolean>("Redstone", new String[]{"Red", "r"}, "Disables the rendering of redstone dust.", false);
public final Value<Boolean> redstoneTorch = new Value<Boolean>("RedstoneTorch", new String[]{"RedTorch", "rt"}, "Disables the rendering of redstone torches.", false);
public final Value<Boolean> redstoneLogic = new Value<Boolean>("RedstoneLogic", new String[]{"RedLogic", "rl"}, "Disables the rendering of redstone logic blocks.", false);
@ -208,7 +210,7 @@ public final class NoLagModule extends Module {
@Listener
public void onSpawnEffectParticle(EventSpawnEffect event) {
if (this.fireworks.getValue()) {
if (this.fireworksEffects.getValue()) {
if (event.getParticleID() == EnumParticleTypes.FIREWORKS_SPARK.getParticleID() ||
event.getParticleID() == EnumParticleTypes.EXPLOSION_HUGE.getParticleID() ||
event.getParticleID() == EnumParticleTypes.EXPLOSION_LARGE.getParticleID() ||
@ -220,7 +222,7 @@ public final class NoLagModule extends Module {
@Listener
public void onAddEffect(EventAddEffect event) {
if (this.fireworks.getValue()) {
if (this.fireworksEffects.getValue()) {
if (event.getParticle() instanceof ParticleFirework.Starter ||
event.getParticle() instanceof ParticleFirework.Spark ||
event.getParticle() instanceof ParticleFirework.Overlay) {
@ -242,4 +244,13 @@ public final class NoLagModule extends Module {
event.setCanceled(true);
}
}
@Listener
public void onEntityAdd(EventAddEntity event) {
if (this.fireworks.getValue()) {
if (event.getEntity() instanceof EntityFireworkRocket) {
event.setCanceled(true);
}
}
}
}

View File

@ -1,11 +1,13 @@
package me.rigamortis.seppuku.impl.patch;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.event.world.EventAddEntity;
import me.rigamortis.seppuku.api.event.world.EventChunk;
import me.rigamortis.seppuku.api.patch.ClassPatch;
import me.rigamortis.seppuku.api.patch.MethodPatch;
import me.rigamortis.seppuku.api.util.ASMUtil;
import me.rigamortis.seppuku.impl.management.PatchManager;
import net.minecraft.entity.Entity;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.*;
import team.stiff.pomelo.EventManager;
@ -44,6 +46,31 @@ public final class ChunkPatch extends ClassPatch {
methodNode.instructions.insertBefore(ASMUtil.bottom(methodNode), insnList);
}
// public void addEntity(Entity entityIn) {
// public addEntity(Lnet/minecraft/entity/Entity;)V
// public void a(vg) {
@MethodPatch(
mcpName = "addEntity",
notchName = "a",
mcpDesc = "(Lnet/minecraft/entity/Entity;)V",
notchDesc = "(Lvg;)V")
public void addEntity(MethodNode methodNode, PatchManager.Environment env) {
final InsnList insnList = new InsnList();
insnList.add(new VarInsnNode(ALOAD, 1));
insnList.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(this.getClass()), "onEntityAddedHook", env == PatchManager.Environment.IDE ? "(Lnet/minecraft/entity/Entity;)Z" : "(Lvg;)Z", false));
final LabelNode jmp = new LabelNode();
insnList.add(new JumpInsnNode(IFEQ, jmp));
insnList.add(new InsnNode(RETURN));
insnList.add(jmp);
methodNode.instructions.insert(insnList);
}
public static boolean onEntityAddedHook(Entity entity) {
final EventAddEntity eventAddEntity = new EventAddEntity(entity);
Seppuku.INSTANCE.getEventManager().dispatchEvent(eventAddEntity);
return eventAddEntity.isCanceled();
}
/**
* // access flags 0x9
* public static handleChunkDataHook(Lnet/minecraft/world/chunk/Chunk;)V

View File

@ -8,6 +8,7 @@ import me.rigamortis.seppuku.api.patch.ClassPatch;
import me.rigamortis.seppuku.api.patch.MethodPatch;
import me.rigamortis.seppuku.impl.management.PatchManager;
import net.minecraft.client.particle.Particle;
import net.minecraft.util.EnumParticleTypes;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.*;
@ -57,6 +58,62 @@ public class ParticleManagerPatch extends ClassPatch {
return event.isCanceled();
}
/*
// access flags 0x1
public emitParticleAtEntity(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/EnumParticleTypes;)V
// access flags 0x1
public emitParticleAtEntity(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/EnumParticleTypes;I)V
*/
// @MethodPatch(
// mcpName = "emitParticleAtEntity",
// notchName = "a",
// mcpDesc = "(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/EnumParticleTypes;)V",
// notchDesc = "(Lvg;Lfj;)V")
// public void emitParticleAtEntity1(MethodNode methodNode, PatchManager.Environment env) {
// //create a list of instructions
// final InsnList insnList = new InsnList();
// //aload in our Particle effect
// insnList.add(new VarInsnNode(ALOAD, 2));
// //call our hook function
// insnList.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(this.getClass()), "emitParticleAtEntityHook", env == PatchManager.Environment.IDE ? "(Lnet/minecraft/util/EnumParticleTypes;)Z" : "(Lfj;)Z", false));
// //create a label to jump to
// final LabelNode jmp = new LabelNode();
// //add "if equals"
// insnList.add(new JumpInsnNode(IFEQ, jmp));
// //return so the rest of the function doesn't get called
// insnList.add(new InsnNode(RETURN));
// //add our label
// insnList.add(jmp);
// //insert the list of instructs at the top of the function
// methodNode.instructions.insert(insnList);
// }
//
// @MethodPatch(
// mcpName = "emitParticleAtEntity",
// notchName = "a",
// mcpDesc = "(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/EnumParticleTypes;I)V",
// notchDesc = "(Lvg;Lfj;I)V")
// public void emitParticleAtEntity2(MethodNode methodNode, PatchManager.Environment env) {
// //create a list of instructions
// final InsnList insnList = new InsnList();
// //aload in our Particle effect
// insnList.add(new VarInsnNode(ALOAD, 2));
// //call our hook function
// insnList.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(this.getClass()), "emitParticleAtEntityHook", env == PatchManager.Environment.IDE ? "(Lnet/minecraft/util/EnumParticleTypes;)Z" : "(Lfj;)Z", false));
// //create a label to jump to
// final LabelNode jmp = new LabelNode();
// //add "if equals"
// insnList.add(new JumpInsnNode(IFEQ, jmp));
// //return so the rest of the function doesn't get called
// insnList.add(new InsnNode(RETURN));
// //add our label
// insnList.add(jmp);
// //insert the list of instructs at the top of the function
// methodNode.instructions.insert(insnList);
// }
// public Particle spawnEffectParticle(int particleId, double xCoord, double yCoord, double zCoord, double xSpeed, double ySpeed, double zSpeed, int... parameters) {
// public btf a(int , double d1, double d2, double d3, double d4, double d5, double d6, int... arrayOfInt)
// public varargs spawnEffectParticle(IDDDDDD[I)Lnet/minecraft/client/particle/Particle;

View File

@ -112,12 +112,18 @@ public final class WorldPatch extends ClassPatch {
public void onEntityAdded(MethodNode methodNode, PatchManager.Environment env) {
final InsnList list = new InsnList();
list.add(new VarInsnNode(ALOAD, 1));
list.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(this.getClass()), "onEntityAddedHook", env == PatchManager.Environment.IDE ? "(Lnet/minecraft/entity/Entity;)V" : "(Lvg;)V", false));
list.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(this.getClass()), "onEntityAddedHook", env == PatchManager.Environment.IDE ? "(Lnet/minecraft/entity/Entity;)Z" : "(Lvg;)Z", false));
final LabelNode jmp = new LabelNode();
list.add(new JumpInsnNode(IFEQ, jmp));
list.add(new InsnNode(RETURN));
list.add(jmp);
methodNode.instructions.insert(list);
}
public static void onEntityAddedHook(Entity entity) {
Seppuku.INSTANCE.getEventManager().dispatchEvent(new EventAddEntity(entity));
public static boolean onEntityAddedHook(Entity entity) {
final EventAddEntity eventAddEntity = new EventAddEntity(entity);
Seppuku.INSTANCE.getEventManager().dispatchEvent(eventAddEntity);
return eventAddEntity.isCanceled();
}
@MethodPatch(