[cleanup] Cleaned up bunch of stuff for better performance (#1874)

This commit is contained in:
Xiaro 2021-01-22 14:53:59 -05:00 committed by GitHub
parent 167a4d2280
commit 9028214a15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 77 additions and 70 deletions

View File

@ -13,7 +13,6 @@ import me.zeroeightsix.kami.util.graphics.ProjectionUtils
import me.zeroeightsix.kami.util.text.MessageDetection import me.zeroeightsix.kami.util.text.MessageDetection
import net.minecraftforge.client.event.* import net.minecraftforge.client.event.*
import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent
import net.minecraftforge.event.entity.player.AttackEntityEvent
import net.minecraftforge.event.entity.player.PlayerInteractEvent import net.minecraftforge.event.entity.player.PlayerInteractEvent
import net.minecraftforge.event.world.ChunkEvent import net.minecraftforge.event.world.ChunkEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.EventPriority
@ -31,6 +30,12 @@ object ForgeEventProcessor {
@SubscribeEvent @SubscribeEvent
fun onTick(event: TickEvent.ClientTickEvent) { fun onTick(event: TickEvent.ClientTickEvent) {
if (event.phase == TickEvent.Phase.START) {
mc.profiler.startSection("kbTickPre")
} else {
mc.profiler.startSection("kbTickPost")
}
KamiEventBus.post(event) KamiEventBus.post(event)
if (event.phase == TickEvent.Phase.END && prevWidth != mc.displayWidth || prevHeight != mc.displayHeight) { if (event.phase == TickEvent.Phase.END && prevWidth != mc.displayWidth || prevHeight != mc.displayHeight) {
@ -38,15 +43,16 @@ object ForgeEventProcessor {
prevHeight = mc.displayHeight prevHeight = mc.displayHeight
KamiEventBus.post(ResolutionUpdateEvent(mc.displayWidth, mc.displayHeight)) KamiEventBus.post(ResolutionUpdateEvent(mc.displayWidth, mc.displayHeight))
} }
mc.profiler.endSection()
} }
@SubscribeEvent @SubscribeEvent
@Suppress("UNUSED_PARAMETER") @Suppress("UNUSED_PARAMETER")
fun onWorldRender(event: RenderWorldLastEvent) { fun onWorldRender(event: RenderWorldLastEvent) {
mc.profiler.startSection("kbRender3D")
ProjectionUtils.updateMatrix() ProjectionUtils.updateMatrix()
mc.profiler.startSection("KamiWorldRender")
KamiTessellator.prepareGL() KamiTessellator.prepareGL()
KamiEventBus.post(RenderWorldEvent()) KamiEventBus.post(RenderWorldEvent())
KamiTessellator.releaseGL() KamiTessellator.releaseGL()
@ -116,21 +122,11 @@ object ForgeEventProcessor {
KamiEventBus.post(entityUseItemEvent) KamiEventBus.post(entityUseItemEvent)
} }
@SubscribeEvent
fun onPlayerPush(event: PlayerSPPushOutOfBlocksEvent) {
KamiEventBus.post(event)
}
@SubscribeEvent @SubscribeEvent
fun onLeftClickBlock(event: PlayerInteractEvent.LeftClickBlock) { fun onLeftClickBlock(event: PlayerInteractEvent.LeftClickBlock) {
KamiEventBus.post(event) KamiEventBus.post(event)
} }
@SubscribeEvent
fun onAttackEntity(entityEvent: AttackEntityEvent) {
KamiEventBus.post(entityEvent)
}
@SubscribeEvent @SubscribeEvent
fun onRenderBlockOverlay(event: RenderBlockOverlayEvent) { fun onRenderBlockOverlay(event: RenderBlockOverlayEvent) {
KamiEventBus.post(event) KamiEventBus.post(event)

View File

@ -1,5 +0,0 @@
package me.zeroeightsix.kami.event.events
import me.zeroeightsix.kami.event.Event
class RenderShaderEvent : Event

View File

@ -82,12 +82,14 @@ object ColorPicker : TitledWindow("Color Picker", 0.0f, 0.0f, 200.0f, 200.0f, Se
override fun onTick() { override fun onTick() {
super.onTick() super.onTick()
prevHue = hue if (visible) {
prevSaturation = saturation prevHue = hue
prevBrightness = brightness prevSaturation = saturation
for (component in components) component.onTick() prevBrightness = brightness
if (hoveredChild != null) updateHSBFromRGB() for (component in components) component.onTick()
if (listeningChild?.listening == false) listeningChild = null if (hoveredChild != null) updateHSBFromRGB()
if (listeningChild?.listening == false) listeningChild = null
}
} }
override fun onMouseInput(mousePos: Vec2f) { override fun onMouseInput(mousePos: Vec2f) {

View File

@ -3,6 +3,7 @@ package me.zeroeightsix.kami.manager.managers
import me.zeroeightsix.kami.event.events.ConnectionEvent import me.zeroeightsix.kami.event.events.ConnectionEvent
import me.zeroeightsix.kami.event.events.RenderOverlayEvent import me.zeroeightsix.kami.event.events.RenderOverlayEvent
import me.zeroeightsix.kami.manager.Manager import me.zeroeightsix.kami.manager.Manager
import me.zeroeightsix.kami.mixin.extension.syncCurrentPlayItem
import me.zeroeightsix.kami.module.AbstractModule import me.zeroeightsix.kami.module.AbstractModule
import me.zeroeightsix.kami.util.* import me.zeroeightsix.kami.util.*
import me.zeroeightsix.kami.util.items.clickSlot import me.zeroeightsix.kami.util.items.clickSlot
@ -33,7 +34,7 @@ object PlayerInventoryManager : Manager {
getTaskOrNext()?.nextInfo()?.let { getTaskOrNext()?.nextInfo()?.let {
clickSlot(it.windowId, it.slot, it.mouseButton, it.type) clickSlot(it.windowId, it.slot, it.mouseButton, it.type)
playerController.updateController() playerController.syncCurrentPlayItem()
} }
if (actionQueue.isEmpty()) currentId = 0 if (actionQueue.isEmpty()) currentId = 0

View File

@ -3,7 +3,6 @@ package me.zeroeightsix.kami.mixin.client.render;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import me.zeroeightsix.kami.event.KamiEventBus; import me.zeroeightsix.kami.event.KamiEventBus;
import me.zeroeightsix.kami.event.events.RenderOverlayEvent; import me.zeroeightsix.kami.event.events.RenderOverlayEvent;
import me.zeroeightsix.kami.event.events.RenderShaderEvent;
import me.zeroeightsix.kami.module.modules.movement.ElytraFlight; import me.zeroeightsix.kami.module.modules.movement.ElytraFlight;
import me.zeroeightsix.kami.module.modules.player.Freecam; import me.zeroeightsix.kami.module.modules.player.Freecam;
import me.zeroeightsix.kami.module.modules.player.NoEntityTrace; import me.zeroeightsix.kami.module.modules.player.NoEntityTrace;
@ -12,6 +11,7 @@ import me.zeroeightsix.kami.module.modules.render.AntiFog;
import me.zeroeightsix.kami.module.modules.render.AntiOverlay; import me.zeroeightsix.kami.module.modules.render.AntiOverlay;
import me.zeroeightsix.kami.module.modules.render.CameraClip; import me.zeroeightsix.kami.module.modules.render.CameraClip;
import me.zeroeightsix.kami.module.modules.render.NoHurtCam; import me.zeroeightsix.kami.module.modules.render.NoHurtCam;
import me.zeroeightsix.kami.util.Wrapper;
import me.zeroeightsix.kami.util.math.Vec2f; import me.zeroeightsix.kami.util.math.Vec2f;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.entity.EntityPlayerSP;
@ -39,7 +39,9 @@ public class MixinEntityRenderer {
@Inject(method = "updateCameraAndRender", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiIngame;renderGameOverlay(F)V", shift = At.Shift.AFTER)) @Inject(method = "updateCameraAndRender", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiIngame;renderGameOverlay(F)V", shift = At.Shift.AFTER))
public void updateCameraAndRender(float partialTicks, long nanoTime, CallbackInfo ci) { public void updateCameraAndRender(float partialTicks, long nanoTime, CallbackInfo ci) {
Wrapper.getMinecraft().profiler.startSection("kbRender2D");
KamiEventBus.INSTANCE.post(new RenderOverlayEvent()); KamiEventBus.INSTANCE.post(new RenderOverlayEvent());
Wrapper.getMinecraft().profiler.endSection();
} }
@Redirect(method = "orientCamera", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/WorldClient;rayTraceBlocks(Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/util/math/Vec3d;)Lnet/minecraft/util/math/RayTraceResult;")) @Redirect(method = "orientCamera", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/WorldClient;rayTraceBlocks(Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/util/math/Vec3d;)Lnet/minecraft/util/math/RayTraceResult;"))
@ -93,12 +95,6 @@ public class MixinEntityRenderer {
} }
} }
@Inject(method = "renderWorldPass", at = @At("RETURN"))
public void renderShaderPre(int pass, float partialTicks, long finishTimeNano, CallbackInfo ci) {
RenderShaderEvent eventPre = new RenderShaderEvent();
KamiEventBus.INSTANCE.post(eventPre);
}
@Redirect(method = "updateCameraAndRender", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/EntityPlayerSP;turn(FF)V")) @Redirect(method = "updateCameraAndRender", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/EntityPlayerSP;turn(FF)V"))
public void turn(EntityPlayerSP player, float yaw, float pitch) { public void turn(EntityPlayerSP player, float yaw, float pitch) {
if (ViewLock.INSTANCE.isEnabled() && Freecam.INSTANCE.isDisabled()) { if (ViewLock.INSTANCE.isEnabled() && Freecam.INSTANCE.isDisabled()) {

View File

@ -3,6 +3,7 @@ package me.zeroeightsix.kami.mixin.client.render;
import me.zeroeightsix.kami.event.KamiEventBus; import me.zeroeightsix.kami.event.KamiEventBus;
import me.zeroeightsix.kami.event.Phase; import me.zeroeightsix.kami.event.Phase;
import me.zeroeightsix.kami.event.events.RenderEntityEvent; import me.zeroeightsix.kami.event.events.RenderEntityEvent;
import me.zeroeightsix.kami.util.Wrapper;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@ -15,22 +16,32 @@ public class MixinRenderManager {
@Inject(method = "renderEntity", at = @At("HEAD"), cancellable = true) @Inject(method = "renderEntity", at = @At("HEAD"), cancellable = true)
public void renderEntityPre(Entity entity, double x, double y, double z, float yaw, float partialTicks, boolean debug, CallbackInfo ci) { public void renderEntityPre(Entity entity, double x, double y, double z, float yaw, float partialTicks, boolean debug, CallbackInfo ci) {
if (entity == null) return; if (entity == null) return;
Wrapper.getMinecraft().profiler.startSection("kbRenderEntityPre");
RenderEntityEvent event = new RenderEntityEvent(entity, x, y, z, yaw, partialTicks, Phase.PRE); RenderEntityEvent event = new RenderEntityEvent(entity, x, y, z, yaw, partialTicks, Phase.PRE);
KamiEventBus.INSTANCE.post(event); KamiEventBus.INSTANCE.post(event);
Wrapper.getMinecraft().profiler.endSection();
if (event.getCancelled()) ci.cancel(); if (event.getCancelled()) ci.cancel();
} }
@Inject(method = "renderEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/Render;doRender(Lnet/minecraft/entity/Entity;DDDFF)V", shift = At.Shift.AFTER)) @Inject(method = "renderEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/Render;doRender(Lnet/minecraft/entity/Entity;DDDFF)V", shift = At.Shift.AFTER))
public void renderEntityPeri(Entity entity, double x, double y, double z, float yaw, float partialTicks, boolean debug, CallbackInfo ci) { public void renderEntityPeri(Entity entity, double x, double y, double z, float yaw, float partialTicks, boolean debug, CallbackInfo ci) {
if (entity == null) return; if (entity == null) return;
Wrapper.getMinecraft().profiler.startSection("kbRenderEntityPeri");
RenderEntityEvent event = new RenderEntityEvent(entity, x, y, z, yaw, partialTicks, Phase.PERI); RenderEntityEvent event = new RenderEntityEvent(entity, x, y, z, yaw, partialTicks, Phase.PERI);
KamiEventBus.INSTANCE.post(event); KamiEventBus.INSTANCE.post(event);
Wrapper.getMinecraft().profiler.endSection();
} }
@Inject(method = "renderEntity", at = @At("RETURN")) @Inject(method = "renderEntity", at = @At("RETURN"))
public void renderEntityPost(Entity entity, double x, double y, double z, float yaw, float partialTicks, boolean debug, CallbackInfo ci) { public void renderEntityPost(Entity entity, double x, double y, double z, float yaw, float partialTicks, boolean debug, CallbackInfo ci) {
if (entity == null) return; if (entity == null) return;
Wrapper.getMinecraft().profiler.startSection("kbRenderEntityPost");
RenderEntityEvent event = new RenderEntityEvent(entity, x, y, z, yaw, partialTicks, Phase.POST); RenderEntityEvent event = new RenderEntityEvent(entity, x, y, z, yaw, partialTicks, Phase.POST);
KamiEventBus.INSTANCE.post(event); KamiEventBus.INSTANCE.post(event);
Wrapper.getMinecraft().profiler.endSection();
} }
} }

View File

@ -1,18 +1,9 @@
package me.zeroeightsix.kami.module.modules.client package me.zeroeightsix.kami.module.modules.client
import me.zeroeightsix.kami.KamiMod import me.zeroeightsix.kami.KamiMod
import me.zeroeightsix.kami.gui.AbstractKamiGui
import me.zeroeightsix.kami.gui.clickgui.KamiClickGui
import me.zeroeightsix.kami.gui.hudgui.KamiHudGui
import me.zeroeightsix.kami.module.Category import me.zeroeightsix.kami.module.Category
import me.zeroeightsix.kami.module.Module import me.zeroeightsix.kami.module.Module
import me.zeroeightsix.kami.setting.ConfigManager
import me.zeroeightsix.kami.setting.ModuleConfig
import me.zeroeightsix.kami.util.ConfigUtils
import me.zeroeightsix.kami.util.TickTimer import me.zeroeightsix.kami.util.TickTimer
import me.zeroeightsix.kami.util.TimeUnit
import me.zeroeightsix.kami.util.text.MessageSendHelper
import me.zeroeightsix.kami.util.threads.BackgroundScope
import net.minecraftforge.fml.common.gameevent.TickEvent import net.minecraftforge.fml.common.gameevent.TickEvent
import org.kamiblue.event.listener.listener import org.kamiblue.event.listener.listener
import org.lwjgl.opengl.Display import org.lwjgl.opengl.Display
@ -29,17 +20,20 @@ internal object CommandConfig : Module(
private val customTitle = setting("WindowTitle", true) private val customTitle = setting("WindowTitle", true)
val modifierEnabled = setting("ModifierEnabled", false, { false }) val modifierEnabled = setting("ModifierEnabled", false, { false })
private val timer = TickTimer()
private val prevTitle = Display.getTitle() private val prevTitle = Display.getTitle()
private const val title = "${KamiMod.NAME} ${KamiMod.KAMI_KATAKANA} ${KamiMod.VERSION_SIMPLE}" private const val title = "${KamiMod.NAME} ${KamiMod.KAMI_KATAKANA} ${KamiMod.VERSION_SIMPLE}"
init { init {
listener<TickEvent.ClientTickEvent> { listener<TickEvent.ClientTickEvent> {
updateTitle() if (timer.tick(10000L)) {
if (customTitle.value) Display.setTitle(title)
else Display.setTitle(prevTitle)
}
}
customTitle.listeners.add {
timer.reset(-0xCAFEBABE)
} }
} }
private fun updateTitle() {
if (customTitle.value) Display.setTitle(title)
else Display.setTitle(prevTitle)
}
} }

View File

@ -3,6 +3,7 @@ package me.zeroeightsix.kami.module.modules.combat
import me.zeroeightsix.kami.event.SafeClientEvent import me.zeroeightsix.kami.event.SafeClientEvent
import me.zeroeightsix.kami.event.events.PacketEvent import me.zeroeightsix.kami.event.events.PacketEvent
import me.zeroeightsix.kami.manager.managers.CombatManager import me.zeroeightsix.kami.manager.managers.CombatManager
import me.zeroeightsix.kami.mixin.extension.syncCurrentPlayItem
import me.zeroeightsix.kami.module.Category import me.zeroeightsix.kami.module.Category
import me.zeroeightsix.kami.module.Module import me.zeroeightsix.kami.module.Module
import me.zeroeightsix.kami.util.* import me.zeroeightsix.kami.util.*
@ -160,7 +161,7 @@ internal object AutoOffhand : Module(
transactionLog.clear() transactionLog.clear()
transactionLog.putAll(moveToSlot(slot.slotNumber, 45).associate { it to false }) transactionLog.putAll(moveToSlot(slot.slotNumber, 45).associate { it to false })
playerController.updateController() playerController.syncCurrentPlayItem()
movingTimer.reset() movingTimer.reset()
if (switchMessage) MessageSendHelper.sendChatMessage("$chatName Offhand now has a ${typeAlt.toString().toLowerCase()}") if (switchMessage) MessageSendHelper.sendChatMessage("$chatName Offhand now has a ${typeAlt.toString().toLowerCase()}")

View File

@ -147,10 +147,7 @@ internal object CrystalAura : Module(
val minDamage get() = max(minDamageP, minDamageE) val minDamage get() = max(minDamageP, minDamageE)
val maxSelfDamage get() = min(maxSelfDamageP, maxSelfDamageE) val maxSelfDamage get() = min(maxSelfDamageP, maxSelfDamageE)
override fun isActive() = override fun isActive() = isEnabled && inactiveTicks <= 20
isEnabled
&& (mc.player?.allSlots?.countItem(Items.END_CRYSTAL) ?: 0) > 0
&& inactiveTicks <= 20
init { init {
onEnable { onEnable {

View File

@ -1,6 +1,7 @@
package me.zeroeightsix.kami.module.modules.misc package me.zeroeightsix.kami.module.modules.misc
import me.zeroeightsix.kami.event.SafeClientEvent import me.zeroeightsix.kami.event.SafeClientEvent
import me.zeroeightsix.kami.event.events.PlayerAttackEvent
import me.zeroeightsix.kami.mixin.extension.syncCurrentPlayItem import me.zeroeightsix.kami.mixin.extension.syncCurrentPlayItem
import me.zeroeightsix.kami.module.Category import me.zeroeightsix.kami.module.Category
import me.zeroeightsix.kami.module.Module import me.zeroeightsix.kami.module.Module
@ -12,7 +13,6 @@ import net.minecraft.block.state.IBlockState
import net.minecraft.enchantment.EnchantmentHelper import net.minecraft.enchantment.EnchantmentHelper
import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.EntityLivingBase
import net.minecraft.init.Enchantments import net.minecraft.init.Enchantments
import net.minecraftforge.event.entity.player.AttackEntityEvent
import net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock import net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock
import net.minecraftforge.fml.common.gameevent.TickEvent import net.minecraftforge.fml.common.gameevent.TickEvent
import org.lwjgl.input.Mouse import org.lwjgl.input.Mouse
@ -37,8 +37,8 @@ internal object AutoTool : Module(
if (shouldMoveBack || !switchBack.value) equipBestTool(world.getBlockState(it.pos)) if (shouldMoveBack || !switchBack.value) equipBestTool(world.getBlockState(it.pos))
} }
safeListener<AttackEntityEvent> { safeListener<PlayerAttackEvent> {
if (swapWeapon.value && it.target is EntityLivingBase) equipBestWeapon(preferWeapon.value) if (swapWeapon.value && it.entity is EntityLivingBase) equipBestWeapon(preferWeapon.value)
} }
safeListener<TickEvent.ClientTickEvent> { safeListener<TickEvent.ClientTickEvent> {

View File

@ -2,6 +2,7 @@ package me.zeroeightsix.kami.module.modules.player
import me.zeroeightsix.kami.event.SafeClientEvent import me.zeroeightsix.kami.event.SafeClientEvent
import me.zeroeightsix.kami.event.events.PlayerTravelEvent import me.zeroeightsix.kami.event.events.PlayerTravelEvent
import me.zeroeightsix.kami.mixin.extension.syncCurrentPlayItem
import me.zeroeightsix.kami.module.Category import me.zeroeightsix.kami.module.Category
import me.zeroeightsix.kami.module.Module import me.zeroeightsix.kami.module.Module
import me.zeroeightsix.kami.process.PauseProcess.pauseBaritone import me.zeroeightsix.kami.process.PauseProcess.pauseBaritone
@ -82,7 +83,7 @@ internal object InventoryManager : Module(
State.IDLE -> removeHoldingItem() State.IDLE -> removeHoldingItem()
} }
playerController.updateController() playerController.syncCurrentPlayItem()
} }
} }

View File

@ -9,6 +9,7 @@ import me.zeroeightsix.kami.event.events.PacketEvent
import me.zeroeightsix.kami.event.events.PlayerTravelEvent import me.zeroeightsix.kami.event.events.PlayerTravelEvent
import me.zeroeightsix.kami.manager.managers.PlayerPacketManager import me.zeroeightsix.kami.manager.managers.PlayerPacketManager
import me.zeroeightsix.kami.mixin.client.entity.MixinEntity import me.zeroeightsix.kami.mixin.client.entity.MixinEntity
import me.zeroeightsix.kami.mixin.extension.syncCurrentPlayItem
import me.zeroeightsix.kami.module.Category import me.zeroeightsix.kami.module.Category
import me.zeroeightsix.kami.module.Module import me.zeroeightsix.kami.module.Module
import me.zeroeightsix.kami.util.* import me.zeroeightsix.kami.util.*
@ -169,7 +170,7 @@ internal object Scaffold : Module(
} }
private fun SafeClientEvent.getBlockSlot(): HotbarSlot? { private fun SafeClientEvent.getBlockSlot(): HotbarSlot? {
playerController.updateController() playerController.syncCurrentPlayItem()
return player.hotbarSlots.firstItem<ItemBlock, HotbarSlot>() return player.hotbarSlots.firstItem<ItemBlock, HotbarSlot>()
} }

View File

@ -3,7 +3,6 @@ package me.zeroeightsix.kami.module.modules.render
import me.zeroeightsix.kami.event.Phase import me.zeroeightsix.kami.event.Phase
import me.zeroeightsix.kami.event.SafeClientEvent import me.zeroeightsix.kami.event.SafeClientEvent
import me.zeroeightsix.kami.event.events.RenderEntityEvent import me.zeroeightsix.kami.event.events.RenderEntityEvent
import me.zeroeightsix.kami.event.events.RenderShaderEvent
import me.zeroeightsix.kami.event.events.RenderWorldEvent import me.zeroeightsix.kami.event.events.RenderWorldEvent
import me.zeroeightsix.kami.mixin.extension.entityOutlineShader import me.zeroeightsix.kami.mixin.extension.entityOutlineShader
import me.zeroeightsix.kami.mixin.extension.listShaders import me.zeroeightsix.kami.mixin.extension.listShaders
@ -27,6 +26,7 @@ import net.minecraft.entity.projectile.EntityThrowable
import net.minecraft.util.ResourceLocation import net.minecraft.util.ResourceLocation
import net.minecraftforge.fml.common.gameevent.TickEvent import net.minecraftforge.fml.common.gameevent.TickEvent
import org.kamiblue.event.listener.listener import org.kamiblue.event.listener.listener
import org.lwjgl.opengl.GL11.*
internal object ESP : Module( internal object ESP : Module(
name = "ESP", name = "ESP",
@ -102,24 +102,37 @@ internal object ESP : Module(
} }
} }
listener<RenderShaderEvent> { listener<RenderWorldEvent>(69420) {
if (mode.value != ESPMode.SHADER) return@listener if (mode.value != ESPMode.SHADER) return@listener
frameBuffer?.bindFramebuffer(false) GlStateManager.matrixMode(GL_PROJECTION)
glPushMatrix()
GlStateManager.matrixMode(GL_MODELVIEW)
glPushMatrix()
shaderHelper.shader?.render(KamiTessellator.pTicks()) shaderHelper.shader?.render(KamiTessellator.pTicks())
// Re-enable blend because shader rendering will disable it at the end
GlStateManager.enableBlend()
GlStateManager.disableDepth()
// Draw it on the main frame buffer // Draw it on the main frame buffer
mc.framebuffer.bindFramebuffer(false) mc.framebuffer.bindFramebuffer(false)
GlStateManager.disableDepth()
// Re-enable blend because shader rendering will disable it at the end
GlStateManager.enableBlend()
frameBuffer?.framebufferRenderExt(mc.displayWidth, mc.displayHeight, false) frameBuffer?.framebufferRenderExt(mc.displayWidth, mc.displayHeight, false)
GlStateManager.disableBlend()
GlStateManager.enableDepth()
// Clean up the frame buffer // Clean up the frame buffer
frameBuffer?.framebufferClear() frameBuffer?.framebufferClear()
mc.framebuffer.bindFramebuffer(true) mc.framebuffer.bindFramebuffer(false)
GlStateManager.enableBlend()
GlStateManager.enableDepth()
GlStateManager.disableTexture2D()
GlStateManager.depthMask(false)
GlStateManager.matrixMode(GL_PROJECTION)
glPopMatrix()
GlStateManager.matrixMode(GL_MODELVIEW)
glPopMatrix()
} }
} }

View File

@ -110,9 +110,8 @@ class TextComponent(val separator: String = " ") {
fun isEmpty() = textLines.firstOrNull { it?.isEmpty() == false } == null fun isEmpty() = textLines.firstOrNull { it?.isEmpty() == false } == null
fun getWidth(customFont: Boolean = FontRenderAdapter.useCustomFont) = textLines.map { fun getWidth(customFont: Boolean = FontRenderAdapter.useCustomFont) = textLines
it?.getWidth(customFont) ?: 0f .maxOfOrNull { it?.getWidth(customFont) ?: 0.0f } ?: 0.0f
}.maxOrNull() ?: 0f
fun getHeight(lineSpace: Int, skipEmptyLines: Boolean = true, customFont: Boolean = FontRenderAdapter.useCustomFont) = fun getHeight(lineSpace: Int, skipEmptyLines: Boolean = true, customFont: Boolean = FontRenderAdapter.useCustomFont) =
FontRenderAdapter.getFontHeight(customFont = customFont) * getLines(skipEmptyLines) + lineSpace * (getLines(skipEmptyLines) - 1) FontRenderAdapter.getFontHeight(customFont = customFont) * getLines(skipEmptyLines) + lineSpace * (getLines(skipEmptyLines) - 1)