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 a8895b3..246d719 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 @@ -1,10 +1,14 @@ package me.rigamortis.seppuku.impl.module.render; +import me.rigamortis.seppuku.Seppuku; import me.rigamortis.seppuku.api.event.EventStageable; +import me.rigamortis.seppuku.api.event.gui.hud.EventUIValueChanged; +import me.rigamortis.seppuku.api.event.gui.hud.modulelist.EventUIListValueChanged; 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.EventLoadWorld; import me.rigamortis.seppuku.api.event.world.EventSpawnParticle; import me.rigamortis.seppuku.api.module.Module; import me.rigamortis.seppuku.api.value.Value; @@ -20,6 +24,8 @@ import net.minecraft.entity.item.EntityTNTPrimed; import net.minecraft.entity.projectile.EntityWitherSkull; import net.minecraft.init.Blocks; import net.minecraft.init.SoundEvents; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; import net.minecraft.network.play.server.*; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntitySign; @@ -30,19 +36,29 @@ import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; import team.stiff.pomelo.impl.annotated.handler.annotation.Listener; +import java.util.ArrayList; +import java.util.List; + /** * Author Seth * 4/11/2019 @ 3:48 AM. */ public final class NoLagModule extends Module { + public final Value blocks = new Value("Blocks", new String[]{"NoLagBlocks", "Block", "b"}, "Manual override for block renders", false); + public final Value blocksAll = new Value("BlocksAll", new String[]{"NoLagBlocksAll", "AllBlocks", "ba"}, "Disables the rendering of all blocks", false); + public final Value> blocksList = new Value>("BlocksList", new String[]{"NoLagBlocksList", "BlockIds", "blockid"}, "Blocks to disable rendering"); + public final Value items = new Value("Items", new String[]{"Item", "i"}, "Manual override for dropped item renders", false); + public final Value itemsAll = new Value("ItemsAll", new String[]{"AllItems", "ia"}, "Disables the rendering of all items", false); + public final Value itemsItemBlocks = new Value("ItemsItemBlocks", new String[]{"AllItemBlocks", "itemblocks"}, "Disables the rendering of dropped item-block stacks", false); + public final Value> itemsList = new Value>("ItemsList", new String[]{"ItemIds", "itemid"}, "Items to disable rendering"); + public final Value light = new Value("Light", new String[]{"Lit", "l"}, "Choose to enable the lighting lag fix. Disables lighting updates", false); public final Value signs = new Value("Signs", new String[]{"Sign", "si"}, "Choose to enable the sign lag fix. Disables the rendering of sign text", false); public final Value sounds = new Value("Sounds", new String[]{"Sound", "s"}, "Choose to enable the sound lag fix. Disable entity swap-item/equip sound", true); public final Value fluids = new Value("Fluids", new String[]{"Fluid", "f", "Liquids", "liq", "Water", "Lava"}, "Disables the rendering of all fluids", false); public final Value pistons = new Value("Pistons", new String[]{"Piston", "p"}, "Choose to enable the piston lag fix. Disables pistons from rendering", false); public final Value slimes = new Value("Slimes", new String[]{"Slime", "sl"}, "Choose to enable the slime lag fix. Disables slimes from spawning", false); - public final Value items = new Value("Items", new String[]{"Item", "i"}, "Disables the rendering of items", false); public final Value particles = new Value("Particles", new String[]{"Part", "par"}, "Disables the spawning of all particles", true); public final Value particlesPackets = new Value("ParticlesPackets", new String[]{"PartPacket", "parpac"}, "Disables particle packets and effect packets", false); public final Value particlesEntityPackets = new Value("ParticlesEntityPackets", new String[]{"PartEntPacket", "parentpac"}, "Disables entity effect packets (usually particles)", false); @@ -63,6 +79,9 @@ public final class NoLagModule extends Module { public NoLagModule() { super("NoLag", new String[]{"AntiLag", "NoRender"}, "Fixes malicious lag exploits and bugs that cause lag", "NONE", -1, ModuleType.RENDER); + + this.blocksList.setValue(new ArrayList<>()); + this.itemsList.setValue(new ArrayList<>()); } @Listener @@ -141,6 +160,18 @@ public final class NoLagModule extends Module { final BlockPos pos = event.getPos(); final Block block = Minecraft.getMinecraft().world.getBlockState(pos).getBlock(); if (block != Blocks.AIR) { + if (this.blocks.getValue()) { + if (this.blocksAll.getValue()) { + event.setCanceled(true); + } else { + this.blocksList.getValue().forEach(listBlock -> { + if (Block.getIdFromBlock(block) == Block.getIdFromBlock(listBlock)) { + event.setCanceled(true); + } + }); + } + } + if (this.fluids.getValue()) { if (block instanceof BlockLiquid) { event.setCanceled(true); @@ -209,8 +240,25 @@ public final class NoLagModule extends Module { public void onRenderEntity(EventRenderEntity event) { if (event.getEntity() != null) { if (this.items.getValue()) { - if (event.getEntity() instanceof EntityItem) - event.setCanceled(true); + if (event.getEntity() instanceof EntityItem) { + if (this.itemsAll.getValue()) { + event.setCanceled(true); + } else { + final EntityItem entityItem = (EntityItem) event.getEntity(); + + if (this.itemsItemBlocks.getValue()) { + if (entityItem.getItem().getItem() instanceof ItemBlock) { + event.setCanceled(true); + } + } + + this.itemsList.getValue().forEach(item -> { + if (Item.getIdFromItem(item) == Item.getIdFromItem(entityItem.getItem().getItem())) { + event.setCanceled(true); + } + }); + } + } } if (this.withers.getValue()) { @@ -309,4 +357,30 @@ public final class NoLagModule extends Module { } } } + + @Listener + public void onWorldLoad(EventLoadWorld event) { + if (event.getWorld() == null) + return; + + if (this.blocksList.getValue().isEmpty()) + this.blocksList.getValue().add(Block.getBlockFromName("stone")); + + if (this.itemsList.getValue().isEmpty()) + this.itemsList.getValue().add(Item.getByNameOrId("stick")); + } + + @Listener + public void onValueChanged(EventUIValueChanged event) { + if (event.getValue().getAlias()[0].toLowerCase().startsWith("nolagblocks")) { + Minecraft.getMinecraft().renderGlobal.loadRenderers(); + } + } + + @Listener + public void onListValueChanged(EventUIListValueChanged event) { + if (event.getValue().getAlias()[0].equalsIgnoreCase("nolagblockslist")) { + Minecraft.getMinecraft().renderGlobal.loadRenderers(); + } + } }