diff --git a/src/main/java/me/rigamortis/seppuku/api/event/render/EventAddEffect.java b/src/main/java/me/rigamortis/seppuku/api/event/render/EventAddEffect.java new file mode 100644 index 0000000..4b0bf4c --- /dev/null +++ b/src/main/java/me/rigamortis/seppuku/api/event/render/EventAddEffect.java @@ -0,0 +1,24 @@ +package me.rigamortis.seppuku.api.event.render; + +import me.rigamortis.seppuku.api.event.EventCancellable; +import net.minecraft.client.particle.Particle; + +/** + * @author noil + */ +public class EventAddEffect extends EventCancellable { + + private Particle particle; + + public EventAddEffect(Particle particle) { + this.particle = particle; + } + + public Particle getParticle() { + return particle; + } + + public void setParticle(Particle particle) { + this.particle = particle; + } +} diff --git a/src/main/java/me/rigamortis/seppuku/api/event/render/EventSpawnEffect.java b/src/main/java/me/rigamortis/seppuku/api/event/render/EventSpawnEffect.java new file mode 100644 index 0000000..3f32efd --- /dev/null +++ b/src/main/java/me/rigamortis/seppuku/api/event/render/EventSpawnEffect.java @@ -0,0 +1,23 @@ +package me.rigamortis.seppuku.api.event.render; + +import me.rigamortis.seppuku.api.event.EventCancellable; + +/** + * @author noil + */ +public class EventSpawnEffect extends EventCancellable { + + private int particleID; + + public EventSpawnEffect(int particleID) { + this.particleID = particleID; + } + + public int getParticleID() { + return particleID; + } + + public void setParticleID(int particleID) { + this.particleID = particleID; + } +} diff --git a/src/main/java/me/rigamortis/seppuku/impl/management/PatchManager.java b/src/main/java/me/rigamortis/seppuku/impl/management/PatchManager.java index db0ee99..1940881 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/management/PatchManager.java +++ b/src/main/java/me/rigamortis/seppuku/impl/management/PatchManager.java @@ -60,6 +60,7 @@ public final class PatchManager { this.patchList.add(new GuiScreenPatch()); this.patchList.add(new RenderGlobalPatch()); this.patchList.add(new GuiChatPatch()); + this.patchList.add(new ParticleManagerPatch()); //load custom external patches //TODO this needs more testing diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/render/NoLagModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/render/NoLagModule.java index 0baed3a..c9f766b 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/module/render/NoLagModule.java +++ b/src/main/java/me/rigamortis/seppuku/impl/module/render/NoLagModule.java @@ -7,13 +7,12 @@ import me.rigamortis.seppuku.api.event.world.EventLightUpdate; import me.rigamortis.seppuku.api.event.world.EventSpawnParticle; import me.rigamortis.seppuku.api.module.Module; import me.rigamortis.seppuku.api.value.Value; -import net.minecraft.block.Block; -import net.minecraft.block.BlockLiquid; -import net.minecraft.block.BlockPistonExtension; -import net.minecraft.block.BlockPistonMoving; +import net.minecraft.block.*; import net.minecraft.client.Minecraft; +import net.minecraft.client.particle.ParticleFirework; import net.minecraft.entity.boss.EntityWither; import net.minecraft.entity.item.EntityEnderCrystal; +import net.minecraft.entity.item.EntityFireworkRocket; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityTNTPrimed; import net.minecraft.entity.projectile.EntityWitherSkull; @@ -23,6 +22,7 @@ import net.minecraft.network.play.server.SPacketSoundEffect; import net.minecraft.network.play.server.SPacketSpawnMob; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntitySign; +import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; @@ -47,8 +47,13 @@ public final class NoLagModule extends Module { public final Value names = new Value("Names", new String[]{"Name", "n"}, "Disables the rendering of vanilla name-tags.", false); public final Value withers = new Value("Withers", new String[]{"Wither", "w"}, "Disables the rendering of withers.", false); public final Value skulls = new Value("Skulls", new String[]{"WitherSkull", "skulls", "skull", "ws"}, "Disables the rendering of flying wither skulls.", false); - public final Value crystals = new Value("Crystals", new String[]{"Wither", "w"}, "Disables the rendering of crystals.", false); - public final Value tnt = new Value("TNT", new String[]{"Wither", "w"}, "Disables the rendering of (primed) TNT.", false); + public final Value crystals = new Value("Crystals", new String[]{"Crystal", "cr", "c"}, "Disables the rendering of crystals.", false); + public final Value tnt = new Value("TNT", new String[]{"Dynamite", "explosives", "tn"}, "Disables the rendering of (primed) TNT.", false); + public final Value torches = new Value("Torches", new String[]{"Torch", "t"}, "Disables the rendering of torches.", false); + public final Value fireworks = new Value("Fireworks", new String[]{"FireW", "Fworks", "fw"}, "Disables the rendering of fireworks.", false); + public final Value redstone = new Value("Redstone", new String[]{"Red", "r"}, "Disables the rendering of redstone dust.", false); + public final Value redstoneTorch = new Value("RedstoneTorch", new String[]{"RedTorch", "rt"}, "Disables the rendering of redstone torches.", false); + public final Value redstoneLogic = new Value("RedstoneLogic", new String[]{"RedLogic", "rl"}, "Disables the rendering of redstone logic blocks.", false); public NoLagModule() { super("NoLag", new String[]{"AntiLag", "NoRender"}, "Fixes malicious lag exploits and bugs that cause lag.", "NONE", -1, ModuleType.RENDER); @@ -107,11 +112,36 @@ public final class NoLagModule extends Module { event.setCanceled(true); } } + if (this.pistons.getValue()) { if (block instanceof BlockPistonMoving || block instanceof BlockPistonExtension) { event.setCanceled(true); } } + + if (this.redstone.getValue()) { + if (block instanceof BlockRedstoneDiode || block instanceof BlockRedstoneWire) { + event.setCanceled(true); + } + } + + if (this.redstoneTorch.getValue()) { + if (block instanceof BlockRedstoneTorch) { + event.setCanceled(true); + } + } + + if (this.redstoneLogic.getValue()) { + if (block instanceof BlockRedstoneComparator || block instanceof BlockRedstoneRepeater) { + event.setCanceled(true); + } + } + + if (this.torches.getValue()) { + if (block instanceof BlockTorch) { + event.setCanceled(true); + } + } } } @@ -168,6 +198,34 @@ public final class NoLagModule extends Module { if (event.getEntity() instanceof EntityTNTPrimed) event.setCanceled(true); } + + if (this.fireworks.getValue()) { + if (event.getEntity() instanceof EntityFireworkRocket) + event.setCanceled(true); + } + } + } + + @Listener + public void onSpawnEffectParticle(EventSpawnEffect event) { + if (this.fireworks.getValue()) { + if (event.getParticleID() == EnumParticleTypes.FIREWORKS_SPARK.getParticleID() || + event.getParticleID() == EnumParticleTypes.EXPLOSION_HUGE.getParticleID() || + event.getParticleID() == EnumParticleTypes.EXPLOSION_LARGE.getParticleID() || + event.getParticleID() == EnumParticleTypes.EXPLOSION_NORMAL.getParticleID()) { + event.setCanceled(true); + } + } + } + + @Listener + public void onAddEffect(EventAddEffect event) { + if (this.fireworks.getValue()) { + if (event.getParticle() instanceof ParticleFirework.Starter || + event.getParticle() instanceof ParticleFirework.Spark || + event.getParticle() instanceof ParticleFirework.Overlay) { + event.setCanceled(true); + } } } diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/world/NoteBotModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/world/NoteBotModule.java index d3ddd4d..7c54519 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/module/world/NoteBotModule.java +++ b/src/main/java/me/rigamortis/seppuku/impl/module/world/NoteBotModule.java @@ -269,7 +269,7 @@ public final class NoteBotModule extends Module { } final AxisAlignedBB bb = new AxisAlignedBB( - pos.getX() - mc.getRenderManager().viewerPosX, pos.getY() - mc.getRenderManager().viewerPosY, pos.getZ() - mc.getRenderManager().viewerPosZ, + pos.getX() - mc.getRenderManager().viewerPosX, pos.getY() + 1.0f - mc.getRenderManager().viewerPosY, pos.getZ() - mc.getRenderManager().viewerPosZ, pos.getX() + 1.0f - mc.getRenderManager().viewerPosX, pos.getY() + 1.0f - mc.getRenderManager().viewerPosY, pos.getZ() + 1.0f - mc.getRenderManager().viewerPosZ); GlStateManager.color(color[0] / 255.0F, color[1] / 255.0F, color[2] / 255.0F, 0.2F); RenderUtil.drawFilledBox(bb); diff --git a/src/main/java/me/rigamortis/seppuku/impl/patch/ParticleManagerPatch.java b/src/main/java/me/rigamortis/seppuku/impl/patch/ParticleManagerPatch.java new file mode 100644 index 0000000..4ada270 --- /dev/null +++ b/src/main/java/me/rigamortis/seppuku/impl/patch/ParticleManagerPatch.java @@ -0,0 +1,96 @@ +package me.rigamortis.seppuku.impl.patch; + +import me.rigamortis.seppuku.Seppuku; +import me.rigamortis.seppuku.api.event.render.EventAddEffect; +import me.rigamortis.seppuku.api.event.render.EventRenderBossHealth; +import me.rigamortis.seppuku.api.event.render.EventSpawnEffect; +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 org.objectweb.asm.Type; +import org.objectweb.asm.tree.*; + +import static org.objectweb.asm.Opcodes.*; + +/** + * @author noil + */ +public class ParticleManagerPatch extends ClassPatch { + + public ParticleManagerPatch() { + super("net.minecraft.client.particle.ParticleManager", "btg"); + } + + /* + * public void a(btf ) { + * this.h.add(); + * } + */ + @MethodPatch( + mcpName = "addEffect", + notchName = "a", + mcpDesc = "(Lnet/minecraft/client/particle/Particle;)V", + notchDesc = "(Lbtf;)V") + public void addEffect(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, 1)); + //call our hook function + insnList.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(this.getClass()), "addEffectHook", env == PatchManager.Environment.IDE ? "(Lnet/minecraft/client/particle/Particle;)Z" : "(Lbtf;)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 static boolean addEffectHook(Particle particle) { + final EventAddEffect event = new EventAddEffect(particle); + Seppuku.INSTANCE.getEventManager().dispatchEvent(event); + return event.isCanceled(); + } + + // 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; + /* + @MethodPatch( + mcpName = "spawnEffectParticle", + notchName = "a", + mcpDesc = "(IDDDDDD[I)Lnet/minecraft/client/particle/Particle;", + notchDesc = "(IDDDDDD[I)Lbtf;") + public void spawnEffectParticle(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, 1)); + //call our hook function + insnList.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(this.getClass()), "spawnEffectParticleHook", "(I)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 static boolean spawnEffectParticleHook(int particleID) { + final EventSpawnEffect event = new EventSpawnEffect(particleID); + Seppuku.INSTANCE.getEventManager().dispatchEvent(event); + return event.isCanceled(); + } + */ +}