diff --git a/src/main/java/com/lambda/mixin/MixinMinecraft.java b/src/main/java/com/lambda/mixin/MixinMinecraft.java index 0971f98ca..73c865b2b 100644 --- a/src/main/java/com/lambda/mixin/MixinMinecraft.java +++ b/src/main/java/com/lambda/mixin/MixinMinecraft.java @@ -5,11 +5,11 @@ import com.lambda.client.event.events.RunGameLoopEvent; import com.lambda.client.gui.hudgui.elements.misc.FPS; import com.lambda.client.manager.managers.HotbarManager; -import com.lambda.mixin.accessor.player.AccessorEntityPlayerSP; -import com.lambda.mixin.accessor.player.AccessorPlayerControllerMP; import com.lambda.client.module.modules.combat.CrystalAura; import com.lambda.client.module.modules.player.BlockInteraction; import com.lambda.client.util.Wrapper; +import com.lambda.mixin.accessor.player.AccessorEntityPlayerSP; +import com.lambda.mixin.accessor.player.AccessorPlayerControllerMP; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.gui.GuiScreen; @@ -130,14 +130,14 @@ public void processKeyBindsInvokeIsKeyDown(CallbackInfo ci) { public void rightClickMousePre(CallbackInfo ci) { if (BlockInteraction.isMultiTaskEnabled()) { isHittingBlock = playerController.getIsHittingBlock(); - ((AccessorPlayerControllerMP) playerController).kbSetIsHittingBlock(false); + ((AccessorPlayerControllerMP) playerController).setIsHittingBlockFun(false); } } @Inject(method = "rightClickMouse", at = @At("RETURN")) public void rightClickMousePost(CallbackInfo ci) { if (BlockInteraction.isMultiTaskEnabled() && !playerController.getIsHittingBlock()) { - ((AccessorPlayerControllerMP) playerController).kbSetIsHittingBlock(isHittingBlock); + ((AccessorPlayerControllerMP) playerController).setIsHittingBlockFun(isHittingBlock); } } diff --git a/src/main/java/com/lambda/mixin/accessor/player/AccessorPlayerControllerMP.java b/src/main/java/com/lambda/mixin/accessor/player/AccessorPlayerControllerMP.java index 5bb24f271..0d17814d8 100644 --- a/src/main/java/com/lambda/mixin/accessor/player/AccessorPlayerControllerMP.java +++ b/src/main/java/com/lambda/mixin/accessor/player/AccessorPlayerControllerMP.java @@ -15,12 +15,11 @@ public interface AccessorPlayerControllerMP { void setBlockHitDelay(int value); @Accessor("isHittingBlock") - void kbSetIsHittingBlock(boolean value); + void setIsHittingBlockFun(boolean value); @Accessor("currentPlayerItem") int getCurrentPlayerItem(); @Invoker("syncCurrentPlayItem") - void kb_invokeSyncCurrentPlayItem(); // Mixin bug #430 https://github.com/SpongePowered/Mixin/issues/430 - + void synchronizeCurrentPlayItem(); // Mixin bug #430 https://github.com/SpongePowered/Mixin/issues/430 } diff --git a/src/main/java/com/lambda/mixin/player/MixinPlayerControllerMP.java b/src/main/java/com/lambda/mixin/player/MixinPlayerControllerMP.java index d0f0fee2b..9950bcc0e 100644 --- a/src/main/java/com/lambda/mixin/player/MixinPlayerControllerMP.java +++ b/src/main/java/com/lambda/mixin/player/MixinPlayerControllerMP.java @@ -2,8 +2,8 @@ import com.lambda.client.event.LambdaEventBus; import com.lambda.client.event.events.PlayerAttackEvent; +import com.lambda.client.event.events.WindowClickEvent; import com.lambda.client.module.modules.player.AutoEat; -import com.lambda.client.module.modules.player.NoGhostItems; import com.lambda.client.module.modules.player.TpsSync; import com.lambda.client.util.TpsCalculator; import net.minecraft.block.state.IBlockState; @@ -14,6 +14,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import org.jetbrains.annotations.NotNull; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -25,7 +26,7 @@ public class MixinPlayerControllerMP { @Redirect(method = "onPlayerDamageBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/state/IBlockState;getPlayerRelativeBlockHardness(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)F")) - float getPlayerRelativeBlockHardness(IBlockState state, EntityPlayer player, World worldIn, BlockPos pos) { + float getPlayerRelativeBlockHardness(@NotNull IBlockState state, EntityPlayer player, World worldIn, BlockPos pos) { return state.getPlayerRelativeBlockHardness(player, worldIn, pos) * (TpsSync.INSTANCE.isEnabled() ? (TpsCalculator.INSTANCE.getTickRate() / 20f) : 1); } @@ -41,8 +42,9 @@ public void attackEntity(EntityPlayer playerIn, Entity targetEntity, CallbackInf @Inject(method = "windowClick", at = @At("HEAD"), cancellable = true) public void onWindowClick(int windowId, int slotId, int mouseButton, ClickType type, EntityPlayer player, CallbackInfoReturnable cir) { - if (NoGhostItems.INSTANCE.isEnabled()) { - NoGhostItems.INSTANCE.handleWindowClick(windowId, slotId, mouseButton, type, player); + WindowClickEvent event = new WindowClickEvent(windowId, slotId, mouseButton, type); + LambdaEventBus.INSTANCE.post(event); + if (event.getCancelled()) { cir.cancel(); } } diff --git a/src/main/java/com/lambda/mixin/world/MixinGetCollisionBB.java b/src/main/java/com/lambda/mixin/world/MixinGetCollisionBB.java index 99822c58c..2a9498ab5 100644 --- a/src/main/java/com/lambda/mixin/world/MixinGetCollisionBB.java +++ b/src/main/java/com/lambda/mixin/world/MixinGetCollisionBB.java @@ -33,5 +33,8 @@ private void getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldI } } } - public Block getBlock(BlockPos var0) {return mc.world.getBlockState(var0).getBlock();} + + public Block getBlock(BlockPos var0) { + return mc.world.getBlockState(var0).getBlock(); + } } diff --git a/src/main/java/com/lambda/mixin/world/MixinItemBlock.java b/src/main/java/com/lambda/mixin/world/MixinItemBlock.java index ae3397313..1055f8483 100644 --- a/src/main/java/com/lambda/mixin/world/MixinItemBlock.java +++ b/src/main/java/com/lambda/mixin/world/MixinItemBlock.java @@ -1,6 +1,6 @@ package com.lambda.mixin.world; -import com.lambda.client.module.modules.player.NoGlitchBlocks; +import com.lambda.client.module.modules.player.NoGhostBlocks; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemBlock; import net.minecraft.util.math.BlockPos; @@ -13,7 +13,7 @@ public class MixinItemBlock { @Redirect(method = "placeBlockAt", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/state/IBlockState;I)Z")) private boolean ignoreSetBlockState(World instance, BlockPos p_setBlockState_1_, IBlockState p_setBlockState_2_, int p_setBlockState_3_) { - if (NoGlitchBlocks.INSTANCE.isEnabled()) { + if (NoGhostBlocks.INSTANCE.isEnabled()) { return true; } else { return instance.setBlockState(p_setBlockState_1_, p_setBlockState_2_, p_setBlockState_3_); diff --git a/src/main/kotlin/com/lambda/client/command/Args.kt b/src/main/kotlin/com/lambda/client/command/Args.kt index 941991dd6..528bf3082 100644 --- a/src/main/kotlin/com/lambda/client/command/Args.kt +++ b/src/main/kotlin/com/lambda/client/command/Args.kt @@ -1,6 +1,10 @@ package com.lambda.client.command import com.lambda.client.capeapi.PlayerProfile +import com.lambda.client.command.args.AbstractArg +import com.lambda.client.command.args.AutoComplete +import com.lambda.client.command.args.DynamicPrefixMatch +import com.lambda.client.command.args.StaticPrefixMatch import com.lambda.client.gui.GuiManager import com.lambda.client.gui.hudgui.AbstractHudElement import com.lambda.client.manager.managers.UUIDManager @@ -8,10 +12,6 @@ import com.lambda.client.module.AbstractModule import com.lambda.client.module.ModuleManager import com.lambda.client.util.* import com.lambda.client.util.threads.runSafeR -import com.lambda.client.command.args.AbstractArg -import com.lambda.client.command.args.AutoComplete -import com.lambda.client.command.args.DynamicPrefixMatch -import com.lambda.client.command.args.StaticPrefixMatch import kotlinx.coroutines.Dispatchers import net.minecraft.block.Block import net.minecraft.item.Item diff --git a/src/main/kotlin/com/lambda/client/command/commands/ConfigCommand.kt b/src/main/kotlin/com/lambda/client/command/commands/ConfigCommand.kt index c1d129c66..16a42c2dd 100644 --- a/src/main/kotlin/com/lambda/client/command/commands/ConfigCommand.kt +++ b/src/main/kotlin/com/lambda/client/command/commands/ConfigCommand.kt @@ -1,6 +1,7 @@ package com.lambda.client.command.commands import com.lambda.client.command.ClientCommand +import com.lambda.client.command.execute.IExecuteEvent import com.lambda.client.event.SafeExecuteEvent import com.lambda.client.module.modules.client.Configurations import com.lambda.client.util.ConfigUtils @@ -9,7 +10,6 @@ import com.lambda.client.util.TimeUnit import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.formatValue import com.lambda.client.util.threads.defaultScope -import com.lambda.client.command.execute.IExecuteEvent import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch diff --git a/src/main/kotlin/com/lambda/client/command/commands/CreditsCommand.kt b/src/main/kotlin/com/lambda/client/command/commands/CreditsCommand.kt index 3d3565ca7..789092526 100644 --- a/src/main/kotlin/com/lambda/client/command/commands/CreditsCommand.kt +++ b/src/main/kotlin/com/lambda/client/command/commands/CreditsCommand.kt @@ -4,9 +4,9 @@ import com.google.gson.Gson import com.google.gson.annotations.SerializedName import com.lambda.client.LambdaMod import com.lambda.client.command.ClientCommand +import com.lambda.client.commons.utils.ConnectionUtils import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.formatValue -import com.lambda.client.commons.utils.ConnectionUtils object CreditsCommand : ClientCommand( name = "credits", diff --git a/src/main/kotlin/com/lambda/client/command/commands/EntityStatsCommand.kt b/src/main/kotlin/com/lambda/client/command/commands/EntityStatsCommand.kt index 515547553..45a65f944 100644 --- a/src/main/kotlin/com/lambda/client/command/commands/EntityStatsCommand.kt +++ b/src/main/kotlin/com/lambda/client/command/commands/EntityStatsCommand.kt @@ -1,9 +1,9 @@ package com.lambda.client.command.commands import com.lambda.client.command.ClientCommand +import com.lambda.client.commons.utils.MathUtils import com.lambda.client.manager.managers.UUIDManager import com.lambda.client.util.text.MessageSendHelper -import com.lambda.client.commons.utils.MathUtils import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.passive.AbstractHorse import kotlin.math.pow diff --git a/src/main/kotlin/com/lambda/client/command/commands/NBTCommand.kt b/src/main/kotlin/com/lambda/client/command/commands/NBTCommand.kt index 79755d07b..81c60ca0a 100644 --- a/src/main/kotlin/com/lambda/client/command/commands/NBTCommand.kt +++ b/src/main/kotlin/com/lambda/client/command/commands/NBTCommand.kt @@ -1,10 +1,10 @@ package com.lambda.client.command.commands import com.lambda.client.command.ClientCommand +import com.lambda.client.commons.utils.SystemUtils import com.lambda.client.event.SafeExecuteEvent import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.formatValue -import com.lambda.client.commons.utils.SystemUtils import net.minecraft.item.ItemStack import net.minecraft.nbt.JsonToNBT import net.minecraft.nbt.NBTTagCompound diff --git a/src/main/kotlin/com/lambda/client/command/commands/PacketCommand.kt b/src/main/kotlin/com/lambda/client/command/commands/PacketCommand.kt index 5e791fc27..b7969d366 100644 --- a/src/main/kotlin/com/lambda/client/command/commands/PacketCommand.kt +++ b/src/main/kotlin/com/lambda/client/command/commands/PacketCommand.kt @@ -3,7 +3,7 @@ package com.lambda.client.command.commands import com.lambda.client.command.ClientCommand import com.lambda.client.event.SafeClientEvent import com.lambda.client.mixin.extension.useEntityId -import com.lambda.client.util.items.clickSlot +import com.lambda.client.util.items.clickSlotUnsynced import com.lambda.client.util.text.MessageSendHelper import net.minecraft.entity.passive.EntityDonkey import net.minecraft.entity.player.EntityPlayer @@ -51,7 +51,7 @@ object PacketCommand : ClientCommand( int("buttonId") { buttonId -> enum("clickType") { clickType -> executeSafe { - clickSlot(windowId.value, slotId.value, buttonId.value, clickType.value) + clickSlotUnsynced(windowId.value, slotId.value, buttonId.value, clickType.value) MessageSendHelper.sendChatMessage("Sent ${TextFormatting.GRAY}CPacketClickWindow${TextFormatting.DARK_RED} > ${TextFormatting.GRAY}windowId: ${windowId.value}, slotId: ${slotId.value}, buttonId: ${buttonId.value}, clickType: ${clickType.value}") } } @@ -62,7 +62,7 @@ object PacketCommand : ClientCommand( literal("ClientSettings") { string("lang") { lang -> - int ("renderDistanceIn") { renderDistanceIn -> + int("renderDistanceIn") { renderDistanceIn -> enum("chatVisibilityIn") { chatVisibilityIn -> boolean("chatColorsIn") { chatColorsIn -> int("modelPartsIn") { modelPartsIn -> diff --git a/src/main/kotlin/com/lambda/client/command/commands/SignBookCommand.kt b/src/main/kotlin/com/lambda/client/command/commands/SignBookCommand.kt index e24bfbffd..8b0f563f9 100644 --- a/src/main/kotlin/com/lambda/client/command/commands/SignBookCommand.kt +++ b/src/main/kotlin/com/lambda/client/command/commands/SignBookCommand.kt @@ -1,11 +1,11 @@ package com.lambda.client.command.commands import com.lambda.client.command.ClientCommand +import com.lambda.client.commons.extension.max import com.lambda.client.util.items.itemPayload import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.MessageSendHelper.sendChatMessage import com.lambda.client.util.text.formatValue -import com.lambda.client.commons.extension.max import net.minecraft.item.ItemWritableBook import net.minecraft.nbt.NBTTagList import net.minecraft.nbt.NBTTagString diff --git a/src/main/kotlin/com/lambda/client/command/commands/TroubleshootCommand.kt b/src/main/kotlin/com/lambda/client/command/commands/TroubleshootCommand.kt index 9f8972c46..be11a3bf8 100644 --- a/src/main/kotlin/com/lambda/client/command/commands/TroubleshootCommand.kt +++ b/src/main/kotlin/com/lambda/client/command/commands/TroubleshootCommand.kt @@ -9,7 +9,6 @@ import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.OpenGlHelper import net.minecraftforge.common.ForgeVersion import org.lwjgl.opengl.GL11 -import java.util.* object TroubleshootCommand : ClientCommand( name = "troubleshoot", diff --git a/src/main/kotlin/com/lambda/client/event/ClientEvents.kt b/src/main/kotlin/com/lambda/client/event/ClientEvents.kt index 6ce72ed54..e2acce7b7 100644 --- a/src/main/kotlin/com/lambda/client/event/ClientEvents.kt +++ b/src/main/kotlin/com/lambda/client/event/ClientEvents.kt @@ -1,9 +1,9 @@ package com.lambda.client.event import com.lambda.client.command.CommandManager -import com.lambda.client.util.Wrapper import com.lambda.client.command.execute.ExecuteEvent import com.lambda.client.command.execute.IExecuteEvent +import com.lambda.client.util.Wrapper import net.minecraft.client.entity.EntityPlayerSP import net.minecraft.client.multiplayer.PlayerControllerMP import net.minecraft.client.multiplayer.WorldClient diff --git a/src/main/kotlin/com/lambda/client/event/LambdaEventBus.kt b/src/main/kotlin/com/lambda/client/event/LambdaEventBus.kt index 14c8285f6..0538133f9 100644 --- a/src/main/kotlin/com/lambda/client/event/LambdaEventBus.kt +++ b/src/main/kotlin/com/lambda/client/event/LambdaEventBus.kt @@ -1,9 +1,9 @@ package com.lambda.client.event -import com.lambda.client.util.Wrapper import com.lambda.client.event.eventbus.AbstractAsyncEventBus import com.lambda.client.event.listener.AsyncListener import com.lambda.client.event.listener.Listener +import com.lambda.client.util.Wrapper import io.netty.util.internal.ConcurrentSet import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch diff --git a/src/main/kotlin/com/lambda/client/event/events/OnUpdateWalkingPlayerEvent.kt b/src/main/kotlin/com/lambda/client/event/events/OnUpdateWalkingPlayerEvent.kt index 90f95afb2..7c6d782dd 100644 --- a/src/main/kotlin/com/lambda/client/event/events/OnUpdateWalkingPlayerEvent.kt +++ b/src/main/kotlin/com/lambda/client/event/events/OnUpdateWalkingPlayerEvent.kt @@ -1,12 +1,12 @@ package com.lambda.client.event.events +import com.lambda.client.commons.extension.next import com.lambda.client.event.Cancellable import com.lambda.client.event.Event import com.lambda.client.event.IMultiPhase import com.lambda.client.event.Phase import com.lambda.client.manager.managers.PlayerPacketManager import com.lambda.client.util.math.Vec2f -import com.lambda.client.commons.extension.next import net.minecraft.util.math.Vec3d class OnUpdateWalkingPlayerEvent private constructor( diff --git a/src/main/kotlin/com/lambda/client/event/events/WindowClickEvent.kt b/src/main/kotlin/com/lambda/client/event/events/WindowClickEvent.kt new file mode 100644 index 000000000..1877226b8 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/event/events/WindowClickEvent.kt @@ -0,0 +1,8 @@ +package com.lambda.client.event.events + +import com.lambda.client.event.Cancellable +import com.lambda.client.event.Event +import com.lambda.client.event.ICancellable +import net.minecraft.inventory.ClickType + +class WindowClickEvent(val windowId: Int, val slotId: Int, val mouseButton: Int, val type: ClickType) : Event, ICancellable by Cancellable() \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/gui/GuiManager.kt b/src/main/kotlin/com/lambda/client/gui/GuiManager.kt index ba93ba108..74d078489 100644 --- a/src/main/kotlin/com/lambda/client/gui/GuiManager.kt +++ b/src/main/kotlin/com/lambda/client/gui/GuiManager.kt @@ -1,6 +1,9 @@ package com.lambda.client.gui import com.lambda.client.LambdaMod +import com.lambda.client.commons.collections.AliasSet +import com.lambda.client.commons.utils.ClassUtils +import com.lambda.client.commons.utils.ClassUtils.instance import com.lambda.client.event.LambdaEventBus import com.lambda.client.gui.clickgui.LambdaClickGui import com.lambda.client.gui.hudgui.AbstractHudElement @@ -8,9 +11,6 @@ import com.lambda.client.gui.hudgui.LambdaHudGui import com.lambda.client.util.AsyncCachedValue import com.lambda.client.util.StopTimer import com.lambda.client.util.TimeUnit -import com.lambda.client.commons.collections.AliasSet -import com.lambda.client.commons.utils.ClassUtils -import com.lambda.client.commons.utils.ClassUtils.instance import kotlinx.coroutines.Deferred import java.lang.reflect.Modifier diff --git a/src/main/kotlin/com/lambda/client/gui/clickgui/LambdaClickGui.kt b/src/main/kotlin/com/lambda/client/gui/clickgui/LambdaClickGui.kt index 75760026a..09ca83968 100644 --- a/src/main/kotlin/com/lambda/client/gui/clickgui/LambdaClickGui.kt +++ b/src/main/kotlin/com/lambda/client/gui/clickgui/LambdaClickGui.kt @@ -2,6 +2,7 @@ package com.lambda.client.gui.clickgui import com.google.gson.JsonParser import com.lambda.client.LambdaMod +import com.lambda.client.commons.utils.ConnectionUtils import com.lambda.client.gui.AbstractLambdaGui import com.lambda.client.gui.clickgui.component.* import com.lambda.client.gui.clickgui.window.ModuleSettingWindow @@ -16,7 +17,6 @@ import com.lambda.client.util.FolderUtils import com.lambda.client.util.math.Vec2f import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.defaultScope -import com.lambda.client.commons.utils.ConnectionUtils import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import net.minecraft.util.text.TextFormatting @@ -139,7 +139,7 @@ object LambdaClickGui : AbstractLambdaGui() .filter { it !in disabledRemotes } .forEach { it.visible = function(it) - } + } } fun populateRemotePlugins() { diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractHudElement.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractHudElement.kt index 849adb72a..e68c065b8 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractHudElement.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractHudElement.kt @@ -1,5 +1,8 @@ package com.lambda.client.gui.hudgui +import com.lambda.client.commons.interfaces.Alias +import com.lambda.client.commons.interfaces.DisplayEnum +import com.lambda.client.commons.interfaces.Nameable import com.lambda.client.event.LambdaEventBus import com.lambda.client.gui.rgui.windows.BasicWindow import com.lambda.client.module.modules.client.GuiColors @@ -15,9 +18,6 @@ import com.lambda.client.util.math.Vec2d import com.lambda.client.util.math.Vec2f import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.safeListener -import com.lambda.client.commons.interfaces.Alias -import com.lambda.client.commons.interfaces.DisplayEnum -import com.lambda.client.commons.interfaces.Nameable import net.minecraftforge.fml.common.gameevent.TickEvent import org.lwjgl.opengl.GL11.glScalef diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractLabelHud.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractLabelHud.kt index 5df88a0b6..56f721f0e 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractLabelHud.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractLabelHud.kt @@ -1,12 +1,12 @@ package com.lambda.client.gui.hudgui +import com.lambda.client.commons.interfaces.Nameable import com.lambda.client.event.SafeClientEvent import com.lambda.client.setting.configs.AbstractConfig import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.graphics.font.TextComponent import com.lambda.client.util.math.Vec2d import com.lambda.client.util.threads.safeAsyncListener -import com.lambda.client.commons.interfaces.Nameable import net.minecraftforge.fml.common.gameevent.TickEvent abstract class AbstractLabelHud( diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/LambdaHudGui.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/LambdaHudGui.kt index 79d9fe279..f119fab0e 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/LambdaHudGui.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/LambdaHudGui.kt @@ -1,6 +1,7 @@ package com.lambda.client.gui.hudgui import com.lambda.client.event.events.RenderOverlayEvent +import com.lambda.client.event.listener.listener import com.lambda.client.gui.AbstractLambdaGui import com.lambda.client.gui.clickgui.LambdaClickGui import com.lambda.client.gui.hudgui.component.HudButton @@ -13,7 +14,6 @@ import com.lambda.client.module.modules.client.HudEditor import com.lambda.client.util.graphics.GlStateUtils import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.math.Vec2f -import com.lambda.client.event.listener.listener import net.minecraftforge.fml.common.gameevent.InputEvent import org.lwjgl.input.Keyboard import org.lwjgl.opengl.GL11.* diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/ModuleList.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/ModuleList.kt index 0f30254e1..1665246cc 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/ModuleList.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/ModuleList.kt @@ -1,5 +1,7 @@ package com.lambda.client.gui.hudgui.elements.client +import com.lambda.client.commons.extension.sumByFloat +import com.lambda.client.commons.interfaces.DisplayEnum import com.lambda.client.gui.hudgui.HudElement import com.lambda.client.module.AbstractModule import com.lambda.client.module.ModuleManager @@ -15,8 +17,6 @@ import com.lambda.client.util.graphics.font.HAlign import com.lambda.client.util.graphics.font.TextComponent import com.lambda.client.util.graphics.font.VAlign import com.lambda.client.util.threads.safeAsyncListener -import com.lambda.client.commons.extension.sumByFloat -import com.lambda.client.commons.interfaces.DisplayEnum import net.minecraft.client.renderer.GlStateManager import net.minecraftforge.fml.common.gameevent.TickEvent import java.awt.Color diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/combat/Armor.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/combat/Armor.kt index 2d328ef36..685f12edf 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/combat/Armor.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/combat/Armor.kt @@ -1,5 +1,6 @@ package com.lambda.client.gui.hudgui.elements.combat +import com.lambda.client.commons.utils.MathUtils import com.lambda.client.gui.hudgui.HudElement import com.lambda.client.util.color.ColorGradient import com.lambda.client.util.color.ColorHolder @@ -13,7 +14,6 @@ import com.lambda.client.util.items.countItem import com.lambda.client.util.math.Vec2d import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeAsyncListener -import com.lambda.client.commons.utils.MathUtils import net.minecraft.client.renderer.GlStateManager import net.minecraft.init.Items import net.minecraft.item.ItemStack diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/combat/CrystalDamage.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/combat/CrystalDamage.kt index ef53d76be..61e83bb23 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/combat/CrystalDamage.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/combat/CrystalDamage.kt @@ -1,11 +1,11 @@ package com.lambda.client.gui.hudgui.elements.combat +import com.lambda.client.commons.utils.MathUtils import com.lambda.client.event.SafeClientEvent import com.lambda.client.gui.hudgui.LabelHud import com.lambda.client.manager.managers.CombatManager import com.lambda.client.util.Quad import com.lambda.client.util.combat.CrystalUtils.canPlaceCollide -import com.lambda.client.commons.utils.MathUtils import kotlin.math.max internal object CrystalDamage : LabelHud( diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/CPS.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/CPS.kt index 6fa6c4e35..b04474c63 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/CPS.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/CPS.kt @@ -2,10 +2,10 @@ package com.lambda.client.gui.hudgui.elements.misc import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.RunGameLoopEvent +import com.lambda.client.event.listener.listener import com.lambda.client.gui.hudgui.LabelHud import com.lambda.client.util.TickTimer import com.lambda.client.util.graphics.AnimationUtils -import com.lambda.client.event.listener.listener import net.minecraftforge.fml.common.gameevent.InputEvent import org.lwjgl.input.Mouse diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/Queue2B2T.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/Queue2B2T.kt index 6ba1dbdcc..e981b0117 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/Queue2B2T.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/Queue2B2T.kt @@ -2,6 +2,7 @@ package com.lambda.client.gui.hudgui.elements.misc import com.google.gson.Gson import com.google.gson.annotations.SerializedName +import com.lambda.client.commons.utils.grammar import com.lambda.client.event.SafeClientEvent import com.lambda.client.gui.hudgui.LabelHud import com.lambda.client.manager.managers.NetworkManager @@ -11,7 +12,6 @@ import com.lambda.client.util.TimeUnit import com.lambda.client.util.WebUtils import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.defaultScope -import com.lambda.client.commons.utils.grammar import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Durability.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Durability.kt index 8da8b95bd..5b3b183e1 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Durability.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Durability.kt @@ -1,8 +1,8 @@ package com.lambda.client.gui.hudgui.elements.player +import com.lambda.client.commons.utils.MathUtils import com.lambda.client.event.SafeClientEvent import com.lambda.client.gui.hudgui.LabelHud -import com.lambda.client.commons.utils.MathUtils import net.minecraft.util.EnumHand internal object Durability : LabelHud( diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Effects.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Effects.kt index 49d226d33..5298e54b0 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Effects.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Effects.kt @@ -4,8 +4,8 @@ import com.lambda.client.event.SafeClientEvent import com.lambda.client.gui.hudgui.LabelHud import com.lambda.client.util.color.ColorConverter import com.lambda.client.util.text.RomanNumerals -import net.minecraft.potion.* import net.minecraft.client.resources.I18n +import net.minecraft.potion.Potion internal object Effects : LabelHud( name = "Effects", diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/PlayerSpeed.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/PlayerSpeed.kt index 5e57f9dcb..d1aced7b3 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/PlayerSpeed.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/PlayerSpeed.kt @@ -1,10 +1,10 @@ package com.lambda.client.gui.hudgui.elements.player +import com.lambda.client.commons.interfaces.DisplayEnum +import com.lambda.client.commons.utils.MathUtils import com.lambda.client.event.SafeClientEvent import com.lambda.client.gui.hudgui.LabelHud import com.lambda.client.util.InfoCalculator.speed -import com.lambda.client.commons.interfaces.DisplayEnum -import com.lambda.client.commons.utils.MathUtils import java.util.* internal object PlayerSpeed : LabelHud( diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Rotation.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Rotation.kt index 7ce662755..8082a9d49 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Rotation.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Rotation.kt @@ -1,9 +1,9 @@ package com.lambda.client.gui.hudgui.elements.player +import com.lambda.client.commons.utils.MathUtils import com.lambda.client.event.SafeClientEvent import com.lambda.client.gui.hudgui.LabelHud import com.lambda.client.util.math.RotationUtils -import com.lambda.client.commons.utils.MathUtils internal object Rotation : LabelHud( name = "Rotation", diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/TimerSpeed.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/TimerSpeed.kt index e0dd5687b..1c336b0be 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/TimerSpeed.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/TimerSpeed.kt @@ -1,9 +1,9 @@ package com.lambda.client.gui.hudgui.elements.player +import com.lambda.client.commons.utils.MathUtils import com.lambda.client.event.SafeClientEvent import com.lambda.client.gui.hudgui.LabelHud import com.lambda.client.manager.managers.TimerManager -import com.lambda.client.commons.utils.MathUtils internal object TimerSpeed : LabelHud( name = "TimerSpeed", diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/ChunkSize.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/ChunkSize.kt index 263c44f11..8e77f5c9b 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/ChunkSize.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/ChunkSize.kt @@ -1,9 +1,9 @@ package com.lambda.client.gui.hudgui.elements.world +import com.lambda.client.commons.utils.MathUtils.round import com.lambda.client.event.SafeClientEvent import com.lambda.client.gui.hudgui.LabelHud import com.lambda.client.mixin.extension.writeChunkToNBT -import com.lambda.client.commons.utils.MathUtils.round import net.minecraft.nbt.CompressedStreamTools import net.minecraft.nbt.NBTTagCompound import net.minecraft.util.datafix.DataFixer diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/TextRadar.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/TextRadar.kt index 2f0602568..95bcd6aed 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/TextRadar.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/TextRadar.kt @@ -1,5 +1,6 @@ package com.lambda.client.gui.hudgui.elements.world +import com.lambda.client.commons.utils.MathUtils import com.lambda.client.event.SafeClientEvent import com.lambda.client.gui.hudgui.LabelHud import com.lambda.client.manager.managers.FriendManager @@ -8,7 +9,6 @@ import com.lambda.client.util.color.ColorGradient import com.lambda.client.util.color.ColorHolder import com.lambda.client.util.color.DyeColors import com.lambda.client.util.threads.runSafeR -import com.lambda.client.commons.utils.MathUtils import net.minecraft.entity.player.EntityPlayer import net.minecraft.init.MobEffects diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/WorldTime.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/WorldTime.kt index 67ada6de6..10aea22d7 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/WorldTime.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/WorldTime.kt @@ -1,8 +1,8 @@ package com.lambda.client.gui.hudgui.elements.world +import com.lambda.client.commons.interfaces.DisplayEnum import com.lambda.client.event.SafeClientEvent import com.lambda.client.gui.hudgui.LabelHud -import com.lambda.client.commons.interfaces.DisplayEnum import org.apache.commons.lang3.time.DurationFormatUtils internal object WorldTime : LabelHud( diff --git a/src/main/kotlin/com/lambda/client/gui/mc/LambdaGuiChat.kt b/src/main/kotlin/com/lambda/client/gui/mc/LambdaGuiChat.kt index 0dd4c11b3..7a02fa782 100644 --- a/src/main/kotlin/com/lambda/client/gui/mc/LambdaGuiChat.kt +++ b/src/main/kotlin/com/lambda/client/gui/mc/LambdaGuiChat.kt @@ -1,6 +1,9 @@ package com.lambda.client.gui.mc import com.lambda.client.command.CommandManager +import com.lambda.client.command.args.AbstractArg +import com.lambda.client.command.args.AutoComplete +import com.lambda.client.command.args.GreedyStringArg import com.lambda.client.mixin.extension.historyBuffer import com.lambda.client.mixin.extension.sentHistoryCursor import com.lambda.client.module.modules.client.GuiColors @@ -9,9 +12,6 @@ import com.lambda.client.util.graphics.RenderUtils2D import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.math.Vec2d import com.lambda.client.util.threads.defaultScope -import com.lambda.client.command.args.AbstractArg -import com.lambda.client.command.args.AutoComplete -import com.lambda.client.command.args.GreedyStringArg import kotlinx.coroutines.launch import net.minecraft.client.gui.GuiChat import org.lwjgl.input.Keyboard diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/Component.kt b/src/main/kotlin/com/lambda/client/gui/rgui/Component.kt index 56ffee9bf..689d53070 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/Component.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/Component.kt @@ -1,6 +1,7 @@ package com.lambda.client.gui.rgui import com.lambda.client.LambdaMod +import com.lambda.client.commons.interfaces.Nameable import com.lambda.client.module.modules.client.ClickGUI import com.lambda.client.setting.GuiConfig import com.lambda.client.setting.GuiConfig.setting @@ -10,7 +11,6 @@ import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.graphics.font.HAlign import com.lambda.client.util.graphics.font.VAlign import com.lambda.client.util.math.Vec2f -import com.lambda.client.commons.interfaces.Nameable import kotlin.math.max open class Component( diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/WindowComponent.kt b/src/main/kotlin/com/lambda/client/gui/rgui/WindowComponent.kt index c67c325fc..9c7d981e5 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/WindowComponent.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/WindowComponent.kt @@ -1,12 +1,12 @@ package com.lambda.client.gui.rgui +import com.lambda.client.commons.interfaces.Nameable import com.lambda.client.setting.GuiConfig.setting import com.lambda.client.setting.configs.AbstractConfig import com.lambda.client.util.graphics.AnimationUtils import com.lambda.client.util.graphics.font.HAlign import com.lambda.client.util.graphics.font.VAlign import com.lambda.client.util.math.Vec2f -import com.lambda.client.commons.interfaces.Nameable import kotlin.math.max import kotlin.math.min diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/component/EnumSlider.kt b/src/main/kotlin/com/lambda/client/gui/rgui/component/EnumSlider.kt index 7b0dd58da..76d404240 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/component/EnumSlider.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/component/EnumSlider.kt @@ -1,5 +1,6 @@ package com.lambda.client.gui.rgui.component +import com.lambda.client.commons.extension.readableName import com.lambda.client.module.modules.client.ClickGUI import com.lambda.client.module.modules.client.CustomFont import com.lambda.client.module.modules.client.GuiColors @@ -7,7 +8,6 @@ import com.lambda.client.setting.settings.impl.primitive.EnumSetting import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.graphics.font.FontRenderAdapter import com.lambda.client.util.math.Vec2f -import com.lambda.client.commons.extension.readableName import kotlin.math.floor class EnumSlider(val setting: EnumSetting<*>) : Slider(setting.name, 0.0, setting.description, setting.visibility) { diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/component/SettingSlider.kt b/src/main/kotlin/com/lambda/client/gui/rgui/component/SettingSlider.kt index 732cbf2fc..3f23c1a22 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/component/SettingSlider.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/component/SettingSlider.kt @@ -1,5 +1,6 @@ package com.lambda.client.gui.rgui.component +import com.lambda.client.commons.utils.MathUtils import com.lambda.client.module.modules.client.ClickGUI import com.lambda.client.module.modules.client.CustomFont import com.lambda.client.module.modules.client.GuiColors @@ -9,7 +10,6 @@ import com.lambda.client.setting.settings.impl.number.NumberSetting import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.graphics.font.FontRenderAdapter import com.lambda.client.util.math.Vec2f -import com.lambda.client.commons.utils.MathUtils import org.lwjgl.input.Keyboard import kotlin.math.abs import kotlin.math.floor diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/windows/BasicWindow.kt b/src/main/kotlin/com/lambda/client/gui/rgui/windows/BasicWindow.kt index 05ee76463..7e542993e 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/windows/BasicWindow.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/windows/BasicWindow.kt @@ -1,5 +1,6 @@ package com.lambda.client.gui.rgui.windows +import com.lambda.client.commons.interfaces.Nameable import com.lambda.client.module.modules.client.ClickGUI import com.lambda.client.module.modules.client.GuiColors import com.lambda.client.setting.GuiConfig @@ -8,7 +9,6 @@ import com.lambda.client.util.graphics.RenderUtils2D import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.math.Vec2d import com.lambda.client.util.math.Vec2f -import com.lambda.client.commons.interfaces.Nameable /** * Window with rectangle rendering diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/windows/CleanWindow.kt b/src/main/kotlin/com/lambda/client/gui/rgui/windows/CleanWindow.kt index 019185c6a..d4242978b 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/windows/CleanWindow.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/windows/CleanWindow.kt @@ -1,9 +1,9 @@ package com.lambda.client.gui.rgui.windows +import com.lambda.client.commons.interfaces.Nameable import com.lambda.client.gui.rgui.WindowComponent import com.lambda.client.setting.GuiConfig import com.lambda.client.setting.configs.AbstractConfig -import com.lambda.client.commons.interfaces.Nameable /** * Window with no rendering diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/windows/ListWindow.kt b/src/main/kotlin/com/lambda/client/gui/rgui/windows/ListWindow.kt index 41c210976..dd00cad74 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/windows/ListWindow.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/windows/ListWindow.kt @@ -1,5 +1,8 @@ package com.lambda.client.gui.rgui.windows +import com.lambda.client.commons.extension.ceilToInt +import com.lambda.client.commons.extension.floorToInt +import com.lambda.client.commons.extension.sumByFloat import com.lambda.client.gui.AbstractLambdaGui import com.lambda.client.gui.rgui.Component import com.lambda.client.gui.rgui.InteractiveComponent @@ -8,9 +11,6 @@ import com.lambda.client.util.TickTimer import com.lambda.client.util.graphics.GlStateUtils import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.math.Vec2f -import com.lambda.client.commons.extension.ceilToInt -import com.lambda.client.commons.extension.floorToInt -import com.lambda.client.commons.extension.sumByFloat import kotlinx.coroutines.runBlocking import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/windows/SettingWindow.kt b/src/main/kotlin/com/lambda/client/gui/rgui/windows/SettingWindow.kt index 6191c03b5..9c1fdd639 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/windows/SettingWindow.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/windows/SettingWindow.kt @@ -1,5 +1,6 @@ package com.lambda.client.gui.rgui.windows +import com.lambda.client.commons.extension.sumByFloat import com.lambda.client.gui.rgui.component.* import com.lambda.client.module.modules.client.ClickGUI import com.lambda.client.setting.settings.AbstractSetting @@ -11,7 +12,6 @@ import com.lambda.client.setting.settings.impl.primitive.EnumSetting import com.lambda.client.setting.settings.impl.primitive.StringSetting import com.lambda.client.util.graphics.font.FontRenderAdapter import com.lambda.client.util.math.Vec2f -import com.lambda.client.commons.extension.sumByFloat import org.lwjgl.input.Keyboard abstract class SettingWindow( diff --git a/src/main/kotlin/com/lambda/client/manager/ManagerLoader.kt b/src/main/kotlin/com/lambda/client/manager/ManagerLoader.kt index f2455fd08..7aa49de7b 100644 --- a/src/main/kotlin/com/lambda/client/manager/ManagerLoader.kt +++ b/src/main/kotlin/com/lambda/client/manager/ManagerLoader.kt @@ -1,10 +1,10 @@ package com.lambda.client.manager import com.lambda.client.LambdaMod -import com.lambda.client.event.LambdaEventBus -import com.lambda.client.util.StopTimer import com.lambda.client.commons.utils.ClassUtils import com.lambda.client.commons.utils.ClassUtils.instance +import com.lambda.client.event.LambdaEventBus +import com.lambda.client.util.StopTimer import kotlinx.coroutines.Deferred internal object ManagerLoader : com.lambda.client.AsyncLoader>> { diff --git a/src/main/kotlin/com/lambda/client/manager/managers/FriendManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/FriendManager.kt index d089e0efe..882ea1ce4 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/FriendManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/FriendManager.kt @@ -3,11 +3,11 @@ package com.lambda.client.manager.managers import com.google.gson.GsonBuilder import com.google.gson.annotations.SerializedName import com.google.gson.reflect.TypeToken -import com.lambda.client.capeapi.PlayerProfile import com.lambda.client.LambdaMod +import com.lambda.client.capeapi.PlayerProfile +import com.lambda.client.commons.extension.synchronized import com.lambda.client.manager.Manager import com.lambda.client.util.ConfigUtils -import com.lambda.client.commons.extension.synchronized import com.lambda.client.util.FolderUtils import java.io.File import java.io.FileReader diff --git a/src/main/kotlin/com/lambda/client/manager/managers/HotbarManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/HotbarManager.kt index 9d63d26e4..31e55ed75 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/HotbarManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/HotbarManager.kt @@ -1,6 +1,11 @@ package com.lambda.client.manager.managers +import com.lambda.client.commons.extension.firstEntryOrNull +import com.lambda.client.commons.extension.firstKeyOrNull +import com.lambda.client.commons.extension.firstValue +import com.lambda.client.commons.extension.synchronized import com.lambda.client.event.events.PacketEvent +import com.lambda.client.event.listener.listener import com.lambda.client.manager.Manager import com.lambda.client.mixin.extension.currentPlayerItem import com.lambda.client.module.AbstractModule @@ -8,11 +13,6 @@ import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeoutFlag import com.lambda.client.util.items.HotbarSlot import com.lambda.client.util.threads.runSafe -import com.lambda.client.commons.extension.firstEntryOrNull -import com.lambda.client.commons.extension.firstKeyOrNull -import com.lambda.client.commons.extension.firstValue -import com.lambda.client.commons.extension.synchronized -import com.lambda.client.event.listener.listener import net.minecraft.client.entity.EntityPlayerSP import net.minecraft.item.ItemStack import net.minecraft.network.play.client.CPacketHeldItemChange diff --git a/src/main/kotlin/com/lambda/client/manager/managers/MacroManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/MacroManager.kt index 1bbdd5f14..31a22763e 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/MacroManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/MacroManager.kt @@ -4,11 +4,11 @@ import com.google.gson.GsonBuilder import com.google.gson.reflect.TypeToken import com.lambda.client.LambdaMod import com.lambda.client.command.CommandManager +import com.lambda.client.event.listener.listener import com.lambda.client.manager.Manager import com.lambda.client.util.ConfigUtils -import com.lambda.client.util.text.MessageSendHelper -import com.lambda.client.event.listener.listener import com.lambda.client.util.FolderUtils +import com.lambda.client.util.text.MessageSendHelper import net.minecraftforge.fml.common.gameevent.InputEvent import org.lwjgl.input.Keyboard import java.io.File diff --git a/src/main/kotlin/com/lambda/client/manager/managers/MessageManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/MessageManager.kt index 5f94abe1c..594ecd579 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/MessageManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/MessageManager.kt @@ -1,6 +1,7 @@ package com.lambda.client.manager.managers import com.lambda.client.event.events.PacketEvent +import com.lambda.client.event.listener.listener import com.lambda.client.manager.Manager import com.lambda.client.mixin.extension.chatMessage import com.lambda.client.module.AbstractModule @@ -8,7 +9,6 @@ import com.lambda.client.module.modules.client.ChatSetting import com.lambda.client.util.TaskState import com.lambda.client.util.TickTimer import com.lambda.client.util.threads.safeListener -import com.lambda.client.event.listener.listener import net.minecraft.network.play.client.CPacketChatMessage import net.minecraftforge.fml.common.gameevent.TickEvent import java.util.* diff --git a/src/main/kotlin/com/lambda/client/manager/managers/PlayerInventoryManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/PlayerInventoryManager.kt index 33e6cf6f5..940201b05 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/PlayerInventoryManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/PlayerInventoryManager.kt @@ -1,63 +1,186 @@ package com.lambda.client.manager.managers +import com.lambda.client.LambdaMod +import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.ConnectionEvent +import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.events.RenderOverlayEvent +import com.lambda.client.event.listener.listener import com.lambda.client.manager.Manager -import com.lambda.client.mixin.extension.syncCurrentPlayItem import com.lambda.client.module.AbstractModule +import com.lambda.client.module.modules.player.LagNotifier +import com.lambda.client.module.modules.player.NoGhostItems +import com.lambda.client.module.modules.player.NoGhostItems.debugLog +import com.lambda.client.process.PauseProcess.pauseBaritone +import com.lambda.client.process.PauseProcess.unpauseBaritone import com.lambda.client.util.TaskState import com.lambda.client.util.TickTimer -import com.lambda.client.util.TpsCalculator -import com.lambda.client.util.items.clickSlot import com.lambda.client.util.items.removeHoldingItem +import com.lambda.client.util.threads.onMainThreadSafe import com.lambda.client.util.threads.safeListener -import com.lambda.client.event.listener.listener +import kotlinx.coroutines.runBlocking import net.minecraft.client.gui.inventory.GuiContainer import net.minecraft.inventory.ClickType -import java.util.* - +import net.minecraft.inventory.Container +import net.minecraft.item.ItemStack +import net.minecraft.network.play.client.CPacketClickWindow +import net.minecraft.network.play.server.SPacketConfirmTransaction +import java.util.concurrent.ConcurrentSkipListSet + +/** + * @see NoGhostItems + */ object PlayerInventoryManager : Manager { - private val timer = TickTimer() - private val lockObject = Any() - private val actionQueue = TreeSet(Comparator.reverseOrder()) + private val transactionTimer = TickTimer() + private val transactionQueue = ConcurrentSkipListSet(Comparator.reverseOrder()) private var currentId = 0 - private var currentTask: InventoryTask? = null init { + safeListener { event -> + val packet = event.packet + if (packet is SPacketConfirmTransaction && transactionQueue.isNotEmpty()) { + val currentTask = transactionQueue.first() + val clickInfo = currentTask.currentInfo() ?: return@safeListener + + if (packet.actionNumber == clickInfo.transactionId + && packet.windowId == clickInfo.windowId + ) { + if (!packet.wasAccepted()) { + LambdaMod.LOG.error("Transaction ${clickInfo.transactionId} was denied. Skipping task. (id=${packet.actionNumber}, window=${packet.windowId})") + unpauseModule(currentTask.owner) + next() + return@safeListener + } + + if (debugLog) LambdaMod.LOG.info("Transaction accepted. (id=${packet.actionNumber}, window=${packet.windowId})") + getContainerOrNull(packet.windowId)?.let { container -> + container.slotClick(clickInfo.slot, clickInfo.mouseButton, clickInfo.type, player) + + currentTask.nextInfo() + if (currentTask.isDone) transactionQueue.pollFirst() + + unpauseModule(currentTask.owner) + } ?: run { + LambdaMod.LOG.error("Container outdated in window: ${player.openContainer}. Skipping task. (id=${packet.actionNumber}, window=${packet.windowId})") + unpauseModule(currentTask.owner) + next() + } + } + } + } + safeListener(0) { - if (!timer.tick((1000.0f / TpsCalculator.tickRate).toLong())) return@safeListener + if (LagNotifier.isBaritonePaused) return@safeListener - if (!player.inventory.itemStack.isEmpty) { - if (mc.currentScreen is GuiContainer) timer.reset(250L) // Wait for 5 extra ticks if player is moving item - else removeHoldingItem() + if (transactionQueue.isEmpty()) { + currentId = 0 + if (NoGhostItems.baritoneSync) NoGhostItems.unpauseBaritone() return@safeListener } - getTaskOrNext()?.nextInfo()?.let { - clickSlot(it.windowId, it.slot, it.mouseButton, it.type) - playerController.syncCurrentPlayItem() + if (currentId == 0 && !player.inventory.itemStack.isEmpty) { + if (mc.currentScreen is GuiContainer) transactionTimer.reset(250L) // Wait for 5 extra ticks if player is moving item + else removeHoldingItem(NoGhostItems) + return@safeListener } - if (actionQueue.isEmpty()) currentId = 0 + transactionQueue.firstOrNull()?.let { currentTask -> + currentTask.currentInfo()?.let { currentInfo -> + if (currentInfo.transactionId < 0 || transactionTimer.tick(NoGhostItems.timeout, false)) { + if (currentInfo.tries > NoGhostItems.maxRetries) { + LambdaMod.LOG.error("Max inventory transaction tries exceeded. Skipping task.") + unpauseModule(currentTask.owner) + next() + } + + deployWindowClick(currentInfo, currentTask) + transactionTimer.reset() + } + } + } } listener { - actionQueue.clear() - currentId = 0 + reset() + } + } + + private fun SafeClientEvent.deployWindowClick(currentInfo: ClickInfo, currentTask: InventoryTask) { + val transactionId = clickSlotServerSide(currentInfo, currentTask) + if (transactionId > -1) { + currentInfo.transactionId = transactionId + currentInfo.tries++ + if (debugLog) LambdaMod.LOG.info("Transaction successfully initiated. ${transactionQueue.size} left. $currentInfo") + } else { + LambdaMod.LOG.error("Container outdated. Skipping task. $currentInfo") + unpauseModule(currentTask.owner) + next() + } + } + + /** + * Sends transaction of inventory clicking in specific window, slot, mouseButton, and click type without performing client side changes. + * + * @return Transaction id + */ + private fun SafeClientEvent.clickSlotServerSide(currentInfo: ClickInfo, currentTask: InventoryTask): Short { + var transactionID: Short = -1 + + getContainerOrNull(currentInfo.windowId)?.let { activeContainer -> + player.inventory?.let { inventory -> + transactionID = activeContainer.getNextTransactionID(inventory) + + val itemStack = if (currentInfo.type == ClickType.PICKUP && currentInfo.slot != -999) { + activeContainer.inventorySlots?.getOrNull(currentInfo.slot)?.stack ?: ItemStack.EMPTY + } else { + ItemStack.EMPTY + } + + connection.sendPacket(CPacketClickWindow( + currentInfo.windowId, + currentInfo.slot, + currentInfo.mouseButton, + currentInfo.type, + itemStack, + transactionID + )) + + runBlocking { + onMainThreadSafe { playerController.updateController() } + } + } + } ?: run { + LambdaMod.LOG.error("Container outdated. Skipping task. $currentInfo") + unpauseModule(currentTask.owner) + next() } + + return transactionID } - private fun getTaskOrNext() = - currentTask?.let { - if (!it.isDone) it - else null - } ?: synchronized(lockObject) { - actionQueue.removeIf { it.isDone } - actionQueue.firstOrNull() + private fun SafeClientEvent.getContainerOrNull(windowId: Int): Container? = + if (windowId == player.openContainer.windowId) { + player.openContainer + } else { + null } - fun isDone() = actionQueue.isEmpty() + private fun unpauseModule(owner: AbstractModule?) { + owner?.let { if (transactionQueue.none { it.owner == owner }) owner.unpause() } + } + + fun next() { + transactionQueue.pollFirst() + transactionTimer.skipTime(NoGhostItems.timeout) + } + + fun reset() { + transactionQueue.clear() + currentId = 0 + } + + fun isDone() = transactionQueue.isEmpty() /** * Adds a new task to the inventory manager respecting the module origin. @@ -66,29 +189,33 @@ object PlayerInventoryManager : Manager { * * @return [TaskState] representing the state of this task */ - fun AbstractModule.addInventoryTask(vararg clickInfo: ClickInfo) = - InventoryTask(currentId++, modulePriority, clickInfo).let { - actionQueue.add(it) + fun AbstractModule.addInventoryTask(vararg clickInfo: ClickInfo): TaskState { + if (NoGhostItems.baritoneSync) NoGhostItems.pauseBaritone() + if (!isPaused) pause() + return InventoryTask(currentId++, this, clickInfo).let { + transactionQueue.add(it) it.taskState } + } private data class InventoryTask( private val id: Int, - private val priority: Int, + val owner: AbstractModule?, private val infoArray: Array, val taskState: TaskState = TaskState(), private var index: Int = 0 ) : Comparable { val isDone get() = taskState.done - fun nextInfo() = - infoArray.getOrNull(index++).also { - if (it == null) taskState.done = true - } + fun currentInfo() = infoArray.getOrNull(index) + fun nextInfo() { + index++ + if (currentInfo() == null) taskState.done = true + } override fun compareTo(other: InventoryTask): Int { - val result = priority - other.priority + val result = (owner?.modulePriority ?: 0) - (other.owner?.modulePriority ?: 0) return if (result != 0) result else other.id - id } @@ -103,9 +230,24 @@ object PlayerInventoryManager : Manager { return true } + override fun toString(): String { + return if (owner != null) { + "id: $id priority: ${owner.modulePriority} taskState: ${taskState.done} index: $index \n${infoArray.joinToString("\n")}" + } else { + "id: $id taskState: ${taskState.done} index: $index \n${infoArray.joinToString("\n")}" + } + } + override fun hashCode() = 31 * infoArray.contentHashCode() + index } - data class ClickInfo(val windowId: Int = 0, val slot: Int, val mouseButton: Int = 0, val type: ClickType) + data class ClickInfo(val windowId: Int = 0, val slot: Int, val mouseButton: Int = 0, val type: ClickType) { + var transactionId: Short = -1 + var tries = 0 + + override fun toString(): String { + return "(id=$transactionId, tries=$tries, windowId=$windowId, slot=$slot, mouseButton=$mouseButton, type=$type)" + } + } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/manager/managers/PlayerPacketManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/PlayerPacketManager.kt index 2bad800b8..7a27dcda5 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/PlayerPacketManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/PlayerPacketManager.kt @@ -4,13 +4,13 @@ import com.lambda.client.event.Phase import com.lambda.client.event.events.OnUpdateWalkingPlayerEvent import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.events.RenderEntityEvent +import com.lambda.client.event.listener.listener import com.lambda.client.manager.Manager import com.lambda.client.mixin.extension.* import com.lambda.client.module.AbstractModule import com.lambda.client.util.Wrapper import com.lambda.client.util.math.Vec2f import com.lambda.client.util.threads.safeListener -import com.lambda.client.event.listener.listener import net.minecraft.network.play.client.CPacketPlayer import net.minecraft.util.math.Vec3d import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/src/main/kotlin/com/lambda/client/manager/managers/TimerManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/TimerManager.kt index 804e3f035..e421a039d 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/TimerManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/TimerManager.kt @@ -1,14 +1,14 @@ package com.lambda.client.manager.managers +import com.lambda.client.commons.extension.synchronized import com.lambda.client.event.events.RunGameLoopEvent +import com.lambda.client.event.listener.listener import com.lambda.client.manager.Manager import com.lambda.client.mixin.extension.tickLength import com.lambda.client.mixin.extension.timer import com.lambda.client.module.AbstractModule import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit -import com.lambda.client.commons.extension.synchronized -import com.lambda.client.event.listener.listener import java.util.* object TimerManager : Manager { diff --git a/src/main/kotlin/com/lambda/client/manager/managers/UUIDManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/UUIDManager.kt index 2cadb8358..bf0a240b0 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/UUIDManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/UUIDManager.kt @@ -1,9 +1,9 @@ package com.lambda.client.manager.managers +import com.lambda.client.LambdaMod import com.lambda.client.capeapi.AbstractUUIDManager import com.lambda.client.capeapi.PlayerProfile import com.lambda.client.capeapi.UUIDUtils -import com.lambda.client.LambdaMod import com.lambda.client.manager.Manager import com.lambda.client.util.FolderUtils import com.lambda.client.util.Wrapper diff --git a/src/main/kotlin/com/lambda/client/mixin/extension/Network.kt b/src/main/kotlin/com/lambda/client/mixin/extension/Network.kt index ff8d568d0..ac73b536d 100644 --- a/src/main/kotlin/com/lambda/client/mixin/extension/Network.kt +++ b/src/main/kotlin/com/lambda/client/mixin/extension/Network.kt @@ -1,7 +1,10 @@ package com.lambda.client.mixin.extension import com.lambda.mixin.accessor.network.* -import net.minecraft.network.play.client.* +import net.minecraft.network.play.client.CPacketChatMessage +import net.minecraft.network.play.client.CPacketCloseWindow +import net.minecraft.network.play.client.CPacketPlayer +import net.minecraft.network.play.client.CPacketUseEntity import net.minecraft.network.play.server.SPacketChat import net.minecraft.network.play.server.SPacketEntityVelocity import net.minecraft.network.play.server.SPacketExplosion diff --git a/src/main/kotlin/com/lambda/client/mixin/extension/Player.kt b/src/main/kotlin/com/lambda/client/mixin/extension/Player.kt index 5f66472e8..80ab9e80c 100644 --- a/src/main/kotlin/com/lambda/client/mixin/extension/Player.kt +++ b/src/main/kotlin/com/lambda/client/mixin/extension/Player.kt @@ -11,4 +11,4 @@ var PlayerControllerMP.blockHitDelay: Int val PlayerControllerMP.currentPlayerItem: Int get() = (this as AccessorPlayerControllerMP).currentPlayerItem -fun PlayerControllerMP.syncCurrentPlayItem() = (this as AccessorPlayerControllerMP).kb_invokeSyncCurrentPlayItem() \ No newline at end of file +fun PlayerControllerMP.syncCurrentPlayItem() = (this as AccessorPlayerControllerMP).synchronizeCurrentPlayItem() \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/module/AbstractModule.kt b/src/main/kotlin/com/lambda/client/module/AbstractModule.kt index fab8bf006..98801b158 100644 --- a/src/main/kotlin/com/lambda/client/module/AbstractModule.kt +++ b/src/main/kotlin/com/lambda/client/module/AbstractModule.kt @@ -1,5 +1,7 @@ package com.lambda.client.module +import com.lambda.client.commons.interfaces.Alias +import com.lambda.client.commons.interfaces.Nameable import com.lambda.client.event.LambdaEventBus import com.lambda.client.event.events.ModuleToggleEvent import com.lambda.client.gui.clickgui.LambdaClickGui @@ -12,8 +14,6 @@ import com.lambda.client.setting.settings.impl.other.BindSetting import com.lambda.client.setting.settings.impl.primitive.BooleanSetting import com.lambda.client.util.Bind import com.lambda.client.util.text.MessageSendHelper -import com.lambda.client.commons.interfaces.Alias -import com.lambda.client.commons.interfaces.Nameable import net.minecraft.client.Minecraft @Suppress("UNCHECKED_CAST") @@ -42,6 +42,7 @@ abstract class AbstractModule( val isEnabled: Boolean get() = enabled.value || alwaysEnabled val isDisabled: Boolean get() = !isEnabled + var isPaused = false val chatName: String get() = "[${name}]" val isVisible: Boolean get() = visible.value @@ -56,6 +57,7 @@ abstract class AbstractModule( fun toggle() { enabled.value = !enabled.value + isPaused = false if (enabled.value) clicks.value++ } @@ -68,6 +70,16 @@ abstract class AbstractModule( enabled.value = false } + fun pause() { + isPaused = true + LambdaEventBus.unsubscribe(this) + } + + fun unpause() { + isPaused = false + LambdaEventBus.subscribe(this) + } + open fun isActive(): Boolean { return isEnabled || alwaysListening } diff --git a/src/main/kotlin/com/lambda/client/module/ModuleManager.kt b/src/main/kotlin/com/lambda/client/module/ModuleManager.kt index c39b51064..407dcc0ec 100644 --- a/src/main/kotlin/com/lambda/client/module/ModuleManager.kt +++ b/src/main/kotlin/com/lambda/client/module/ModuleManager.kt @@ -2,13 +2,13 @@ package com.lambda.client.module import com.lambda.client.AsyncLoader import com.lambda.client.LambdaMod +import com.lambda.client.commons.collections.AliasSet +import com.lambda.client.commons.utils.ClassUtils +import com.lambda.client.commons.utils.ClassUtils.instance import com.lambda.client.event.LambdaEventBus import com.lambda.client.util.AsyncCachedValue import com.lambda.client.util.StopTimer import com.lambda.client.util.TimeUnit -import com.lambda.client.commons.collections.AliasSet -import com.lambda.client.commons.utils.ClassUtils -import com.lambda.client.commons.utils.ClassUtils.instance import kotlinx.coroutines.Deferred import org.lwjgl.input.Keyboard import java.lang.reflect.Modifier diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/AutoTPA.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/AutoTPA.kt index 0fbabdb3b..6079e8a6d 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/AutoTPA.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/AutoTPA.kt @@ -1,12 +1,12 @@ package com.lambda.client.module.modules.chat import com.lambda.client.event.events.PacketEvent +import com.lambda.client.event.listener.listener import com.lambda.client.manager.managers.FriendManager import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.text.MessageDetection import com.lambda.client.util.text.MessageSendHelper.sendServerMessage -import com.lambda.client.event.listener.listener import net.minecraft.network.play.server.SPacketChat object AutoTPA : Module( diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/ChatFilter.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/ChatFilter.kt index 0028f94f4..74861e861 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/ChatFilter.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/ChatFilter.kt @@ -1,12 +1,12 @@ package com.lambda.client.module.modules.chat +import com.lambda.client.event.listener.listener import com.lambda.client.module.Category import com.lambda.client.module.Module +import com.lambda.client.util.FolderUtils import com.lambda.client.util.text.MessageDetection import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.formatValue -import com.lambda.client.event.listener.listener -import com.lambda.client.util.FolderUtils import net.minecraftforge.client.event.ClientChatReceivedEvent import java.io.File import java.io.FileNotFoundException diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/FriendHighlight.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/FriendHighlight.kt index 338a12940..90269b2d5 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/FriendHighlight.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/FriendHighlight.kt @@ -1,11 +1,11 @@ package com.lambda.client.module.modules.chat +import com.lambda.client.event.listener.listener import com.lambda.client.manager.managers.FriendManager import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.color.EnumTextColor import com.lambda.client.util.text.MessageSendHelper -import com.lambda.client.event.listener.listener import net.minecraft.client.audio.PositionedSoundRecord import net.minecraft.init.SoundEvents import net.minecraft.util.text.TextComponentString diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/LoginMessage.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/LoginMessage.kt index 2ec412903..7f86ab631 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/LoginMessage.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/LoginMessage.kt @@ -4,14 +4,13 @@ import com.lambda.client.event.events.ConnectionEvent import com.lambda.client.event.listener.listener import com.lambda.client.module.Category import com.lambda.client.module.Module +import com.lambda.client.util.FolderUtils import com.lambda.client.util.MovementUtils.isMoving import com.lambda.client.util.text.MessageDetection import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.MessageSendHelper.sendServerMessage import com.lambda.client.util.threads.defaultScope import com.lambda.client.util.threads.safeListener -import com.lambda.client.event.listener.listener -import com.lambda.client.util.FolderUtils import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/PortalChat.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/PortalChat.kt index 28e4dd80f..d1e6105fb 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/PortalChat.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/PortalChat.kt @@ -1,8 +1,8 @@ package com.lambda.client.module.modules.chat -import com.lambda.mixin.player.MixinEntityPlayerSP import com.lambda.client.module.Category import com.lambda.client.module.Module +import com.lambda.mixin.player.MixinEntityPlayerSP /** * @see MixinEntityPlayerSP diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/ClickGUI.kt b/src/main/kotlin/com/lambda/client/module/modules/client/ClickGUI.kt index 5a733f41a..6edbb12ce 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/ClickGUI.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/ClickGUI.kt @@ -1,12 +1,12 @@ package com.lambda.client.module.modules.client import com.lambda.client.event.events.ShutdownEvent +import com.lambda.client.event.listener.listener import com.lambda.client.gui.clickgui.LambdaClickGui import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.StopTimer import com.lambda.client.util.threads.safeListener -import com.lambda.client.event.listener.listener import net.minecraftforge.fml.common.gameevent.TickEvent import org.lwjgl.input.Keyboard import kotlin.math.round diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/HudEditor.kt b/src/main/kotlin/com/lambda/client/module/modules/client/HudEditor.kt index 45daa799d..df7d35d8e 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/HudEditor.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/HudEditor.kt @@ -1,10 +1,10 @@ package com.lambda.client.module.modules.client import com.lambda.client.event.events.ShutdownEvent +import com.lambda.client.event.listener.listener import com.lambda.client.gui.hudgui.LambdaHudGui import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.client.event.listener.listener object HudEditor : Module( name = "HudEditor", diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoArmor.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoArmor.kt index 6465d4045..752943522 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoArmor.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoArmor.kt @@ -23,28 +23,8 @@ object AutoArmor : Module( category = Category.COMBAT, modulePriority = 500 ) { - private val delay by setting("Delay", 5, 1..10, 1, unit = " ticks") - - private val timer = TickTimer(TimeUnit.TICKS) - private var lastTask = TaskState(true) - - var isPaused = false - init { - onToggle { - isPaused = false - } - safeListener { - if (isPaused) return@safeListener - if (!timer.tick(delay.toLong()) || !lastTask.done) return@safeListener - - if (!player.inventory.itemStack.isEmpty) { - if (mc.currentScreen is GuiContainer) timer.reset(150L) // Wait for 3 extra ticks if player is moving item - else removeHoldingItem() - return@safeListener - } - // store slots and values of best armor pieces, initialize with currently equipped armor // Pair val bestArmors = Array(4) { -1 to getArmorValue(player.inventory.armorInventory[it]) } @@ -91,7 +71,7 @@ object AutoArmor : Module( private fun SafeClientEvent.equipArmor(bestArmors: Array>) { for ((index, pair) in bestArmors.withIndex()) { if (pair.first == -1) continue // Skip if we didn't find a better armor - lastTask = if (player.inventoryContainer.inventory[8 - index].isEmpty) { + if (player.inventoryContainer.inventory[8 - index].isEmpty) { addInventoryTask( PlayerInventoryManager.ClickInfo(0, pair.first, type = ClickType.QUICK_MOVE) // Move the new one into armor slot ) diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoLog.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoLog.kt index a023a902d..ebc75a412 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoLog.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoLog.kt @@ -1,5 +1,6 @@ package com.lambda.client.module.modules.combat +import com.lambda.client.commons.utils.MathUtils import com.lambda.client.event.SafeClientEvent import com.lambda.client.gui.mc.LambdaGuiDisconnected import com.lambda.client.manager.managers.CombatManager @@ -12,7 +13,6 @@ import com.lambda.client.util.combat.CombatUtils.scaledHealth import com.lambda.client.util.items.allSlots import com.lambda.client.util.items.countItem import com.lambda.client.util.threads.safeListener -import com.lambda.client.commons.utils.MathUtils import net.minecraft.client.audio.PositionedSoundRecord import net.minecraft.client.gui.GuiMainMenu import net.minecraft.client.gui.GuiMultiplayer diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoMend.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoMend.kt index da117a984..ce71476e3 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoMend.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoMend.kt @@ -45,7 +45,7 @@ object AutoMend : Module( private var initHotbarSlot = -1 private var isGuiOpened = false - private var paused = false + private var pausedPending = false private val throwDelayTimer = TickTimer(TimeUnit.TICKS) @@ -56,7 +56,7 @@ object AutoMend : Module( init { onEnable { - paused = false + pausedPending = false if (autoSwitch) { runSafe { initHotbarSlot = player.inventory.currentItem @@ -71,7 +71,6 @@ object AutoMend : Module( } } - // TODO: Add proper module pausing system pauseAutoArmor.listeners.add { if (!pauseAutoArmor.value) { AutoArmor.isPaused = false @@ -94,15 +93,15 @@ object AutoMend : Module( if (cancelNearby == NearbyMode.DISABLE) { disable() } else { - if (!paused) + if (!pausedPending) switchback() - paused = true + pausedPending = true } return@safeListener } - paused = false + pausedPending = false // don't call twice in same tick so store in a var val shouldMend = shouldMend(0) || shouldMend(1) || shouldMend(2) || shouldMend(3) @@ -152,8 +151,8 @@ object AutoMend : Module( minSlot = emptySlot + 1 if (emptySlot == -1) break - clickSlot(player.inventoryContainer.windowId, 8 - i, 0, ClickType.PICKUP) - clickSlot(player.inventoryContainer.windowId, emptySlot, 0, ClickType.PICKUP) + clickSlot(this@AutoMend, player.inventoryContainer.windowId, 8 - i, 0, ClickType.PICKUP) + clickSlot(this@AutoMend, player.inventoryContainer.windowId, emptySlot, 0, ClickType.PICKUP) } } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt index 3f316febf..1d027b275 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt @@ -1,21 +1,17 @@ package com.lambda.client.module.modules.combat +import com.lambda.client.commons.extension.next import com.lambda.client.event.SafeClientEvent -import com.lambda.client.event.events.PacketEvent import com.lambda.client.manager.managers.CombatManager import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.Bind -import com.lambda.client.util.TickTimer -import com.lambda.client.util.TimeUnit import com.lambda.client.util.combat.CombatUtils.calcDamageFromMob import com.lambda.client.util.combat.CombatUtils.calcDamageFromPlayer import com.lambda.client.util.combat.CombatUtils.scaledHealth import com.lambda.client.util.items.* import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.safeListener -import com.lambda.client.commons.extension.next -import net.minecraft.client.gui.inventory.GuiContainer import net.minecraft.entity.item.EntityEnderCrystal import net.minecraft.entity.monster.EntityMob import net.minecraft.entity.player.EntityPlayer @@ -25,7 +21,6 @@ import net.minecraft.item.ItemAppleGold import net.minecraft.item.ItemEndCrystal import net.minecraft.item.ItemPotion import net.minecraft.item.ItemStack -import net.minecraft.network.play.server.SPacketConfirmTransaction import net.minecraft.potion.PotionUtils import net.minecraftforge.fml.common.gameevent.InputEvent import net.minecraftforge.fml.common.gameevent.TickEvent @@ -35,6 +30,7 @@ import kotlin.math.ceil object AutoOffhand : Module( name = "AutoOffhand", + alias = arrayOf("AutoTotem"), description = "Manages item in your offhand", category = Category.COMBAT ) { @@ -70,10 +66,6 @@ object AutoOffhand : Module( // General private val priority by setting("Priority", Priority.HOTBAR) private val switchMessage by setting("Switch Message", true) - private val delay by setting("Delay", 2, 1..20, 1, - description = "Ticks to wait between each move") - private val confirmTimeout by setting("Confirm Timeout", 5, 1..20, 1, - description = "Maximum ticks to wait for confirm packets from server") private enum class Type(val filter: (ItemStack) -> Boolean) { TOTEM({ it.item.id == 449 }), @@ -87,9 +79,6 @@ object AutoOffhand : Module( HOTBAR, INVENTORY } - private val transactionLog = HashMap() - private val confirmTimer = TickTimer(TimeUnit.TICKS) - private val movingTimer = TickTimer(TimeUnit.TICKS) private var maxDamage = 0f init { @@ -103,32 +92,11 @@ object AutoOffhand : Module( } } - safeListener { - if (it.packet !is SPacketConfirmTransaction || it.packet.windowId != 0 || !transactionLog.containsKey(it.packet.actionNumber)) return@safeListener - - transactionLog[it.packet.actionNumber] = true - if (!transactionLog.containsValue(false)) { - confirmTimer.reset(confirmTimeout * -50L) // If all the click packets were accepted then we reset the timer for next moving - } - } - safeListener(1100) { if (player.isDead || player.health <= 0.0f) return@safeListener - if (!confirmTimer.tick(confirmTimeout.toLong(), false)) return@safeListener - if (!movingTimer.tick(delay.toLong(), false)) return@safeListener // Delays `delay` ticks - updateDamage() - if (!player.inventory.itemStack.isEmpty) { // If player is holding an in inventory - if (mc.currentScreen is GuiContainer) { // If inventory is open (playing moving item) - movingTimer.reset() // reset movingTimer as the user is currently interacting with the inventory. - } else { // If inventory is not open (ex. inventory desync) - removeHoldingItem() - } - return@safeListener - } - switchToType(getType(), true) } } @@ -168,15 +136,7 @@ object AutoOffhand : Module( getItemSlot(typeOriginal, attempts)?.let { (slot, typeAlt) -> if (slot == player.offhandSlot) return - transactionLog.clear() - moveToSlot(slot, player.offhandSlot).forEach { - transactionLog[it] = false - } - - playerController.updateController() - - confirmTimer.reset() - movingTimer.reset() + moveToSlot(this@AutoOffhand, slot, player.offhandSlot) if (switchMessage) MessageSendHelper.sendChatMessage("$chatName Offhand now has a ${typeAlt.toString().lowercase()}") } diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/BedAura.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/BedAura.kt index 83ecc55e5..924e75596 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/BedAura.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/BedAura.kt @@ -6,6 +6,7 @@ import com.lambda.client.manager.managers.CombatManager import com.lambda.client.manager.managers.PlayerPacketManager.sendPlayerPacket import com.lambda.client.module.Category import com.lambda.client.module.Module +import com.lambda.client.module.modules.player.NoGhostItems import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit import com.lambda.client.util.combat.CrystalUtils.calcCrystalDamage @@ -43,8 +44,8 @@ object BedAura : Module( ) { private val ignoreSecondBaseBlock by setting("Ignore Second Base Block", false) private val suicideMode by setting("Suicide Mode", false) - private val hitDelay by setting("Hit Delay", 5, 1..10, 1) - private val refillDelay by setting("Refill Delay", 2, 1..5, 1) + private val hitDelay by setting("Hit Delay", 5, 1..10, 1, unit = " ticks") + private val refillDelay by setting("Refill Delay", 2, 1..5, 1, unit = " ticks") private val minDamage by setting("Min Damage", 10f, 1f..20f, 0.25f) private val maxSelfDamage by setting("Max Self Damage", 4f, 1f..10f, 0.25f, { !suicideMode }) private val range by setting("Range", 5f, 1f..5f, 0.25f) @@ -98,9 +99,9 @@ object BedAura : Module( } inactiveTicks++ - if (canRefill() && refillTimer.tick(refillDelay.toLong())) { + if (canRefill() && (refillTimer.tick(refillDelay) || (NoGhostItems.syncMode != NoGhostItems.SyncMode.PLAYER && NoGhostItems.isEnabled))) { player.storageSlots.firstItem()?.let { - quickMoveSlot(it) + quickMoveSlot(this@BedAura, it) } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/CombatSetting.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/CombatSetting.kt index 9fbeb561b..f960804a1 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/CombatSetting.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/CombatSetting.kt @@ -1,7 +1,9 @@ package com.lambda.client.module.modules.combat +import com.lambda.client.commons.extension.ceilToInt import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.RenderOverlayEvent +import com.lambda.client.event.listener.listener import com.lambda.client.manager.managers.CombatManager import com.lambda.client.module.Category import com.lambda.client.module.Module @@ -26,8 +28,6 @@ import com.lambda.client.util.threads.defaultScope import com.lambda.client.util.threads.isActiveOrFalse import com.lambda.client.util.threads.runSafeR import com.lambda.client.util.threads.safeListener -import com.lambda.client.commons.extension.ceilToInt -import com.lambda.client.event.listener.listener import kotlinx.coroutines.Job import kotlinx.coroutines.launch import net.minecraft.entity.Entity diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalESP.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalESP.kt index 0812ddc15..1487f6669 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalESP.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalESP.kt @@ -1,9 +1,11 @@ package com.lambda.client.module.modules.combat +import com.lambda.client.commons.utils.MathUtils import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.events.RenderOverlayEvent import com.lambda.client.event.events.RenderWorldEvent +import com.lambda.client.event.listener.listener import com.lambda.client.manager.managers.CombatManager import com.lambda.client.manager.managers.HotbarManager.serverSideItem import com.lambda.client.module.Category @@ -19,8 +21,6 @@ import com.lambda.client.util.graphics.ProjectionUtils import com.lambda.client.util.graphics.font.FontRenderAdapter import com.lambda.client.util.math.VectorUtils.toVec3dCenter import com.lambda.client.util.threads.safeListener -import com.lambda.client.commons.utils.MathUtils -import com.lambda.client.event.listener.listener import net.minecraft.init.Items import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock import net.minecraft.util.EnumHand diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/HoleSnap.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/HoleSnap.kt index bf75fb13d..cdb4023f3 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/HoleSnap.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/HoleSnap.kt @@ -1,9 +1,12 @@ package com.lambda.client.module.modules.combat +import com.lambda.client.commons.extension.ceilToInt +import com.lambda.client.commons.extension.toRadian import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.events.PlayerMoveEvent import com.lambda.client.event.events.RenderWorldEvent +import com.lambda.client.event.listener.listener import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.module.modules.movement.Speed @@ -21,9 +24,6 @@ import com.lambda.client.util.math.VectorUtils.distanceTo import com.lambda.client.util.math.VectorUtils.toVec3d import com.lambda.client.util.threads.safeAsyncListener import com.lambda.client.util.threads.safeListener -import com.lambda.client.commons.extension.ceilToInt -import com.lambda.client.commons.extension.toRadian -import com.lambda.client.event.listener.listener import net.minecraft.network.play.server.SPacketPlayerPosLook import net.minecraft.util.MovementInputFromOptions import net.minecraft.util.math.BlockPos diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt index 1d9a3c585..5d7c6acb8 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt @@ -1,8 +1,10 @@ package com.lambda.client.module.modules.combat import com.lambda.client.LambdaMod +import com.lambda.client.commons.extension.synchronized import com.lambda.client.event.events.ConnectionEvent import com.lambda.client.event.events.PacketEvent +import com.lambda.client.event.listener.listener import com.lambda.client.manager.managers.FriendManager import com.lambda.client.module.Category import com.lambda.client.module.Module @@ -11,8 +13,6 @@ import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.MessageSendHelper.sendServerMessage import com.lambda.client.util.text.format import com.lambda.client.util.threads.safeListener -import com.lambda.client.commons.extension.synchronized -import com.lambda.client.event.listener.listener import net.minecraft.entity.player.EntityPlayer import net.minecraft.network.play.server.SPacketEntityStatus import net.minecraft.util.text.TextFormatting diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/AntiWeather.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/AntiWeather.kt index 4e3bc69b1..9dd9eef76 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/AntiWeather.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/AntiWeather.kt @@ -1,8 +1,8 @@ package com.lambda.client.module.modules.misc -import com.lambda.mixin.world.MixinWorld import com.lambda.client.module.Category import com.lambda.client.module.Module +import com.lambda.mixin.world.MixinWorld /** * @see MixinWorld.getThunderStrengthHead diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/AutoObsidian.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/AutoObsidian.kt index 49df9e241..54c5bc25f 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/AutoObsidian.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/AutoObsidian.kt @@ -437,6 +437,7 @@ object AutoObsidian : Module( swapToSlot(hotbarSlot) } else { val moved = swapToItemOrMove( + this@AutoObsidian, predicateSlot = { val item = it.item val block = item.block @@ -462,6 +463,7 @@ object AutoObsidian : Module( private fun SafeClientEvent.placeEnderChest(pos: BlockPos) { if (!swapToBlock(Blocks.ENDER_CHEST)) { val moved = swapToBlockOrMove( + this@AutoObsidian, Blocks.ENDER_CHEST, predicateSlot = { val item = it.item @@ -488,7 +490,7 @@ object AutoObsidian : Module( val slot = container.getSlots(0..27).firstBlock(Blocks.ENDER_CHEST) if (slot != null) { - clickSlot(container.windowId, slot, 0, ClickType.QUICK_MOVE) + clickSlot(this@AutoObsidian, container.windowId, slot, 0, ClickType.QUICK_MOVE) player.closeScreen() } else if (shulkerOpenTimer.tick(100, false)) { // Wait for maximum of 5 seconds if (leaveEmptyShulkers && container.inventory.subList(0, 27).all { it.isEmpty }) { @@ -593,6 +595,7 @@ object AutoObsidian : Module( if (!swapped) { val moved = swapToItemOrMove( + this@AutoObsidian, Items.DIAMOND_PICKAXE, predicateItem = { EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, it) == 0 diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/AutoReconnect.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/AutoReconnect.kt index ea714f9bc..5150100e8 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/AutoReconnect.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/AutoReconnect.kt @@ -1,13 +1,13 @@ package com.lambda.client.module.modules.misc import com.lambda.client.event.events.GuiEvent +import com.lambda.client.event.listener.listener import com.lambda.client.mixin.extension.message import com.lambda.client.mixin.extension.parentScreen import com.lambda.client.mixin.extension.reason import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.StopTimer -import com.lambda.client.event.listener.listener import net.minecraft.client.gui.GuiDisconnected import net.minecraft.client.multiplayer.GuiConnecting import net.minecraft.client.multiplayer.ServerData diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/AutoTool.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/AutoTool.kt index 8e9ced857..6cb6b9c8d 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/AutoTool.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/AutoTool.kt @@ -5,10 +5,11 @@ import com.lambda.client.event.events.PlayerAttackEvent import com.lambda.client.mixin.extension.syncCurrentPlayItem import com.lambda.client.module.Category import com.lambda.client.module.Module +import com.lambda.client.util.TickTimer +import com.lambda.client.util.TimeUnit import com.lambda.client.util.combat.CombatUtils import com.lambda.client.util.combat.CombatUtils.equipBestWeapon -import com.lambda.client.util.items.hotbarSlots -import com.lambda.client.util.items.swapToSlot +import com.lambda.client.util.items.* import com.lambda.client.util.threads.safeListener import net.minecraft.block.state.IBlockState import net.minecraft.enchantment.EnchantmentHelper @@ -24,13 +25,13 @@ object AutoTool : Module( category = Category.MISC ) { private val switchBack = setting("Switch Back", true) - private val timeout by setting("Timeout", 20, 1..100, 5, { switchBack.value }, unit = "s") + private val timeout by setting("Timeout", 1, 1..20, 1, { switchBack.value }, unit = " ticks") private val swapWeapon by setting("Switch Weapon", false) private val preferWeapon by setting("Prefer", CombatUtils.PreferWeapon.SWORD) private var shouldMoveBack = false - private var lastSlot = 0 - private var lastChange = 0L + private var startSlot = 0 + private var switchTimer = TickTimer(TimeUnit.TICKS) init { safeListener { @@ -46,13 +47,13 @@ object AutoTool : Module( val mouse = Mouse.isButtonDown(0) if (mouse && !shouldMoveBack) { - lastChange = System.currentTimeMillis() + switchTimer.reset() shouldMoveBack = true - lastSlot = player.inventory.currentItem + startSlot = player.inventory.currentItem playerController.syncCurrentPlayItem() - } else if (!mouse && shouldMoveBack && (lastChange + timeout * 10 < System.currentTimeMillis())) { + } else if (!mouse && shouldMoveBack && switchTimer.tick(timeout, false)) { shouldMoveBack = false - player.inventory.currentItem = lastSlot + player.inventory.currentItem = startSlot playerController.syncCurrentPlayItem() } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/AutoTunnel.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/AutoTunnel.kt index 73fd51938..0b7405840 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/AutoTunnel.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/AutoTunnel.kt @@ -2,15 +2,15 @@ package com.lambda.client.module.modules.misc import com.lambda.client.event.events.BaritoneCommandEvent import com.lambda.client.event.events.ConnectionEvent +import com.lambda.client.event.listener.listener import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.module.modules.movement.AutoWalk import com.lambda.client.util.BaritoneUtils import com.lambda.client.util.math.RotationUtils import com.lambda.client.util.text.MessageSendHelper -import com.lambda.client.util.threads.safeListener -import com.lambda.client.event.listener.listener import com.lambda.client.util.text.capitalize +import com.lambda.client.util.threads.safeListener import net.minecraft.util.EnumFacing import net.minecraftforge.fml.common.gameevent.TickEvent import kotlin.math.round diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/PingSpoof.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/PingSpoof.kt index d7643eb34..ba8cfb20d 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/PingSpoof.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/PingSpoof.kt @@ -1,11 +1,11 @@ package com.lambda.client.module.modules.misc import com.lambda.client.event.events.PacketEvent +import com.lambda.client.event.listener.listener import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.threads.defaultScope import com.lambda.client.util.threads.onMainThreadSafe -import com.lambda.client.event.listener.listener import kotlinx.coroutines.delay import kotlinx.coroutines.launch import net.minecraft.network.play.client.CPacketKeepAlive diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/TeleportLogger.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/TeleportLogger.kt index add523c75..fd7d736d6 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/TeleportLogger.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/TeleportLogger.kt @@ -1,12 +1,12 @@ package com.lambda.client.module.modules.misc +import com.lambda.client.commons.utils.MathUtils import com.lambda.client.manager.managers.WaypointManager import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.EntityUtils.isFakeOrSelf import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.safeListener -import com.lambda.client.commons.utils.MathUtils import net.minecraft.util.math.BlockPos import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/AutoWalk.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/AutoWalk.kt index b807d1696..20013a055 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/AutoWalk.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/AutoWalk.kt @@ -70,7 +70,7 @@ object AutoWalk : Module( } listener(6969) { - if (LagNotifier.paused && LagNotifier.pauseAutoWalk) return@listener + if (LagNotifier.isBaritonePaused && LagNotifier.pauseAutoWalk) return@listener if (it.movementInput !is MovementInputFromOptions) return@listener diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/BoatFly.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/BoatFly.kt index 411c2a233..15804c44b 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/BoatFly.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/BoatFly.kt @@ -55,8 +55,8 @@ object BoatFly : Module( if (ridingEntity !is EntityBoat || !cancelPlayer) return@safeListener if (it.packet is CPacketPlayer - || it.packet is CPacketInput - || it.packet is CPacketSteerBoat) { + || it.packet is CPacketInput + || it.packet is CPacketSteerBoat) { if (it.packet is CPacketInput && it.packet == CPacketInput(0.0f, 0.0f, false, true)) { return@safeListener } else { diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt index 5839b5918..0f0729530 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt @@ -95,9 +95,9 @@ object ElytraFlight : Module( /* Vanilla */ - private val upPitch by setting("Up Pitch", 50f,0f..90f, 5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }) - private val downPitch by setting("Down Pitch", 30f,0f..90f, 5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }) - private val rocketPitch by setting("Rocket Pitch", 50f,0f..90f, 5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }) + private val upPitch by setting("Up Pitch", 50f, 0f..90f, 5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }) + private val downPitch by setting("Down Pitch", 30f, 0f..90f, 5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }) + private val rocketPitch by setting("Rocket Pitch", 50f, 0f..90f, 5f, { mode.value == ElytraFlightMode.VANILLA && page == Page.MODE_SETTINGS }) /* End of Mode Settings */ @@ -262,7 +262,7 @@ object ElytraFlight : Module( sendChatMessage("$chatName Liquid below, disabling.") autoLanding = false } - LagNotifier.paused && LagNotifier.pauseTakeoff -> { + LagNotifier.isBaritonePaused && LagNotifier.pauseTakeoff -> { holdPlayer(event) } player.capabilities.isFlying || !player.isElytraFlying || isPacketFlying -> { @@ -297,8 +297,8 @@ object ElytraFlight : Module( val height = if (highPingOptimize) 0.0f else minTakeoffHeight val closeToGround = player.posY <= world.getGroundPos(player).y + height && !wasInLiquid && !mc.isSingleplayer - if (!easyTakeOff || (LagNotifier.paused && LagNotifier.pauseTakeoff) || player.onGround) { - if (LagNotifier.paused && LagNotifier.pauseTakeoff && player.posY - world.getGroundPos(player).y > 4.0f) holdPlayer(event) /* Holds player in the air if server is lagging and the distance is enough for taking fall damage */ + if (!easyTakeOff || (LagNotifier.isBaritonePaused && LagNotifier.pauseTakeoff) || player.onGround) { + if (LagNotifier.isBaritonePaused && LagNotifier.pauseTakeoff && player.posY - world.getGroundPos(player).y > 4.0f) holdPlayer(event) /* Holds player in the air if server is lagging and the distance is enough for taking fall damage */ reset(player.onGround) return } diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt index 03ac35c01..659f3263b 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt @@ -1,5 +1,7 @@ package com.lambda.client.module.modules.movement +import com.lambda.client.commons.extension.ceilToInt +import com.lambda.client.commons.extension.floorToInt import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.events.PlayerTravelEvent import com.lambda.client.mixin.extension.playerMoving @@ -9,8 +11,6 @@ import com.lambda.client.module.Module import com.lambda.client.util.BaritoneUtils import com.lambda.client.util.EntityUtils import com.lambda.client.util.threads.safeListener -import com.lambda.client.commons.extension.ceilToInt -import com.lambda.client.commons.extension.floorToInt import net.minecraft.block.Block import net.minecraft.block.BlockLiquid import net.minecraft.entity.Entity diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/NoSlowDown.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/NoSlowDown.kt index 448b6d69a..db72e04df 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/NoSlowDown.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/NoSlowDown.kt @@ -5,14 +5,11 @@ import com.lambda.client.event.events.PacketEvent import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.EntityUtils.flooredPosition -import com.lambda.client.util.MovementUtils.isMoving import com.lambda.client.util.threads.safeListener import com.lambda.mixin.world.MixinBlockSoulSand import com.lambda.mixin.world.MixinBlockWeb import net.minecraft.init.Blocks import net.minecraft.item.* -import net.minecraft.network.play.client.CPacketClickWindow -import net.minecraft.network.play.client.CPacketEntityAction import net.minecraft.network.play.client.CPacketPlayer import net.minecraft.network.play.client.CPacketPlayerDigging import net.minecraft.network.play.client.CPacketPlayerDigging.Action diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/SafeWalk.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/SafeWalk.kt index 1a7797cf9..cfa2226fc 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/SafeWalk.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/SafeWalk.kt @@ -1,6 +1,5 @@ package com.lambda.client.module.modules.movement -import com.lambda.mixin.entity.MixinEntity import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.module.modules.player.Scaffold @@ -9,6 +8,7 @@ import com.lambda.client.util.EntityUtils.flooredPosition import com.lambda.client.util.Wrapper import com.lambda.client.util.math.VectorUtils.toVec3d import com.lambda.client.util.threads.runSafeR +import com.lambda.mixin.entity.MixinEntity /** * @see MixinEntity.moveInvokeIsSneakingPre diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt index 3857445e8..f649cf49a 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt @@ -2,10 +2,12 @@ package com.lambda.client.module.modules.movement import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.PacketEvent +import com.lambda.client.event.listener.listener import com.lambda.client.manager.managers.PlayerPacketManager import com.lambda.client.mixin.extension.playerY import com.lambda.client.module.Category import com.lambda.client.module.Module +import com.lambda.client.module.modules.combat.Surround.inHoleCheck import com.lambda.client.setting.settings.impl.primitive.BooleanSetting import com.lambda.client.util.BaritoneUtils import com.lambda.client.util.Bind @@ -13,8 +15,6 @@ import com.lambda.client.util.EntityUtils.isInOrAboveLiquid import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener -import com.lambda.client.event.listener.listener -import com.lambda.client.module.modules.combat.Surround.inHoleCheck import net.minecraft.network.play.client.CPacketPlayer import net.minecraftforge.fml.common.gameevent.InputEvent import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Velocity.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Velocity.kt index 2c77f4973..e68232838 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Velocity.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Velocity.kt @@ -1,12 +1,12 @@ package com.lambda.client.module.modules.movement import com.lambda.client.event.events.PacketEvent -import com.lambda.mixin.entity.MixinEntity -import com.lambda.mixin.world.MixinBlockLiquid import com.lambda.client.mixin.extension.* import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.threads.safeListener +import com.lambda.mixin.entity.MixinEntity +import com.lambda.mixin.world.MixinBlockLiquid import net.minecraft.client.entity.EntityPlayerSP import net.minecraft.entity.Entity import net.minecraft.network.play.server.SPacketEntityVelocity diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/AutoEat.kt b/src/main/kotlin/com/lambda/client/module/modules/player/AutoEat.kt index ce9914250..ca64550b6 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/AutoEat.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/AutoEat.kt @@ -1,17 +1,17 @@ package com.lambda.client.module.modules.player +import com.lambda.client.commons.extension.next import com.lambda.client.event.SafeClientEvent import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.process.PauseProcess.pauseBaritone import com.lambda.client.process.PauseProcess.unpauseBaritone +import com.lambda.client.util.TickTimer +import com.lambda.client.util.TimeUnit import com.lambda.client.util.combat.CombatUtils.scaledHealth import com.lambda.client.util.items.* import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener -import com.lambda.client.commons.extension.next -import com.lambda.client.util.TickTimer -import com.lambda.client.util.TimeUnit import com.lambda.mixin.player.MixinPlayerControllerMP import net.minecraft.init.Items import net.minecraft.init.MobEffects @@ -169,7 +169,7 @@ object AutoEat : Module( private fun SafeClientEvent.moveFoodToHotbar(preferredFood: PreferredFood): Boolean { val slotFrom = getFoodSlot(preferredFood, player.storageSlots) ?: return false - moveToHotbar(slotFrom) { + moveToHotbar(this@AutoEat, slotFrom) { val item = it.item item !is ItemTool && item !is ItemBlock } diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/ChestStealer.kt b/src/main/kotlin/com/lambda/client/module/modules/player/ChestStealer.kt index 392e28e49..f7834216e 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/ChestStealer.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/ChestStealer.kt @@ -4,6 +4,7 @@ import com.lambda.client.event.SafeClientEvent import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.TickTimer +import com.lambda.client.util.TimeUnit import com.lambda.client.util.items.* import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener @@ -13,6 +14,7 @@ import net.minecraft.client.gui.GuiMerchant import net.minecraft.client.gui.GuiRepair import net.minecraft.client.gui.inventory.* import net.minecraft.init.Items +import net.minecraft.inventory.ContainerShulkerBox import net.minecraft.item.ItemShulkerBox import net.minecraftforge.fml.common.gameevent.TickEvent @@ -24,7 +26,7 @@ object ChestStealer : Module( val mode by setting("Mode", Mode.TOGGLE) private val movingMode by setting("Moving Mode", MovingMode.QUICK_MOVE) private val ignoreEjectItem by setting("Ignores Eject Item", false, description = "Ignore AutoEject items in InventoryManager") - private val delay by setting("Delay", 250, 0..1000, 25, description = "Move stack delay in ms") + private val delay by setting("Delay", 5, 0..20, 1, description = "Move stack delay", unit = " ticks") private val onlyShulkers by setting("Only Shulkers", false, description = "Only move shulker boxes") enum class Mode { @@ -41,7 +43,7 @@ object ChestStealer : Module( var stealing = false var storing = false - val timer = TickTimer() + val timer = TickTimer(TimeUnit.TICKS) init { safeListener { @@ -126,11 +128,11 @@ object ChestStealer : Module( ?: return false val windowID = player.openContainer.windowId - if (timer.tick(delay.toLong())) { + if (timer.tick(delay) || (NoGhostItems.syncMode != NoGhostItems.SyncMode.PLAYER && NoGhostItems.isEnabled)) { when (movingMode) { - MovingMode.QUICK_MOVE -> quickMoveSlot(windowID, slot) - MovingMode.PICKUP -> moveToSlot(windowID, slot, slotTo.slotNumber) - MovingMode.THROW -> throwAllInSlot(windowID, slot) + MovingMode.QUICK_MOVE -> quickMoveSlot(this@ChestStealer, windowID, slot) + MovingMode.PICKUP -> moveToSlot(this@ChestStealer, windowID, slot, slotTo.slotNumber) + MovingMode.THROW -> throwAllInSlot(this@ChestStealer, windowID, slot) } } @@ -159,6 +161,7 @@ object ChestStealer : Module( for (slot in size until size + 36) { val item = container[slot].item if (item == Items.AIR) continue + if (player.openContainer is ContainerShulkerBox && item is ItemShulkerBox) continue if (!onlyShulkers || item is ItemShulkerBox) { return slot } diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Freecam.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Freecam.kt index 6a8fd7235..81145fc6e 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Freecam.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Freecam.kt @@ -164,7 +164,7 @@ object Freecam : Module( listener { if (leftClickCome && Mouse.getEventButton() == 0 && clickTimer.tick(1L)) { - val result : BlockPos = mc.objectMouseOver.blockPos ?: return@listener + val result: BlockPos = mc.objectMouseOver.blockPos ?: return@listener if (mc.objectMouseOver.typeOfHit == RayTraceResult.Type.BLOCK) { val pos = result.offset(mc.objectMouseOver.sideHit) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/InventoryManager.kt b/src/main/kotlin/com/lambda/client/module/modules/player/InventoryManager.kt index 78b2480b6..4d84f6168 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/InventoryManager.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/InventoryManager.kt @@ -42,7 +42,7 @@ object InventoryManager : Module( private val autoEject by setting("Auto Eject", false) private val fullOnly by setting("Only At Full", false, { autoEject }) private val pauseMovement by setting("Pause Movement", true) - private val delay by setting("Delay Ticks", 1, 0..20, 1) + private val delay by setting("Delay Ticks", 1, 0..20, 1, unit = " ticks") val ejectList = setting(CollectionSetting("Eject List", defaultEjectList)) enum class State { @@ -50,7 +50,7 @@ object InventoryManager : Module( } private var currentState = State.IDLE - private var paused = false + private var isBaritonePaused = false private val timer = TickTimer(TimeUnit.TICKS) override fun isActive(): Boolean { @@ -59,20 +59,20 @@ object InventoryManager : Module( init { onDisable { - paused = false + isBaritonePaused = false unpauseBaritone() } safeListener { - if (player.isSpectator || !pauseMovement || !paused) return@safeListener - player.setVelocity(0.0, mc.player.motionY, 0.0) + if (player.isSpectator || !pauseMovement || !isBaritonePaused) return@safeListener + player.setVelocity(0.0, player.motionY, 0.0) it.cancel() } safeListener { if (it.phase != TickEvent.Phase.START || player.isSpectator || mc.currentScreen is GuiContainer) return@safeListener - if (!timer.tick(delay.toLong())) return@safeListener + if (!timer.tick(delay) && !(NoGhostItems.syncMode != NoGhostItems.SyncMode.PLAYER && NoGhostItems.isEnabled)) return@safeListener setState() @@ -81,7 +81,7 @@ object InventoryManager : Module( State.REFILLING_BUILDING -> refillBuilding() State.REFILLING -> refill() State.EJECTING -> eject() - State.IDLE -> removeHoldingItem() + State.IDLE -> removeHoldingItem(this@InventoryManager) } playerController.syncCurrentPlayItem() @@ -97,7 +97,7 @@ object InventoryManager : Module( else -> State.IDLE } - paused = if (currentState != State.IDLE && pauseMovement) { + isBaritonePaused = if (currentState != State.IDLE && pauseMovement) { pauseBaritone() true } else { @@ -143,10 +143,10 @@ object InventoryManager : Module( when { autoRefill && undamagedItem != null -> { - moveToHotbar(undamagedItem.slotNumber, currentSlot) + moveToHotbar(this@InventoryManager, undamagedItem.slotNumber, currentSlot) } emptySlot != null -> { - moveToHotbar(emptySlot.slotNumber, currentSlot) + moveToHotbar(this@InventoryManager, emptySlot.slotNumber, currentSlot) } else -> { player.dropItem(false) @@ -156,7 +156,7 @@ object InventoryManager : Module( private fun SafeClientEvent.refillBuilding() { player.storageSlots.firstID(buildingBlockID)?.let { - quickMoveSlot(it) + quickMoveSlot(this@InventoryManager, it) } } @@ -164,12 +164,12 @@ object InventoryManager : Module( val slotTo = getRefillableSlot() ?: return val slotFrom = getCompatibleStack(slotTo.stack) ?: return - moveToSlot(slotFrom, slotTo) + moveToSlot(this@InventoryManager, slotFrom, slotTo) } private fun SafeClientEvent.eject() { getEjectSlot()?.let { - throwAllInSlot(it) + throwAllInSlot(this@InventoryManager, it) } } /* End of tasks */ diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/LagNotifier.kt b/src/main/kotlin/com/lambda/client/module/modules/player/LagNotifier.kt index 96d2cd3f4..a6cb6ee4f 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/LagNotifier.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/LagNotifier.kt @@ -1,8 +1,10 @@ package com.lambda.client.module.modules.player +import com.lambda.client.commons.utils.MathUtils import com.lambda.client.event.events.ConnectionEvent import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.events.RenderOverlayEvent +import com.lambda.client.event.listener.listener import com.lambda.client.manager.managers.NetworkManager import com.lambda.client.module.Category import com.lambda.client.module.Module @@ -14,8 +16,6 @@ import com.lambda.client.util.graphics.font.FontRenderAdapter import com.lambda.client.util.math.Vec2f import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.safeListener -import com.lambda.client.commons.utils.MathUtils -import com.lambda.client.event.listener.listener import net.minecraft.client.gui.ScaledResolution import net.minecraft.network.play.server.SPacketPlayerPosLook import net.minecraft.util.math.Vec3d @@ -41,11 +41,11 @@ object LagNotifier : Module( private val lastRubberBandTimer = TickTimer() private var text = "" - var paused = false; private set + var isBaritonePaused = false; private set init { onDisable { - unpause() + requestUnpause() } listener { @@ -62,7 +62,7 @@ object LagNotifier : Module( safeListener { if (mc.isIntegratedServerRunning) { - unpause() + requestUnpause() text = "" } else { val timeoutMillis = (timeout * 1000.0f).toLong() @@ -72,14 +72,14 @@ object LagNotifier : Module( else "Server Not Responding! " text += timeDifference(lastPacketTimer.time) - pause() + requestPause() } detectRubberBand && !lastRubberBandTimer.tick(timeoutMillis, false) -> { text = "RubberBand Detected! ${timeDifference(lastRubberBandTimer.time)}" - pause() + requestPause() } else -> { - unpause() + requestUnpause() } } } @@ -102,22 +102,22 @@ object LagNotifier : Module( } } - private fun pause() { - if (!paused && pauseBaritone && feedback) { + private fun requestPause() { + if (!isBaritonePaused && pauseBaritone && feedback) { MessageSendHelper.sendBaritoneMessage("Paused due to lag!") } pauseBaritone() - paused = true + isBaritonePaused = true } - private fun unpause() { - if (paused && pauseBaritone && feedback) { + private fun requestUnpause() { + if (isBaritonePaused && pauseBaritone && feedback) { MessageSendHelper.sendBaritoneMessage("Unpaused!") } unpauseBaritone() - paused = false + isBaritonePaused = false text = "" } diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/NoGlitchBlocks.kt b/src/main/kotlin/com/lambda/client/module/modules/player/NoGhostBlocks.kt similarity index 76% rename from src/main/kotlin/com/lambda/client/module/modules/player/NoGlitchBlocks.kt rename to src/main/kotlin/com/lambda/client/module/modules/player/NoGhostBlocks.kt index a597ddf2b..4688f85b6 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/NoGlitchBlocks.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/NoGhostBlocks.kt @@ -7,9 +7,9 @@ import com.lambda.mixin.world.MixinItemBlock /** * @see MixinItemBlock.ignoreSetBlockState */ -object NoGlitchBlocks : Module( - name = "NoGlitchBlocks", +object NoGhostBlocks : Module( + name = "NoGhostBlocks", + alias = arrayOf("NoGlitchBlocks"), description = "Syncs block interactions for strict environments", category = Category.PLAYER -) { -} \ No newline at end of file +) \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/NoGhostItems.kt b/src/main/kotlin/com/lambda/client/module/modules/player/NoGhostItems.kt index eb49bb57c..dbf3caf68 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/NoGhostItems.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/NoGhostItems.kt @@ -1,58 +1,44 @@ package com.lambda.client.module.modules.player -import com.lambda.client.event.events.PacketEvent -import com.lambda.client.event.listener.listener +import com.lambda.client.event.events.WindowClickEvent +import com.lambda.client.manager.managers.PlayerInventoryManager +import com.lambda.client.manager.managers.PlayerInventoryManager.addInventoryTask import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.client.util.threads.runSafe +import com.lambda.client.util.threads.safeListener import com.lambda.mixin.player.MixinPlayerControllerMP -import net.minecraft.entity.player.EntityPlayer -import net.minecraft.inventory.ClickType -import net.minecraft.item.ItemStack -import net.minecraft.network.play.client.CPacketClickWindow -import net.minecraft.network.play.server.SPacketConfirmTransaction /** * @see MixinPlayerControllerMP.onWindowClick + * @see PlayerInventoryManager */ object NoGhostItems : Module( name = "NoGhostItems", description = "Syncs inventory transactions for strict environments", category = Category.PLAYER ) { - private val timeout by setting("Timeout in ticks", 5, 1..50, 1) - - private var pendingTransaction: InventoryTransaction? = null - private var lastPending = System.currentTimeMillis() - - init { - listener { event -> - if (event.packet is SPacketConfirmTransaction) { - pendingTransaction?.let { - it.player.openContainer.slotClick(it.slotId, it.mouseButton, it.type, it.player) - pendingTransaction = null - } - } - } + val syncMode by setting("Scope", SyncMode.MODULES) + val baritoneSync by setting("Baritone pause", true, description = "Pauses Baritone until transaction is complete.") + val timeout by setting("Timeout in ms", 800, 1..2500, 25) + val maxRetries by setting("Max retries", 8, 0..20, 1) + val debugLog by setting("Debug log", false) + private val clearQueue = setting("Clear Transaction Queue", false) + + enum class SyncMode { + ALL, PLAYER, MODULES } - fun handleWindowClick(windowId: Int, slotId: Int, mouseButton: Int, type: ClickType, player: EntityPlayer) { - val transaction = InventoryTransaction(windowId, slotId, mouseButton, type, player) - - if (pendingTransaction == null || System.currentTimeMillis() - lastPending > timeout * 50L) { - val transactionID = transaction.player.openContainer.getNextTransactionID(transaction.player.inventory) - pendingTransaction = transaction - lastPending = System.currentTimeMillis() + init { + safeListener { + if (syncMode == SyncMode.MODULES) return@safeListener - runSafe { - connection.sendPacket(CPacketClickWindow(transaction.windowId, transaction.slotId, transaction.mouseButton, transaction.type, ItemStack.EMPTY, transactionID)) - } + addInventoryTask(PlayerInventoryManager.ClickInfo(it.windowId, it.slotId, it.mouseButton, it.type)) + it.cancel() } - } - data class InventoryTransaction(val windowId: Int, val slotId: Int, val mouseButton: Int, val type: ClickType, val player: EntityPlayer) { - override fun toString(): String { - return "windowId: $windowId slotId: $slotId mouseButton: $mouseButton type: ${type.name} player: ${player.name}" + clearQueue.consumers.add { _, it -> + if (it) PlayerInventoryManager.reset() + false } } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/PacketCancel.kt b/src/main/kotlin/com/lambda/client/module/modules/player/PacketCancel.kt index 7dcaa791d..5a5f93f7f 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/PacketCancel.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/PacketCancel.kt @@ -1,9 +1,9 @@ package com.lambda.client.module.modules.player import com.lambda.client.event.events.PacketEvent +import com.lambda.client.event.listener.listener import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.client.event.listener.listener import net.minecraft.network.login.client.CPacketEncryptionResponse import net.minecraft.network.login.client.CPacketLoginStart import net.minecraft.network.login.server.SPacketEnableCompression @@ -123,7 +123,7 @@ object PacketCancel : Module( private val SPacketExplosionSetting by setting("SPacketExplosion", false, { side == Side.SERVER && categorySetting == CategorySlider.WORLD }) private val SPacketEntityVelocitySetting by setting("SPacketEntityVelocity", false, { side == Side.SERVER && categorySetting == CategorySlider.ENTITY }) private val SPacketEntityTeleportSetting by setting("SPacketEntityTeleport", false, { side == Side.SERVER && categorySetting == CategorySlider.ENTITY }) - private val SPacketEntityStatusSetting by setting("SPacketEntityStatus", false, { side == Side.SERVER && categorySetting == CategorySlider.ENTITY}) + private val SPacketEntityStatusSetting by setting("SPacketEntityStatus", false, { side == Side.SERVER && categorySetting == CategorySlider.ENTITY }) private val SPacketEntityPropertiesSetting by setting("SPacketEntityProperties", false, { side == Side.SERVER && categorySetting == CategorySlider.ENTITY }) private val SPacketEntityMetadataSetting by setting("SPacketEntityMetadata", false, { side == Side.SERVER && categorySetting == CategorySlider.ENTITY }) private val SPacketEntityHeadLookSetting by setting("SPacketEntityHeadLook", false, { side == Side.SERVER && categorySetting == CategorySlider.ENTITY }) diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/PacketLogger.kt b/src/main/kotlin/com/lambda/client/module/modules/player/PacketLogger.kt index 7276ffb5d..66e255092 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/PacketLogger.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/PacketLogger.kt @@ -1,20 +1,20 @@ package com.lambda.client.module.modules.player import com.lambda.client.LambdaMod +import com.lambda.client.commons.interfaces.DisplayEnum import com.lambda.client.event.events.ConnectionEvent import com.lambda.client.event.events.PacketEvent +import com.lambda.client.event.listener.listener import com.lambda.client.mixin.extension.* import com.lambda.client.module.Category import com.lambda.client.module.Module +import com.lambda.client.util.FolderUtils import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit -import com.lambda.client.util.FolderUtils import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.defaultScope import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener -import com.lambda.client.commons.interfaces.DisplayEnum -import com.lambda.client.event.listener.listener import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import net.minecraft.network.Packet diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/PortalGodMode.kt b/src/main/kotlin/com/lambda/client/module/modules/player/PortalGodMode.kt index e0d51a11b..19438be3e 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/PortalGodMode.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/PortalGodMode.kt @@ -1,10 +1,10 @@ package com.lambda.client.module.modules.player import com.lambda.client.event.events.PacketEvent +import com.lambda.client.event.listener.listener import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.threads.runSafe -import com.lambda.client.event.listener.listener import net.minecraft.network.play.client.CPacketConfirmTeleport object PortalGodMode : Module( diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index bbb4852ed..f33e6d938 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -5,11 +5,11 @@ import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.OnUpdateWalkingPlayerEvent import com.lambda.client.event.events.PacketEvent import com.lambda.client.event.events.PlayerTravelEvent +import com.lambda.client.event.listener.listener import com.lambda.client.manager.managers.HotbarManager.resetHotbar import com.lambda.client.manager.managers.HotbarManager.serverSideItem import com.lambda.client.manager.managers.HotbarManager.spoofHotbar import com.lambda.client.manager.managers.PlayerPacketManager.sendPlayerPacket -import com.lambda.mixin.entity.MixinEntity import com.lambda.client.mixin.extension.syncCurrentPlayItem import com.lambda.client.module.Category import com.lambda.client.module.Module @@ -26,7 +26,7 @@ import com.lambda.client.util.threads.safeListener import com.lambda.client.util.world.PlaceInfo import com.lambda.client.util.world.getNeighbour import com.lambda.client.util.world.placeBlock -import com.lambda.client.event.listener.listener +import com.lambda.mixin.entity.MixinEntity import net.minecraft.item.ItemBlock import net.minecraft.network.play.client.CPacketEntityAction import net.minecraft.network.play.server.SPacketPlayerPosLook diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt index 2e75079c7..616c578bc 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt @@ -1,10 +1,10 @@ package com.lambda.client.module.modules.player +import com.lambda.client.event.listener.listener import com.lambda.client.manager.managers.TimerManager.modifyTimer import com.lambda.client.manager.managers.TimerManager.resetTimer import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.client.event.listener.listener import net.minecraftforge.fml.common.gameevent.TickEvent object Timer : Module( diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/XCarry.kt b/src/main/kotlin/com/lambda/client/module/modules/player/XCarry.kt index b2061eefc..f069ff017 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/XCarry.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/XCarry.kt @@ -1,10 +1,10 @@ package com.lambda.client.module.modules.player import com.lambda.client.event.events.PacketEvent +import com.lambda.client.event.listener.listener import com.lambda.client.mixin.extension.windowID import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.client.event.listener.listener import net.minecraft.network.play.client.CPacketCloseWindow object XCarry : Module( diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/BossStack.kt b/src/main/kotlin/com/lambda/client/module/modules/render/BossStack.kt index 634e89206..24b2b2961 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/BossStack.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/BossStack.kt @@ -1,12 +1,12 @@ package com.lambda.client.module.modules.render +import com.lambda.client.event.listener.listener import com.lambda.client.mixin.extension.mapBossInfos import com.lambda.client.mixin.extension.render import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.TickTimer import com.lambda.client.util.graphics.GlStateUtils -import com.lambda.client.event.listener.listener import net.minecraft.client.gui.BossInfoClient import net.minecraft.client.gui.ScaledResolution import net.minecraft.client.renderer.GlStateManager diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/Breadcrumbs.kt b/src/main/kotlin/com/lambda/client/module/modules/render/Breadcrumbs.kt index 3d4f2ff50..98b34df1c 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/Breadcrumbs.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/Breadcrumbs.kt @@ -3,6 +3,7 @@ package com.lambda.client.module.modules.render import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.ConnectionEvent import com.lambda.client.event.events.RenderWorldEvent +import com.lambda.client.event.listener.listener import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.EntityUtils.getInterpolatedPos @@ -11,7 +12,6 @@ import com.lambda.client.util.graphics.LambdaTessellator import com.lambda.client.util.math.VectorUtils.distanceTo import com.lambda.client.util.text.MessageSendHelper.sendChatMessage import com.lambda.client.util.threads.safeListener -import com.lambda.client.event.listener.listener import net.minecraft.client.renderer.GlStateManager import net.minecraft.util.math.Vec3d import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/BreakingESP.kt b/src/main/kotlin/com/lambda/client/module/modules/render/BreakingESP.kt index 55e8ed609..7cfb2de6b 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/BreakingESP.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/BreakingESP.kt @@ -3,6 +3,7 @@ package com.lambda.client.module.modules.render import com.lambda.client.event.events.BlockBreakEvent import com.lambda.client.event.events.RenderOverlayEvent import com.lambda.client.event.events.RenderWorldEvent +import com.lambda.client.event.listener.listener import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.color.ColorHolder @@ -11,7 +12,6 @@ import com.lambda.client.util.graphics.font.FontRenderAdapter import com.lambda.client.util.math.VectorUtils.distanceTo import com.lambda.client.util.text.MessageSendHelper.sendChatMessage import com.lambda.client.util.threads.safeListener -import com.lambda.client.event.listener.listener import net.minecraft.client.audio.PositionedSoundRecord import net.minecraft.client.gui.ScaledResolution import net.minecraft.init.Blocks diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/EyeFinder.kt b/src/main/kotlin/com/lambda/client/module/modules/render/EyeFinder.kt index c33cc259a..08ac70c8c 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/EyeFinder.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/EyeFinder.kt @@ -1,6 +1,7 @@ package com.lambda.client.module.modules.render import com.lambda.client.event.events.RenderWorldEvent +import com.lambda.client.event.listener.listener import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.EntityUtils.getInterpolatedAmount @@ -9,7 +10,6 @@ import com.lambda.client.util.color.ColorHolder import com.lambda.client.util.graphics.ESPRenderer import com.lambda.client.util.graphics.LambdaTessellator import com.lambda.client.util.threads.safeListener -import com.lambda.client.event.listener.listener import net.minecraft.client.Minecraft import net.minecraft.client.renderer.GlStateManager import net.minecraft.entity.Entity diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/MobOwner.kt b/src/main/kotlin/com/lambda/client/module/modules/render/MobOwner.kt index bd3d508f5..65020b141 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/MobOwner.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/MobOwner.kt @@ -1,11 +1,11 @@ package com.lambda.client.module.modules.render +import com.lambda.client.commons.utils.MathUtils.round import com.lambda.client.manager.managers.UUIDManager import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener -import com.lambda.client.commons.utils.MathUtils.round import net.minecraft.entity.passive.AbstractHorse import net.minecraft.entity.passive.EntityTameable import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/Nametags.kt b/src/main/kotlin/com/lambda/client/module/modules/render/Nametags.kt index b88f4e673..7ae701a7f 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/Nametags.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/Nametags.kt @@ -1,13 +1,17 @@ package com.lambda.client.module.modules.render -import com.lambda.client.LambdaMod +import com.lambda.client.commons.extension.ceilToInt +import com.lambda.client.commons.extension.floorToInt +import com.lambda.client.commons.utils.MathUtils import com.lambda.client.event.events.RenderOverlayEvent +import com.lambda.client.event.listener.listener import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.module.modules.client.ClickGUI import com.lambda.client.module.modules.client.CustomFont import com.lambda.client.module.modules.client.GuiColors import com.lambda.client.module.modules.client.Hud +import com.lambda.client.module.modules.misc.LogoutLogger import com.lambda.client.util.EnchantmentUtils import com.lambda.client.util.EntityUtils import com.lambda.client.util.color.ColorGradient @@ -17,11 +21,6 @@ import com.lambda.client.util.graphics.font.* import com.lambda.client.util.items.originalName import com.lambda.client.util.math.Vec2d import com.lambda.client.util.threads.safeListener -import com.lambda.client.commons.extension.ceilToInt -import com.lambda.client.commons.extension.floorToInt -import com.lambda.client.commons.utils.MathUtils -import com.lambda.client.event.listener.listener -import com.lambda.client.module.modules.misc.LogoutLogger import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.client.renderer.RenderHelper import net.minecraft.entity.Entity diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt index 9abdf207a..ea00883b3 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt @@ -17,9 +17,9 @@ import com.lambda.client.util.graphics.GlStateUtils import com.lambda.client.util.graphics.LambdaTessellator import com.lambda.client.util.graphics.RenderUtils2D import com.lambda.client.util.math.Vec2d +import com.lambda.client.util.math.VectorUtils.distanceTo import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.safeListener -import com.lambda.client.util.math.VectorUtils.distanceTo import net.minecraft.client.Minecraft import net.minecraft.client.renderer.vertex.DefaultVertexFormats import net.minecraft.network.play.server.SPacketChunkData @@ -29,15 +29,11 @@ import net.minecraftforge.fml.common.gameevent.TickEvent import org.apache.commons.lang3.SystemUtils import org.lwjgl.opengl.GL11.GL_LINE_LOOP import org.lwjgl.opengl.GL11.glLineWidth -import java.io.BufferedWriter -import java.io.FileWriter -import java.io.IOException -import java.io.PrintWriter +import java.io.* import java.nio.file.Files -import java.io.File import java.nio.file.Path import java.text.SimpleDateFormat -import java.util.Date +import java.util.* import java.util.concurrent.ConcurrentHashMap object NewChunks : Module( diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/StorageESP.kt b/src/main/kotlin/com/lambda/client/module/modules/render/StorageESP.kt index 64aa28bb0..6ad5f206d 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/StorageESP.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/StorageESP.kt @@ -2,6 +2,7 @@ package com.lambda.client.module.modules.render import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.RenderWorldEvent +import com.lambda.client.event.listener.listener import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.color.ColorHolder @@ -10,7 +11,6 @@ import com.lambda.client.util.color.HueCycler import com.lambda.client.util.graphics.ESPRenderer import com.lambda.client.util.graphics.GeometryMasks import com.lambda.client.util.threads.safeAsyncListener -import com.lambda.client.event.listener.listener import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.launch diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/Tracers.kt b/src/main/kotlin/com/lambda/client/module/modules/render/Tracers.kt index 8b637575c..9f17dd06e 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/Tracers.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/Tracers.kt @@ -1,6 +1,8 @@ package com.lambda.client.module.modules.render +import com.lambda.client.commons.utils.MathUtils.convertRange import com.lambda.client.event.events.RenderWorldEvent +import com.lambda.client.event.listener.listener import com.lambda.client.manager.managers.FriendManager import com.lambda.client.module.Category import com.lambda.client.module.Module @@ -11,8 +13,6 @@ import com.lambda.client.util.color.ColorHolder import com.lambda.client.util.color.HueCycler import com.lambda.client.util.graphics.ESPRenderer import com.lambda.client.util.threads.safeListener -import com.lambda.client.commons.utils.MathUtils.convertRange -import com.lambda.client.event.listener.listener import net.minecraft.entity.Entity import net.minecraft.entity.player.EntityPlayer import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/WaypointRender.kt b/src/main/kotlin/com/lambda/client/module/modules/render/WaypointRender.kt index d8d330042..2a26528a7 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/WaypointRender.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/WaypointRender.kt @@ -1,6 +1,7 @@ package com.lambda.client.module.modules.render import com.lambda.client.event.events.* +import com.lambda.client.event.listener.listener import com.lambda.client.manager.managers.WaypointManager import com.lambda.client.manager.managers.WaypointManager.Waypoint import com.lambda.client.module.Category @@ -16,7 +17,6 @@ import com.lambda.client.util.math.Vec2d import com.lambda.client.util.math.VectorUtils.distanceTo import com.lambda.client.util.math.VectorUtils.toVec3dCenter import com.lambda.client.util.threads.safeListener -import com.lambda.client.event.listener.listener import net.minecraft.util.math.AxisAlignedBB import net.minecraft.util.math.BlockPos import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/src/main/kotlin/com/lambda/client/plugin/PluginClassLoader.kt b/src/main/kotlin/com/lambda/client/plugin/PluginClassLoader.kt index 25f2924df..35bf375d5 100644 --- a/src/main/kotlin/com/lambda/client/plugin/PluginClassLoader.kt +++ b/src/main/kotlin/com/lambda/client/plugin/PluginClassLoader.kt @@ -1,10 +1,10 @@ package com.lambda.client.plugin -import java.util.jar.JarFile -import java.lang.ClassNotFoundException -import java.io.IOException + import java.io.ByteArrayOutputStream +import java.io.IOException import java.io.InputStream import java.util.jar.JarEntry +import java.util.jar.JarFile // A custom class loader that only opens the file while it is actually reading from it then closes the file so that it can be deleted / changed. class PluginClassLoader(jar: JarFile, parent: ClassLoader) : ClassLoader(parent) { diff --git a/src/main/kotlin/com/lambda/client/plugin/PluginInfo.kt b/src/main/kotlin/com/lambda/client/plugin/PluginInfo.kt index 5e3ddae1b..f2f9945b6 100644 --- a/src/main/kotlin/com/lambda/client/plugin/PluginInfo.kt +++ b/src/main/kotlin/com/lambda/client/plugin/PluginInfo.kt @@ -2,8 +2,8 @@ package com.lambda.client.plugin import com.google.gson.Gson import com.google.gson.annotations.SerializedName -import com.lambda.client.plugin.api.Plugin import com.lambda.client.commons.interfaces.Nameable +import com.lambda.client.plugin.api.Plugin import java.io.InputStream class PluginInfo private constructor( diff --git a/src/main/kotlin/com/lambda/client/plugin/PluginLoader.kt b/src/main/kotlin/com/lambda/client/plugin/PluginLoader.kt index 6381f2b80..ac2f805da 100644 --- a/src/main/kotlin/com/lambda/client/plugin/PluginLoader.kt +++ b/src/main/kotlin/com/lambda/client/plugin/PluginLoader.kt @@ -3,9 +3,9 @@ package com.lambda.client.plugin import com.google.gson.Gson import com.google.gson.reflect.TypeToken import com.lambda.client.LambdaMod -import com.lambda.client.plugin.api.Plugin import com.lambda.client.commons.interfaces.Nameable import com.lambda.client.commons.utils.ClassUtils.instance +import com.lambda.client.plugin.api.Plugin import net.minecraft.launchwrapper.Launch import java.io.File import java.io.FileNotFoundException diff --git a/src/main/kotlin/com/lambda/client/plugin/PluginManager.kt b/src/main/kotlin/com/lambda/client/plugin/PluginManager.kt index 547d08639..19c65c3d1 100644 --- a/src/main/kotlin/com/lambda/client/plugin/PluginManager.kt +++ b/src/main/kotlin/com/lambda/client/plugin/PluginManager.kt @@ -2,12 +2,12 @@ package com.lambda.client.plugin import com.lambda.client.AsyncLoader import com.lambda.client.LambdaMod +import com.lambda.client.commons.collections.NameableSet import com.lambda.client.gui.clickgui.LambdaClickGui import com.lambda.client.gui.clickgui.component.PluginButton import com.lambda.client.plugin.api.Plugin import com.lambda.client.util.FolderUtils import com.lambda.client.util.text.MessageSendHelper -import com.lambda.client.commons.collections.NameableSet import kotlinx.coroutines.Deferred import net.minecraft.util.text.TextFormatting import org.apache.maven.artifact.versioning.DefaultArtifactVersion diff --git a/src/main/kotlin/com/lambda/client/plugin/api/Plugin.kt b/src/main/kotlin/com/lambda/client/plugin/api/Plugin.kt index b5fdf9244..019a685d2 100644 --- a/src/main/kotlin/com/lambda/client/plugin/api/Plugin.kt +++ b/src/main/kotlin/com/lambda/client/plugin/api/Plugin.kt @@ -2,7 +2,10 @@ package com.lambda.client.plugin.api import com.lambda.client.command.ClientCommand import com.lambda.client.command.CommandManager +import com.lambda.client.commons.collections.CloseableList +import com.lambda.client.commons.interfaces.Nameable import com.lambda.client.event.LambdaEventBus +import com.lambda.client.event.ListenerManager import com.lambda.client.gui.GuiManager import com.lambda.client.manager.Manager import com.lambda.client.module.ModuleManager @@ -11,9 +14,6 @@ import com.lambda.client.setting.ConfigManager import com.lambda.client.setting.configs.PluginConfig import com.lambda.client.util.threads.BackgroundJob import com.lambda.client.util.threads.BackgroundScope -import com.lambda.client.commons.collections.CloseableList -import com.lambda.client.commons.interfaces.Nameable -import com.lambda.client.event.ListenerManager /** * A plugin. All plugin main classes must extend this class. diff --git a/src/main/kotlin/com/lambda/client/setting/ConfigManager.kt b/src/main/kotlin/com/lambda/client/setting/ConfigManager.kt index a9d448315..afce1604e 100644 --- a/src/main/kotlin/com/lambda/client/setting/ConfigManager.kt +++ b/src/main/kotlin/com/lambda/client/setting/ConfigManager.kt @@ -1,8 +1,8 @@ package com.lambda.client.setting import com.lambda.client.LambdaMod -import com.lambda.client.setting.configs.IConfig import com.lambda.client.commons.collections.NameableSet +import com.lambda.client.setting.configs.IConfig internal object ConfigManager { private val configSet = NameableSet() diff --git a/src/main/kotlin/com/lambda/client/setting/configs/NameableConfig.kt b/src/main/kotlin/com/lambda/client/setting/configs/NameableConfig.kt index 952653e29..cc9a5cdab 100644 --- a/src/main/kotlin/com/lambda/client/setting/configs/NameableConfig.kt +++ b/src/main/kotlin/com/lambda/client/setting/configs/NameableConfig.kt @@ -1,7 +1,7 @@ package com.lambda.client.setting.configs -import com.lambda.client.setting.settings.AbstractSetting import com.lambda.client.commons.interfaces.Nameable +import com.lambda.client.setting.settings.AbstractSetting open class NameableConfig( name: String, diff --git a/src/main/kotlin/com/lambda/client/setting/groups/SettingGroup.kt b/src/main/kotlin/com/lambda/client/setting/groups/SettingGroup.kt index 8fe54a84a..6f0d92227 100644 --- a/src/main/kotlin/com/lambda/client/setting/groups/SettingGroup.kt +++ b/src/main/kotlin/com/lambda/client/setting/groups/SettingGroup.kt @@ -3,8 +3,8 @@ package com.lambda.client.setting.groups import com.google.gson.JsonObject import com.google.gson.JsonPrimitive import com.lambda.client.LambdaMod -import com.lambda.client.setting.settings.AbstractSetting import com.lambda.client.commons.interfaces.Nameable +import com.lambda.client.setting.settings.AbstractSetting open class SettingGroup( override val name: String diff --git a/src/main/kotlin/com/lambda/client/setting/settings/impl/primitive/EnumSetting.kt b/src/main/kotlin/com/lambda/client/setting/settings/impl/primitive/EnumSetting.kt index f3dfc2f9a..b3a4127ad 100644 --- a/src/main/kotlin/com/lambda/client/setting/settings/impl/primitive/EnumSetting.kt +++ b/src/main/kotlin/com/lambda/client/setting/settings/impl/primitive/EnumSetting.kt @@ -2,8 +2,8 @@ package com.lambda.client.setting.settings.impl.primitive import com.google.gson.JsonElement import com.google.gson.JsonPrimitive -import com.lambda.client.setting.settings.MutableSetting import com.lambda.client.commons.extension.next +import com.lambda.client.setting.settings.MutableSetting class EnumSetting>( name: String, diff --git a/src/main/kotlin/com/lambda/client/util/EntityUtils.kt b/src/main/kotlin/com/lambda/client/util/EntityUtils.kt index e935e7415..3dc38e6b8 100644 --- a/src/main/kotlin/com/lambda/client/util/EntityUtils.kt +++ b/src/main/kotlin/com/lambda/client/util/EntityUtils.kt @@ -1,12 +1,12 @@ package com.lambda.client.util +import com.lambda.client.commons.extension.ceilToInt +import com.lambda.client.commons.extension.floorToInt import com.lambda.client.event.SafeClientEvent import com.lambda.client.manager.managers.FriendManager import com.lambda.client.util.MovementUtils.calcMoveYaw import com.lambda.client.util.items.id import com.lambda.client.util.math.VectorUtils.toBlockPos -import com.lambda.client.commons.extension.ceilToInt -import com.lambda.client.commons.extension.floorToInt import net.minecraft.block.BlockLiquid import net.minecraft.client.Minecraft import net.minecraft.entity.Entity diff --git a/src/main/kotlin/com/lambda/client/util/TimerUtils.kt b/src/main/kotlin/com/lambda/client/util/TimerUtils.kt index e58e8acf6..387217f71 100644 --- a/src/main/kotlin/com/lambda/client/util/TimerUtils.kt +++ b/src/main/kotlin/com/lambda/client/util/TimerUtils.kt @@ -5,10 +5,21 @@ open class Timer { protected val currentTime get() = System.currentTimeMillis() + fun reset(offset: Int) { + reset(offset.toLong()) + } + fun reset(offset: Long = 0L) { time = currentTime + offset } + fun skipTime(delay: Int) { + skipTime(delay.toLong()) + } + + fun skipTime(delay: Long) { + time = currentTime - delay + } } class TickTimer(val timeUnit: TimeUnit = TimeUnit.MILLISECONDS) : Timer() { diff --git a/src/main/kotlin/com/lambda/client/util/TpsCalculator.kt b/src/main/kotlin/com/lambda/client/util/TpsCalculator.kt index 2adee8e07..70909d12b 100644 --- a/src/main/kotlin/com/lambda/client/util/TpsCalculator.kt +++ b/src/main/kotlin/com/lambda/client/util/TpsCalculator.kt @@ -3,8 +3,8 @@ package com.lambda.client.util import com.lambda.client.event.LambdaEventBus import com.lambda.client.event.events.ConnectionEvent import com.lambda.client.event.events.PacketEvent -import com.lambda.client.util.CircularArray.Companion.average import com.lambda.client.event.listener.listener +import com.lambda.client.util.CircularArray.Companion.average import net.minecraft.network.play.server.SPacketTimeUpdate object TpsCalculator { diff --git a/src/main/kotlin/com/lambda/client/util/WebUtils.kt b/src/main/kotlin/com/lambda/client/util/WebUtils.kt index 4d7ac6cde..7f8c7e5fd 100644 --- a/src/main/kotlin/com/lambda/client/util/WebUtils.kt +++ b/src/main/kotlin/com/lambda/client/util/WebUtils.kt @@ -2,8 +2,8 @@ package com.lambda.client.util import com.google.gson.JsonParser import com.lambda.client.LambdaMod -import com.lambda.client.util.threads.mainScope import com.lambda.client.commons.utils.ConnectionUtils +import com.lambda.client.util.threads.mainScope import kotlinx.coroutines.launch import org.apache.maven.artifact.versioning.DefaultArtifactVersion import java.awt.Desktop diff --git a/src/main/kotlin/com/lambda/client/util/combat/CombatUtils.kt b/src/main/kotlin/com/lambda/client/util/combat/CombatUtils.kt index 37b822f8b..465d06aa7 100644 --- a/src/main/kotlin/com/lambda/client/util/combat/CombatUtils.kt +++ b/src/main/kotlin/com/lambda/client/util/combat/CombatUtils.kt @@ -3,12 +3,12 @@ package com.lambda.client.util.combat import com.lambda.client.event.LambdaEventBus import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.events.ConnectionEvent +import com.lambda.client.event.listener.listener import com.lambda.client.util.items.attackDamage import com.lambda.client.util.items.filterByStack import com.lambda.client.util.items.hotbarSlots import com.lambda.client.util.items.swapToSlot import com.lambda.client.util.threads.safeListener -import com.lambda.client.event.listener.listener import net.minecraft.enchantment.Enchantment import net.minecraft.enchantment.EnchantmentHelper import net.minecraft.entity.EntityLivingBase diff --git a/src/main/kotlin/com/lambda/client/util/combat/SurroundUtils.kt b/src/main/kotlin/com/lambda/client/util/combat/SurroundUtils.kt index 91231e578..eb8cc2822 100644 --- a/src/main/kotlin/com/lambda/client/util/combat/SurroundUtils.kt +++ b/src/main/kotlin/com/lambda/client/util/combat/SurroundUtils.kt @@ -2,7 +2,6 @@ package com.lambda.client.util.combat import com.lambda.client.event.SafeClientEvent import com.lambda.client.util.EntityUtils.flooredPosition -import com.lambda.client.util.Wrapper import net.minecraft.block.Block import net.minecraft.entity.Entity import net.minecraft.init.Blocks diff --git a/src/main/kotlin/com/lambda/client/util/graphics/RenderUtils2D.kt b/src/main/kotlin/com/lambda/client/util/graphics/RenderUtils2D.kt index 721043d26..b3b32634f 100644 --- a/src/main/kotlin/com/lambda/client/util/graphics/RenderUtils2D.kt +++ b/src/main/kotlin/com/lambda/client/util/graphics/RenderUtils2D.kt @@ -1,9 +1,9 @@ package com.lambda.client.util.graphics +import com.lambda.client.commons.utils.MathUtils import com.lambda.client.util.Wrapper import com.lambda.client.util.color.ColorHolder import com.lambda.client.util.math.Vec2d -import com.lambda.client.commons.utils.MathUtils import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.RenderHelper import net.minecraft.item.ItemStack diff --git a/src/main/kotlin/com/lambda/client/util/graphics/ShaderHelper.kt b/src/main/kotlin/com/lambda/client/util/graphics/ShaderHelper.kt index 35b87df64..525eb5429 100644 --- a/src/main/kotlin/com/lambda/client/util/graphics/ShaderHelper.kt +++ b/src/main/kotlin/com/lambda/client/util/graphics/ShaderHelper.kt @@ -3,8 +3,8 @@ package com.lambda.client.util.graphics import com.lambda.client.LambdaMod import com.lambda.client.event.LambdaEventBus import com.lambda.client.event.events.ResolutionUpdateEvent -import com.lambda.client.util.Wrapper import com.lambda.client.event.listener.listener +import com.lambda.client.util.Wrapper import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.OpenGlHelper import net.minecraft.client.shader.Framebuffer diff --git a/src/main/kotlin/com/lambda/client/util/graphics/font/FontGlyphs.kt b/src/main/kotlin/com/lambda/client/util/graphics/font/FontGlyphs.kt index 345fc6934..b39ad5d3d 100644 --- a/src/main/kotlin/com/lambda/client/util/graphics/font/FontGlyphs.kt +++ b/src/main/kotlin/com/lambda/client/util/graphics/font/FontGlyphs.kt @@ -1,8 +1,8 @@ package com.lambda.client.util.graphics.font import com.lambda.client.LambdaMod -import com.lambda.client.util.graphics.texture.MipmapTexture import com.lambda.client.commons.utils.MathUtils +import com.lambda.client.util.graphics.texture.MipmapTexture import org.lwjgl.opengl.GL11.* import org.lwjgl.opengl.GL12.GL_CLAMP_TO_EDGE import org.lwjgl.opengl.GL14.GL_TEXTURE_LOD_BIAS diff --git a/src/main/kotlin/com/lambda/client/util/items/Operation.kt b/src/main/kotlin/com/lambda/client/util/items/Operation.kt index b82eba128..7f4e8379e 100644 --- a/src/main/kotlin/com/lambda/client/util/items/Operation.kt +++ b/src/main/kotlin/com/lambda/client/util/items/Operation.kt @@ -1,6 +1,10 @@ package com.lambda.client.util.items import com.lambda.client.event.SafeClientEvent +import com.lambda.client.manager.managers.PlayerInventoryManager +import com.lambda.client.manager.managers.PlayerInventoryManager.addInventoryTask +import com.lambda.client.module.AbstractModule +import com.lambda.client.module.modules.player.NoGhostItems import com.lambda.client.util.threads.onMainThreadSafe import kotlinx.coroutines.runBlocking import net.minecraft.block.Block @@ -18,6 +22,7 @@ import net.minecraft.network.play.client.CPacketClickWindow * or slot 0 if none */ inline fun SafeClientEvent.swapToBlockOrMove( + owner: AbstractModule, predicateItem: (ItemStack) -> Boolean = { true }, predicateSlot: (ItemStack) -> Boolean = { true } ): Boolean { @@ -25,7 +30,7 @@ inline fun SafeClientEvent.swapToBlockOrMove( true } else { player.storageSlots.firstBlock(predicateItem)?.let { - moveToHotbar(it, predicateSlot) + moveToHotbar(owner, it, predicateSlot) true } ?: false } @@ -38,6 +43,7 @@ inline fun SafeClientEvent.swapToBlockOrMove( * or slot 0 if none */ fun SafeClientEvent.swapToBlockOrMove( + owner: AbstractModule, block: Block, predicateItem: (ItemStack) -> Boolean = { true }, predicateSlot: (ItemStack) -> Boolean = { true } @@ -46,7 +52,7 @@ fun SafeClientEvent.swapToBlockOrMove( true } else { player.storageSlots.firstBlock(block, predicateItem)?.let { - moveToHotbar(it, predicateSlot) + moveToHotbar(owner, it, predicateSlot) true } ?: false } @@ -59,6 +65,7 @@ fun SafeClientEvent.swapToBlockOrMove( * or slot 0 if none */ inline fun SafeClientEvent.swapToItemOrMove( + owner: AbstractModule, predicateItem: (ItemStack) -> Boolean = { true }, predicateSlot: (ItemStack) -> Boolean = { true } ): Boolean { @@ -66,7 +73,7 @@ inline fun SafeClientEvent.swapToItemOrMove( true } else { player.storageSlots.firstItem(predicateItem)?.let { - moveToHotbar(it, predicateSlot) + moveToHotbar(owner, it, predicateSlot) true } ?: false } @@ -79,6 +86,7 @@ inline fun SafeClientEvent.swapToItemOrMove( * or slot 0 if none */ fun SafeClientEvent.swapToItemOrMove( + owner: AbstractModule, item: Item, predicateItem: (ItemStack) -> Boolean = { true }, predicateSlot: (ItemStack) -> Boolean = { true } @@ -87,7 +95,7 @@ fun SafeClientEvent.swapToItemOrMove( true } else { player.storageSlots.firstItem(item, predicateItem)?.let { - moveToHotbar(it, predicateSlot) + moveToHotbar(owner, it, predicateSlot) true } ?: false } @@ -100,6 +108,7 @@ fun SafeClientEvent.swapToItemOrMove( * or slot 0 if none */ fun SafeClientEvent.swapToItemOrMove( + owner: AbstractModule, itemID: Int, predicateItem: (ItemStack) -> Boolean = { true }, predicateSlot: (ItemStack) -> Boolean = { true } @@ -108,7 +117,7 @@ fun SafeClientEvent.swapToItemOrMove( true } else { player.storageSlots.firstID(itemID, predicateItem)?.let { - moveToHotbar(it, predicateSlot) + moveToHotbar(owner, it, predicateSlot) true } ?: false } @@ -184,181 +193,181 @@ fun SafeClientEvent.swapToSlot(slot: Int) { * Swaps the item in [slotFrom] with the first empty hotbar slot * or matches with [predicate] or slot 0 if none of those found */ -inline fun SafeClientEvent.moveToHotbar(slotFrom: Slot, predicate: (ItemStack) -> Boolean): Short { - return moveToHotbar(slotFrom.slotNumber, predicate) +inline fun SafeClientEvent.moveToHotbar(owner: AbstractModule, slotFrom: Slot, predicate: (ItemStack) -> Boolean) { + moveToHotbar(owner, slotFrom.slotNumber, predicate) } /** * Swaps the item in [slotFrom] with the first empty hotbar slot * or matches with [predicate] or slot 0 if none of those found */ -inline fun SafeClientEvent.moveToHotbar(slotFrom: Int, predicate: (ItemStack) -> Boolean): Short { +inline fun SafeClientEvent.moveToHotbar(owner: AbstractModule, slotFrom: Int, predicate: (ItemStack) -> Boolean) { val hotbarSlots = player.hotbarSlots val slotTo = hotbarSlots.firstItem(Items.AIR)?.hotbarSlot ?: hotbarSlots.firstByStack(predicate)?.hotbarSlot ?: 0 - return moveToHotbar(slotFrom, slotTo) + moveToHotbar(owner, slotFrom, slotTo) } /** * Swaps the item in [slotFrom] with the hotbar slot [slotTo]. */ -fun SafeClientEvent.moveToHotbar(slotFrom: Slot, slotTo: HotbarSlot): Short { - return moveToHotbar(0, slotFrom, slotTo) +fun SafeClientEvent.moveToHotbar(owner: AbstractModule, slotFrom: Slot, slotTo: HotbarSlot) { + moveToHotbar(owner, 0, slotFrom, slotTo) } /** * Swaps the item in [slotFrom] with the hotbar slot [hotbarSlotTo]. */ -fun SafeClientEvent.moveToHotbar(windowId: Int, slotFrom: Slot, hotbarSlotTo: HotbarSlot): Short { - return moveToHotbar(windowId, slotFrom.slotNumber, hotbarSlotTo.hotbarSlot) +fun SafeClientEvent.moveToHotbar(owner: AbstractModule, windowId: Int, slotFrom: Slot, hotbarSlotTo: HotbarSlot) { + moveToHotbar(owner, windowId, slotFrom.slotNumber, hotbarSlotTo.hotbarSlot) } /** * Swaps the item in [slotFrom] with the hotbar slot [hotbarSlotTo]. */ -fun SafeClientEvent.moveToHotbar(slotFrom: Int, hotbarSlotTo: Int): Short { - return moveToHotbar(0, slotFrom, hotbarSlotTo) +fun SafeClientEvent.moveToHotbar(owner: AbstractModule, slotFrom: Int, hotbarSlotTo: Int) { + moveToHotbar(owner, 0, slotFrom, hotbarSlotTo) } /** * Swaps the item in [slotFrom] with the hotbar slot [hotbarSlotTo]. */ -fun SafeClientEvent.moveToHotbar(windowId: Int, slotFrom: Int, hotbarSlotTo: Int): Short { +fun SafeClientEvent.moveToHotbar(owner: AbstractModule, windowId: Int, slotFrom: Int, hotbarSlotTo: Int) { // mouseButton is actually the hotbar swapToSlot(hotbarSlotTo) - return clickSlot(windowId, slotFrom, hotbarSlotTo, type = ClickType.SWAP) + clickSlot(owner, windowId, slotFrom, hotbarSlotTo, type = ClickType.SWAP) } /** * Move the item in [slotFrom] to [slotTo] in player inventory, * if [slotTo] contains an item, then move it to [slotFrom] */ -fun SafeClientEvent.moveToSlot(slotFrom: Slot, slotTo: Slot): ShortArray { - return moveToSlot(0, slotFrom.slotNumber, slotTo.slotNumber) +fun SafeClientEvent.moveToSlot(owner: AbstractModule, slotFrom: Slot, slotTo: Slot) { + moveToSlot(owner, 0, slotFrom.slotNumber, slotTo.slotNumber) } /** * Move the item in [slotFrom] to [slotTo] in player inventory, * if [slotTo] contains an item, then move it to [slotFrom] */ -fun SafeClientEvent.moveToSlot(slotFrom: Int, slotTo: Int): ShortArray { - return moveToSlot(0, slotFrom, slotTo) +fun SafeClientEvent.moveToSlot(owner: AbstractModule, slotFrom: Int, slotTo: Int) { + moveToSlot(owner, 0, slotFrom, slotTo) } /** * Move the item in [slotFrom] to [slotTo] in [windowId], * if [slotTo] contains an item, then move it to [slotFrom] */ -fun SafeClientEvent.moveToSlot(windowId: Int, slotFrom: Int, slotTo: Int): ShortArray { - return shortArrayOf( - clickSlot(windowId, slotFrom, type = ClickType.PICKUP), - clickSlot(windowId, slotTo, type = ClickType.PICKUP), - clickSlot(windowId, slotFrom, type = ClickType.PICKUP) - ) +fun SafeClientEvent.moveToSlot(owner: AbstractModule, windowId: Int, slotFrom: Int, slotTo: Int) { + clickSlot(owner, windowId, slotFrom, type = ClickType.PICKUP) + clickSlot(owner, windowId, slotTo, type = ClickType.PICKUP) + clickSlot(owner, windowId, slotFrom, type = ClickType.PICKUP) } /** * Move all the item that equals to the item in [slotTo] to [slotTo] in player inventory * Note: Not working */ -fun SafeClientEvent.moveAllToSlot(slotTo: Int): ShortArray { - return shortArrayOf( - clickSlot(slot = slotTo, type = ClickType.PICKUP_ALL), - clickSlot(slot = slotTo, type = ClickType.PICKUP) - ) +fun SafeClientEvent.moveAllToSlot(owner: AbstractModule, slotTo: Int) { + clickSlot(owner, slot = slotTo, type = ClickType.PICKUP_ALL) + clickSlot(owner, slot = slotTo, type = ClickType.PICKUP) } /** * Quick move (Shift + Click) the item in [slot] in player inventory */ -fun SafeClientEvent.quickMoveSlot(slot: Int): Short { - return quickMoveSlot(0, slot) +fun SafeClientEvent.quickMoveSlot(owner: AbstractModule, slot: Int) { + quickMoveSlot(owner, 0, slot) } /** * Quick move (Shift + Click) the item in [slot] in specified [windowId] */ -fun SafeClientEvent.quickMoveSlot(windowId: Int, slot: Int): Short { - return clickSlot(windowId, slot, type = ClickType.QUICK_MOVE) +fun SafeClientEvent.quickMoveSlot(owner: AbstractModule, windowId: Int, slot: Int) { + clickSlot(owner, windowId, slot, type = ClickType.QUICK_MOVE) } /** * Quick move (Shift + Click) the item in [slot] in player inventory */ -fun SafeClientEvent.quickMoveSlot(slot: Slot): Short { - return quickMoveSlot(0, slot) +fun SafeClientEvent.quickMoveSlot(owner: AbstractModule, slot: Slot) { + quickMoveSlot(owner, 0, slot) } /** * Quick move (Shift + Click) the item in [slot] in specified [windowId] */ -fun SafeClientEvent.quickMoveSlot(windowId: Int, slot: Slot): Short { - return clickSlot(windowId, slot, type = ClickType.QUICK_MOVE) +fun SafeClientEvent.quickMoveSlot(owner: AbstractModule, windowId: Int, slot: Slot) { + clickSlot(owner, windowId, slot, type = ClickType.QUICK_MOVE) } - /** * Throw all the item in [slot] in player inventory */ -fun SafeClientEvent.throwAllInSlot(slot: Int): Short { - return throwAllInSlot(0, slot) +fun SafeClientEvent.throwAllInSlot(owner: AbstractModule, slot: Int) { + throwAllInSlot(owner, 0, slot) } /** * Throw all the item in [slot] in specified [windowId] */ -fun SafeClientEvent.throwAllInSlot(windowId: Int, slot: Int): Short { - return clickSlot(windowId, slot, 1, ClickType.THROW) +fun SafeClientEvent.throwAllInSlot(owner: AbstractModule, windowId: Int, slot: Int) { + clickSlot(owner, windowId, slot, 1, ClickType.THROW) } /** * Throw all the item in [slot] in player inventory */ -fun SafeClientEvent.throwAllInSlot(slot: Slot): Short { - return throwAllInSlot(0, slot) +fun SafeClientEvent.throwAllInSlot(owner: AbstractModule, slot: Slot) { + throwAllInSlot(owner, 0, slot) } /** * Throw all the item in [slot] in specified [windowId] */ -fun SafeClientEvent.throwAllInSlot(windowId: Int, slot: Slot): Short { - return clickSlot(windowId, slot, 1, ClickType.THROW) +fun SafeClientEvent.throwAllInSlot(owner: AbstractModule, windowId: Int, slot: Slot) { + clickSlot(owner, windowId, slot, 1, ClickType.THROW) } /** * Put the item currently holding by mouse to somewhere or throw it */ -fun SafeClientEvent.removeHoldingItem() { +fun SafeClientEvent.removeHoldingItem(owner: AbstractModule) { if (player.inventory.itemStack.isEmpty) return val slot = player.inventoryContainer.getSlots(9..45).firstItem(Items.AIR)?.slotNumber // Get empty slots in inventory and offhand ?: player.craftingSlots.firstItem(Items.AIR)?.slotNumber // Get empty slots in crafting slot ?: -999 // Throw on the ground - clickSlot(slot = slot, type = ClickType.PICKUP) + clickSlot(owner, slot = slot, type = ClickType.PICKUP) } - /** * Performs inventory clicking in specific window, slot, mouseButton, and click type - * - * @return Transaction id */ -fun SafeClientEvent.clickSlot(windowId: Int = 0, slot: Slot, mouseButton: Int = 0, type: ClickType): Short { - return clickSlot(windowId, slot.slotNumber, mouseButton, type) +fun SafeClientEvent.clickSlot(owner: AbstractModule, windowId: Int = 0, slot: Slot, mouseButton: Int = 0, type: ClickType) { + clickSlot(owner, windowId, slot.slotNumber, mouseButton, type) } /** * Performs inventory clicking in specific window, slot, mouseButton, and click type - * - * @return Transaction id */ -fun SafeClientEvent.clickSlot(windowId: Int = 0, slot: Int, mouseButton: Int = 0, type: ClickType): Short { +fun SafeClientEvent.clickSlot(owner: AbstractModule, windowId: Int = 0, slot: Int, mouseButton: Int = 0, type: ClickType) { + if (NoGhostItems.isEnabled && NoGhostItems.syncMode != NoGhostItems.SyncMode.PLAYER) { + owner.addInventoryTask( + PlayerInventoryManager.ClickInfo(windowId, slot, mouseButton, type) + ) + } else { + clickSlotUnsynced(windowId, slot, mouseButton, type) + } +} + +fun SafeClientEvent.clickSlotUnsynced(windowId: Int = 0, slot: Int, mouseButton: Int = 0, type: ClickType) { val container = if (windowId == 0) player.inventoryContainer else player.openContainer - container ?: return -32768 + container ?: return - val playerInventory = player.inventory ?: return -32768 + val playerInventory = player.inventory ?: return val transactionID = container.getNextTransactionID(playerInventory) val itemStack = container.slotClick(slot, mouseButton, type, player) @@ -366,6 +375,4 @@ fun SafeClientEvent.clickSlot(windowId: Int = 0, slot: Int, mouseButton: Int = 0 runBlocking { onMainThreadSafe { playerController.updateController() } } - - return transactionID } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/util/math/RotationUtils.kt b/src/main/kotlin/com/lambda/client/util/math/RotationUtils.kt index 899cfd177..c5f30ef74 100644 --- a/src/main/kotlin/com/lambda/client/util/math/RotationUtils.kt +++ b/src/main/kotlin/com/lambda/client/util/math/RotationUtils.kt @@ -1,7 +1,7 @@ package com.lambda.client.util.math -import com.lambda.client.event.SafeClientEvent import com.lambda.client.commons.extension.toDegree +import com.lambda.client.event.SafeClientEvent import net.minecraft.entity.Entity import net.minecraft.util.math.Vec3d import kotlin.math.* diff --git a/src/main/kotlin/com/lambda/client/util/threads/BackgroundScope.kt b/src/main/kotlin/com/lambda/client/util/threads/BackgroundScope.kt index 2a2f1ff2b..261aac306 100644 --- a/src/main/kotlin/com/lambda/client/util/threads/BackgroundScope.kt +++ b/src/main/kotlin/com/lambda/client/util/threads/BackgroundScope.kt @@ -4,7 +4,7 @@ import com.lambda.client.LambdaMod import kotlinx.coroutines.* @OptIn(DelicateCoroutinesApi::class) -internal object BackgroundScope : CoroutineScope by CoroutineScope(newFixedThreadPoolContext(2, "Lambda Background")) { +object BackgroundScope : CoroutineScope by CoroutineScope(newFixedThreadPoolContext(2, "Lambda Background")) { private val jobs = LinkedHashMap() private var started = false diff --git a/src/main/kotlin/com/lambda/client/util/threads/CoroutineUtils.kt b/src/main/kotlin/com/lambda/client/util/threads/CoroutineUtils.kt index d2e1f2104..f2ab1fff8 100644 --- a/src/main/kotlin/com/lambda/client/util/threads/CoroutineUtils.kt +++ b/src/main/kotlin/com/lambda/client/util/threads/CoroutineUtils.kt @@ -1,10 +1,6 @@ package com.lambda.client.util.threads -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.Job -import kotlinx.coroutines.newSingleThreadContext -import kotlinx.coroutines.DelicateCoroutinesApi +import kotlinx.coroutines.* /** * Single thread scope to use in Lambda diff --git a/src/main/kotlin/com/lambda/client/util/threads/MainThreadExecutor.kt b/src/main/kotlin/com/lambda/client/util/threads/MainThreadExecutor.kt index 58f48ffee..024a8f074 100644 --- a/src/main/kotlin/com/lambda/client/util/threads/MainThreadExecutor.kt +++ b/src/main/kotlin/com/lambda/client/util/threads/MainThreadExecutor.kt @@ -2,8 +2,8 @@ package com.lambda.client.util.threads import com.lambda.client.event.LambdaEventBus import com.lambda.client.event.events.RunGameLoopEvent -import com.lambda.client.util.Wrapper import com.lambda.client.event.listener.listener +import com.lambda.client.util.Wrapper import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.completeWith import kotlinx.coroutines.runBlocking diff --git a/src/main/kotlin/com/lambda/client/util/threads/ThreadSafety.kt b/src/main/kotlin/com/lambda/client/util/threads/ThreadSafety.kt index fca0c8f7f..c93198ab9 100644 --- a/src/main/kotlin/com/lambda/client/util/threads/ThreadSafety.kt +++ b/src/main/kotlin/com/lambda/client/util/threads/ThreadSafety.kt @@ -1,10 +1,6 @@ package com.lambda.client.util.threads -import com.lambda.client.event.ClientEvent -import com.lambda.client.event.ClientExecuteEvent -import com.lambda.client.event.SafeClientEvent -import com.lambda.client.event.SafeExecuteEvent -import com.lambda.client.event.ListenerManager +import com.lambda.client.event.* import com.lambda.client.event.listener.AsyncListener import com.lambda.client.event.listener.DEFAULT_PRIORITY import com.lambda.client.event.listener.Listener diff --git a/src/main/resources/assets/shaders/menu/bluegrid.fsh b/src/main/resources/assets/shaders/menu/bluegrid.fsh index 189c247ec..9a49b18ed 100644 --- a/src/main/resources/assets/shaders/menu/bluegrid.fsh +++ b/src/main/resources/assets/shaders/menu/bluegrid.fsh @@ -16,79 +16,79 @@ uniform vec2 mouse; uniform vec2 resolution; void glow(float d) { - float br = 0.0015 * resolution.y; - gl_FragColor.rgb += vec3(0.15, 0.15, 0.45) * br / d; + float br = 0.0015 * resolution.y; + gl_FragColor.rgb += vec3(0.15, 0.15, 0.45) * br / d; } -void line( vec2 a, vec2 l ) { - l.x *= resolution.y/resolution.x; - l += 0.5; - l *= resolution; - - vec2 P = gl_FragCoord.xy; - - float angle = length(mouse)/10.0; - mat2 rot = mat2(cos(angle), -sin(angle), - sin(angle), cos(angle)); - P = rot * P; - - a.x *= resolution.y/resolution.x; - a += 0.5; - a *= resolution; - - vec2 aP = P-a; - vec2 al = l-a; - vec3 al3 = vec3(al, 0.0); - vec3 aP3 = vec3(aP, 0.0); - //float q = length(dot(aP,al))/length(al); - float q = length(cross(aP3,al3))/length(al3); - - float d = q; - if ( dot(al, aP) <= 0.0 ) { // before start - d = distance(P, a); - } - else if ( dot(al, al) <= dot(al, aP) ) { // after end - d = distance(P, l); - } - glow(d); +void line(vec2 a, vec2 l) { + l.x *= resolution.y/resolution.x; + l += 0.5; + l *= resolution; + + vec2 P = gl_FragCoord.xy; + + float angle = length(mouse)/10.0; + mat2 rot = mat2(cos(angle), -sin(angle), + sin(angle), cos(angle)); + P = rot * P; + + a.x *= resolution.y/resolution.x; + a += 0.5; + a *= resolution; + + vec2 aP = P-a; + vec2 al = l-a; + vec3 al3 = vec3(al, 0.0); + vec3 aP3 = vec3(aP, 0.0); + //float q = length(dot(aP,al))/length(al); + float q = length(cross(aP3, al3))/length(al3); + + float d = q; + if (dot(al, aP) <= 0.0) { // before start + d = distance(P, a); + } + else if (dot(al, al) <= dot(al, aP)) { // after end + d = distance(P, l); + } + glow(d); } void point(vec2 a) { - a.x *= resolution.y/resolution.x; - a += 0.5; - a *= resolution; + a.x *= resolution.y/resolution.x; + a += 0.5; + a *= resolution; - vec2 P = gl_FragCoord.xy; - float d = distance(P, a); - glow(d); + vec2 P = gl_FragCoord.xy; + float d = distance(P, a); + glow(d); } float rand(int seed) { - return fract(sin(float(seed)*15.234234) + sin(float(seed)*4.3456342) * 372.4532); + return fract(sin(float(seed)*15.234234) + sin(float(seed)*4.3456342) * 372.4532); } -void main( void ) { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - - // Horizontal grid lines - float y = 0.0; - for (int l=1; l<13; l++) { - y = -1.0/(0.6 * sin(time * 0.73) + float(l)*1.2) + 0.25; - line(vec2(-2.0, y), vec2(2.0, y)); - } - - // Perpendicular grid lines - for (int l=-30; l<31; l++) { - float x = float(l) + fract(time * 3.25); - line(vec2(x * 0.025, y), vec2(x, -1.0)); - } - - // Starfield - - for (int l=1; l<70; l++) { - float sx = (fract(rand(l+342) + time * (0.002 + 0.01*rand(l)))-0.5) * 3.0; - float sy = y + 0.4 * rand(l+8324); - point(vec2(sx,sy)); - } +void main(void) { + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + + // Horizontal grid lines + float y = 0.0; + for (int l=1; l<13; l++) { + y = -1.0/(0.6 * sin(time * 0.73) + float(l)*1.2) + 0.25; + line(vec2(-2.0, y), vec2(2.0, y)); + } + + // Perpendicular grid lines + for (int l=-30; l<31; l++) { + float x = float(l) + fract(time * 3.25); + line(vec2(x * 0.025, y), vec2(x, -1.0)); + } + + // Starfield + + for (int l=1; l<70; l++) { + float sx = (fract(rand(l+342) + time * (0.002 + 0.01*rand(l)))-0.5) * 3.0; + float sy = y + 0.4 * rand(l+8324); + point(vec2(sx, sy)); + } } \ No newline at end of file diff --git a/src/main/resources/assets/shaders/menu/bluenebula.fsh b/src/main/resources/assets/shaders/menu/bluenebula.fsh index a951f975d..ab641eb1f 100644 --- a/src/main/resources/assets/shaders/menu/bluenebula.fsh +++ b/src/main/resources/assets/shaders/menu/bluenebula.fsh @@ -1,5 +1,5 @@ #ifdef GL_ES -precision highp float; // ios +precision highp float;// ios #endif @@ -29,197 +29,193 @@ uniform vec2 resolution; float triangle(float x, float a) { -float output2 = 2.0*abs( 2.0* ( (x/a) - floor( (x/a) + 0.5) ) ) - 1.0; -return output2; + float output2 = 2.0*abs(2.0* ((x/a) - floor((x/a) + 0.5))) - 1.0; + return output2; } float field(in vec3 p) { - float strength = 8. + .03 * log(1.e-6 + fract(sin(time) * 4373.11)); - float accum = 0.; - float prev = 0.; - float tw = 0.; - - - for (int i = 0; i < 6; ++i) { - float mag = dot(p, p); - p = abs(p) / mag + vec3(-.5, -.8 + 0.1*sin(time*0.2 + 2.0), -1.1+0.3*cos(time*0.15)); - float w = exp(-float(i) / 7.); - accum += w * exp(-strength * pow(abs(mag - prev), 2.3)); - tw += w; - prev = mag; - } - return max(0., 5. * accum / tw - .7); + float strength = 8. + .03 * log(1.e-6 + fract(sin(time) * 4373.11)); + float accum = 0.; + float prev = 0.; + float tw = 0.; + + + for (int i = 0; i < 6; ++i) { + float mag = dot(p, p); + p = abs(p) / mag + vec3(-.5, -.8 + 0.1*sin(time*0.2 + 2.0), -1.1+0.3*cos(time*0.15)); + float w = exp(-float(i) / 7.); + accum += w * exp(-strength * pow(abs(mag - prev), 2.3)); + tw += w; + prev = mag; + } + return max(0., 5. * accum / tw - .7); } void main() { - vec2 uv2 = 2. * gl_FragCoord.xy / resolution.xy - 1.; - vec2 uvs = uv2 * resolution.xy / max(resolution.x, resolution.y); + vec2 uv2 = 2. * gl_FragCoord.xy / resolution.xy - 1.; + vec2 uvs = uv2 * resolution.xy / max(resolution.x, resolution.y); - float time2 = time*0.7; + float time2 = time*0.7; - float speed = speed2; - //speed = 0.005 * cos(time2*0.002 + 3.1415926/4.0); + float speed = speed2; + //speed = 0.005 * cos(time2*0.002 + 3.1415926/4.0); - speed = 0.1; + speed = 0.1; - float formuparam = formuparam2; + float formuparam = formuparam2; + //get coords and direction - //get coords and direction + vec2 uv = uvs; - vec2 uv = uvs; + //mouse rotation + float a_xz = 0.9; + float a_yz = -.6; + float a_xy = 0.9 + time*0.04; - //mouse rotation - float a_xz = 0.9; - float a_yz = -.6; - float a_xy = 0.9 + time*0.04; + mat2 rot_xz = mat2(cos(a_xz), sin(a_xz), -sin(a_xz), cos(a_xz)); + mat2 rot_yz = mat2(cos(a_yz), sin(a_yz), -sin(a_yz), cos(a_yz)); - mat2 rot_xz = mat2(cos(a_xz),sin(a_xz),-sin(a_xz),cos(a_xz)); + mat2 rot_xy = mat2(cos(a_xy), sin(a_xy), -sin(a_xy), cos(a_xy)); - mat2 rot_yz = mat2(cos(a_yz),sin(a_yz),-sin(a_yz),cos(a_yz)); - mat2 rot_xy = mat2(cos(a_xy),sin(a_xy),-sin(a_xy),cos(a_xy)); + float v2 =1.0; + vec3 dir=vec3(uv*zoom, 1.); - float v2 =1.0; + vec3 from=vec3(0.0, 0.0, 0.0); - vec3 dir=vec3(uv*zoom,1.); - vec3 from=vec3(0.0, 0.0,0.0); + vec3 forward = vec3(0., 0., 1.); - vec3 forward = vec3(0.,0.,1.); + from.x += transverseSpeed*(1.0)*cos(0.01*time) + 0.001*time; + from.y += transverseSpeed*(1.0)*sin(0.01*time) +0.001*time; + from.z += 0.003*time; - from.x += transverseSpeed*(1.0)*cos(0.01*time) + 0.001*time; - from.y += transverseSpeed*(1.0)*sin(0.01*time) +0.001*time; - from.z += 0.003*time; + dir.xy*=rot_xy; + forward.xy *= rot_xy; + dir.xz*=rot_xz; + forward.xz *= rot_xz; - dir.xy*=rot_xy; - forward.xy *= rot_xy; - dir.xz*=rot_xz; - forward.xz *= rot_xz; + dir.yz*= rot_yz; + forward.yz *= rot_yz; - dir.yz*= rot_yz; - forward.yz *= rot_yz; + from.xy*=-rot_xy; + from.xz*=rot_xz; + from.yz*= rot_yz; - from.xy*=-rot_xy; - from.xz*=rot_xz; - from.yz*= rot_yz; + //zoom + float zooom = (time2-3311.)*speed; + from += forward* zooom; + float sampleShift = mod(zooom, stepsize); + float zoffset = -sampleShift; + sampleShift /= stepsize;// make from 0 to 1 - //zoom - float zooom = (time2-3311.)*speed; - from += forward* zooom; - float sampleShift = mod( zooom, stepsize ); - float zoffset = -sampleShift; - sampleShift /= stepsize; // make from 0 to 1 + //volumetric rendering + float s=0.24; + float s3 = s + stepsize/2.0; + vec3 v=vec3(0.); + float t3 = 0.0; + vec3 backCol2 = vec3(0.); + for (int r=0; r 2) + { + a += i > 7 ? min(12., D) : D; + } + pa=length(p2); + } - #ifdef cloud - t3 = field(p3); - #endif - float pa,a=pa=0.; - for (int i=0; i3) fade*=1.-dm; // dark matter, don't render near + // brightens stuff up a bit + float s1 = s+zoffset; + // need closed form expression for this, now that we shift samples + float fade = pow(distfading, max(0., float(r)-sampleShift)); - if (i > 2) - { - a += i > 7 ? min( 12., D) : D; - } - pa=length(p2); - } + //t3 += fade; - //float dm=max(0.,darkmatter-a*a*.001); //dark matter - a*=a*a; // add contrast - //if (r>3) fade*=1.-dm; // dark matter, don't render near - // brightens stuff up a bit - float s1 = s+zoffset; - // need closed form expression for this, now that we shift samples - float fade = pow(distfading,max(0.,float(r)-sampleShift)); + v+=fade; + //backCol2 -= fade; + // fade out samples as they approach the camera + if (r == 0) + fade *= (1. - (sampleShift)); + // fade in samples as they approach from the distance + if (r == volsteps-1) + fade *= sampleShift; + v+=vec3(s1, s1*s1, s1*s1*s1*s1)*a*brightness*fade;// coloring based on distance - //t3 += fade; + backCol2 += mix(.4, 1., v2) * vec3(0.20 * t3 * t3 * t3, 0.4 * t3 * t3, t3 * 0.7) * fade; - v+=fade; - //backCol2 -= fade; - // fade out samples as they approach the camera - if( r == 0 ) - fade *= (1. - (sampleShift)); - // fade in samples as they approach from the distance - if( r == volsteps-1 ) - fade *= sampleShift; - v+=vec3(s1,s1*s1,s1*s1*s1*s1)*a*brightness*fade; // coloring based on distance + s+=stepsize; + s3 += stepsize; - backCol2 += mix(.4, 1., v2) * vec3(0.20 * t3 * t3 * t3, 0.4 * t3 * t3, t3 * 0.7) * fade; + } - s+=stepsize; - s3 += stepsize; + v=mix(vec3(length(v)), v, saturation);//color adjust - } - v=mix(vec3(length(v)),v,saturation); //color adjust + vec4 forCol2 = vec4(v*.01, 1.); + #ifdef cloud + backCol2 *= cloud; + #endif + backCol2.b *= 0.01; + backCol2.r *= 0.01; - vec4 forCol2 = vec4(v*.01,1.); - #ifdef cloud - backCol2 *= cloud; - #endif - backCol2.b *= 0.01; + backCol2.b = 0.5*mix(backCol2.b, backCol2.g, 1.2); + backCol2.g = 0.01; - backCol2.r *= 0.01; + backCol2.bg = mix(backCol2.gb, backCol2.bg, 0.5*(cos(time*0.01) + 1.0)); - - - backCol2.b = 0.5*mix(backCol2.b, backCol2.g, 1.2); - backCol2.g = 0.01; - - backCol2.bg = mix(backCol2.gb, backCol2.bg, 0.5*(cos(time*0.01) + 1.0)); - - gl_FragColor = forCol2 + vec4(backCol2, 1.0); + gl_FragColor = forCol2 + vec4(backCol2, 1.0); } \ No newline at end of file diff --git a/src/main/resources/assets/shaders/menu/bluevortex.fsh b/src/main/resources/assets/shaders/menu/bluevortex.fsh index 4e9e97782..aee8befbb 100644 --- a/src/main/resources/assets/shaders/menu/bluevortex.fsh +++ b/src/main/resources/assets/shaders/menu/bluevortex.fsh @@ -20,7 +20,7 @@ uniform vec2 resolution; vec2 Rot(vec2 v, float angle) { return vec2(v.x * cos(angle) + v.y * sin(angle), - v.y * cos(angle) - v.x * sin(angle)); + v.y * cos(angle) - v.x * sin(angle)); } vec3 DrawStar(float len, float angle) @@ -66,7 +66,7 @@ vec3 DrawCloud(float dis, float angle, vec2 coord) fre *= -2.0; ap *= 0.5; } - float len2=dot(coord,coord); + float len2=dot(coord, coord); d+=len2*4.0; return baseColor + cloudColor * d; } diff --git a/src/main/resources/assets/shaders/menu/cave.fsh b/src/main/resources/assets/shaders/menu/cave.fsh index 9fb69ce15..705319c48 100644 --- a/src/main/resources/assets/shaders/menu/cave.fsh +++ b/src/main/resources/assets/shaders/menu/cave.fsh @@ -9,67 +9,67 @@ uniform vec2 resolution; const vec4 iMouse = vec4(0.0); mat2 r2d(float a) { - float c = cos(a), s = sin(a); - return mat2(c, s, -s, c); + float c = cos(a), s = sin(a); + return mat2(c, s, -s, c); } vec2 path(float t) { - float a = sin(t*.2 + 1.5), b = sin(t*.2); - return vec2(2.*a, a*b); + float a = sin(t*.2 + 1.5), b = sin(t*.2); + return vec2(2.*a, a*b); } float g = 0.; float de(vec3 p) { - p.xy -= path(p.z); + p.xy -= path(p.z); - float d = -length(p.xy) + 4.; + float d = -length(p.xy) + 4.; - g += .01 / (.01 + d * d); - return d; + g += .01 / (.01 + d * d); + return d; } void mainImage(out vec4 fragColor, in vec2 fragCoord) { - vec2 uv = fragCoord / iResolution.xy - .5; - uv.x *= iResolution.x / iResolution.y; + vec2 uv = fragCoord / iResolution.xy - .5; + uv.x *= iResolution.x / iResolution.y; - float dt = iTime * 1.; - vec3 ro = vec3(0, 0, -5. + dt); - vec3 ta = vec3(0, 0, dt); + float dt = iTime * 1.; + vec3 ro = vec3(0, 0, -5. + dt); + vec3 ta = vec3(0, 0, dt); - ro.xy += path(ro.z); - ta.xy += path(ta.z); + ro.xy += path(ro.z); + ta.xy += path(ta.z); - vec3 fwd = normalize(ta - ro); - vec3 right = cross(fwd, vec3(0, 1, 0)); - vec3 up = cross(right, fwd); - vec3 rd = normalize(fwd + uv.x*right + uv.y*up); + vec3 fwd = normalize(ta - ro); + vec3 right = cross(fwd, vec3(0, 1, 0)); + vec3 up = cross(right, fwd); + vec3 rd = normalize(fwd + uv.x*right + uv.y*up); - rd.xy *= r2d(sin(-ro.x / 3.14)*.3); - vec3 p = floor(ro) + .5; - vec3 mask; - vec3 drd = 1. / abs(rd); - rd = sign(rd); - vec3 side = drd * (rd * (p - ro) + .5); + rd.xy *= r2d(sin(-ro.x / 3.14)*.3); + vec3 p = floor(ro) + .5; + vec3 mask; + vec3 drd = 1. / abs(rd); + rd = sign(rd); + vec3 side = drd * (rd * (p - ro) + .5); - float t = 0., ri = 0.; - for (float i = 0.; i < 1.; i += .01) { - ri = i; - if (de(p) < 0.) break; - mask = step(side, side.yzx) * step(side, side.zxy); + float t = 0., ri = 0.; + for (float i = 0.; i < 1.; i += .01) { + ri = i; + if (de(p) < 0.) break; + mask = step(side, side.yzx) * step(side, side.zxy); - side += drd * mask; - p += rd * mask; - } - t = length(p - ro); + side += drd * mask; + p += rd * mask; + } + t = length(p - ro); - vec3 c = vec3(1) * length(mask * vec3(1., .5, .75)); - c = mix(vec3(.2, .2, .7), vec3(.2, .1, .2), c); - c += g * .4; - c.r += sin(iTime)*0. + .42*sin(p.z*.25 - iTime * 0.); - c = mix(c, vec3(.2, .1, .2), 1. - exp(-.001*t*t)); + vec3 c = vec3(1) * length(mask * vec3(1., .5, .75)); + c = mix(vec3(.2, .2, .7), vec3(.2, .1, .2), c); + c += g * .4; + c.r += sin(iTime)*0. + .42*sin(p.z*.25 - iTime * 0.); + c = mix(c, vec3(.2, .1, .2), 1. - exp(-.001*t*t)); - fragColor = vec4(c, 1.0); + fragColor = vec4(c, 1.0); } void main(void) diff --git a/src/main/resources/assets/shaders/menu/clouds.fsh b/src/main/resources/assets/shaders/menu/clouds.fsh index 2c363d79a..ec22f340f 100644 --- a/src/main/resources/assets/shaders/menu/clouds.fsh +++ b/src/main/resources/assets/shaders/menu/clouds.fsh @@ -67,11 +67,11 @@ uniform vec2 resolution; bool STRUCTURED = true; // cam moving in a straight line -vec3 lookDir = vec3(cos(PI * 1.2),0.,sin(PI * 1.2)); -vec3 camVel = vec3(-20.,0.,0.); -float zoom = 1.0; // 1.5; +vec3 lookDir = vec3(cos(PI * 1.2), 0., sin(PI * 1.2)); +vec3 camVel = vec3(-20., 0., 0.); +float zoom = 1.0;// 1.5; -vec3 sundir = normalize(vec3(-1.0,0.0,-1.)); +vec3 sundir = normalize(vec3(-1.0, 0.0, -1.)); // Noise salvaged from here http://glslsandbox.com/e#35155.0 @@ -82,124 +82,124 @@ float rand(vec3 p){ float noise(vec3 pos) { - vec3 ip = floor(pos); - vec3 fp = smoothstep(0.0, 1.0, fract(pos)); - vec4 a = vec4( - rand(ip + vec3(0, 0, 0)), - rand(ip + vec3(1, 0, 0)), - rand(ip + vec3(0, 1, 0)), - rand(ip + vec3(1, 1, 0))); - vec4 b = vec4( - rand(ip + vec3(0, 0, 1)), - rand(ip + vec3(1, 0, 1)), - rand(ip + vec3(0, 1, 1)), - rand(ip + vec3(1, 1, 1))); - - a = mix(a, b, fp.z); - a.xy = mix(a.xy, a.zw, fp.yx); - return mix(a.x, a.y, fp.x); + vec3 ip = floor(pos); + vec3 fp = smoothstep(0.0, 1.0, fract(pos)); + vec4 a = vec4( + rand(ip + vec3(0, 0, 0)), + rand(ip + vec3(1, 0, 0)), + rand(ip + vec3(0, 1, 0)), + rand(ip + vec3(1, 1, 0))); + vec4 b = vec4( + rand(ip + vec3(0, 0, 1)), + rand(ip + vec3(1, 0, 1)), + rand(ip + vec3(0, 1, 1)), + rand(ip + vec3(1, 1, 1))); + + a = mix(a, b, fp.z); + a.xy = mix(a.xy, a.zw, fp.yx); + return mix(a.x, a.y, fp.x); } -vec4 map( in vec3 p ) +vec4 map(in vec3 p) { - float d = 0.2 + .8 * sin(0.6*p.z)*sin(0.5*p.x) - p.y; + float d = 0.2 + .8 * sin(0.6*p.z)*sin(0.5*p.x) - p.y; vec3 q = p; float f; - f = 0.5000*noise( q ); q = q*2.02; - f += 0.2500*noise( q ); q = q*2.03; - f += 0.1250*noise( q ); q = q*2.01; - f += 0.0625*noise( q ); + f = 0.5000*noise(q); q = q*2.02; + f += 0.2500*noise(q); q = q*2.03; + f += 0.1250*noise(q); q = q*2.01; + f += 0.0625*noise(q); d += 2.75 * f; - d = clamp( d, 0.0, 1.0 ); + d = clamp(d, 0.0, 1.0); - vec4 res = vec4( d ); + vec4 res = vec4(d); - vec3 col = 1.15 * vec3(1.0,0.95,0.8); - col += vec3(1.,0.,0.) * exp2(res.x*10.-10.); - res.xyz = mix( col, vec3(0.7,0.7,0.7), res.x ); + vec3 col = 1.15 * vec3(1.0, 0.95, 0.8); + col += vec3(1., 0., 0.) * exp2(res.x*10.-10.); + res.xyz = mix(col, vec3(0.7, 0.7, 0.7), res.x); return res; } -// to share with unity hlsl -#define float2 vec2 -#define float3 vec3 -#define fmod mod -float mysign( float x ) { return x < 0. ? -1. : 1. ; } -float2 mysign( float2 x ) { return float2( x.x < 0. ? -1. : 1., x.y < 0. ? -1. : 1. ) ; } + // to share with unity hlsl + #define float2 vec2 + #define float3 vec3 + #define fmod mod +float mysign(float x) { return x < 0. ? -1. : 1.; } + float2 mysign(float2 x) { return float2(x.x < 0. ? -1. : 1., x.y < 0. ? -1. : 1.); } // compute ray march start offset and ray march step delta and blend weight for the current ray -void SetupSampling( out float2 t, out float2 dt, out float2 wt, in float3 ro, in float3 rd ) +void SetupSampling(out float2 t, out float2 dt, out float2 wt, in float3 ro, in float3 rd) { - if( !STRUCTURED ) + if (!STRUCTURED) { - dt = float2(PERIOD,PERIOD); + dt = float2(PERIOD, PERIOD); t = dt; - wt = float2(0.5,0.5); + wt = float2(0.5, 0.5); return; } - // the following code computes intersections between the current ray, and a set - // of (possibly) stationary sample planes. + // the following code computes intersections between the current ray, and a set + // of (possibly) stationary sample planes. - // much of this should be more at home on the CPU or in a VS. + // much of this should be more at home on the CPU or in a VS. - // structured sampling pattern line normals - float3 n0 = (abs( rd.x ) > abs( rd.z )) ? float3(1., 0., 0.) : float3(0., 0., 1.); // non diagonal - float3 n1 = float3(mysign( rd.x * rd.z ), 0., 1.); // diagonal + // structured sampling pattern line normals + float3 n0 = (abs(rd.x) > abs(rd.z)) ? float3(1., 0., 0.) : float3(0., 0., 1.);// non diagonal +float3 n1 = float3(mysign(rd.x * rd.z), 0., 1.);// diagonal - // normal lengths (used later) - float2 ln = float2(length( n0 ), length( n1 )); +// normal lengths (used later) +float2 ln = float2(length(n0), length(n1)); n0 /= ln.x; n1 /= ln.y; // some useful DPs - float2 ndotro = float2(dot( ro, n0 ), dot( ro, n1 )); - float2 ndotrd = float2(dot( rd, n0 ), dot( rd, n1 )); + float2 ndotro = float2(dot(ro, n0), dot(ro, n1)); +float2 ndotrd = float2(dot(rd, n0), dot(rd, n1)); - // step size - float2 period = ln * PERIOD; - dt = period / abs( ndotrd ); +// step size +float2 period = ln * PERIOD; + dt = period / abs(ndotrd); // dist to line through origin - float2 dist = abs( ndotro / ndotrd ); + float2 dist = abs(ndotro / ndotrd); // raymarch start offset - skips leftover bit to get from ro to first strata lines - t = -mysign( ndotrd ) * fmod( ndotro, period ) / abs( ndotrd ); - if( ndotrd.x > 0. ) t.x += dt.x; - if( ndotrd.y > 0. ) t.y += dt.y; + t = -mysign(ndotrd) * fmod(ndotro, period) / abs(ndotrd); + if (ndotrd.x > 0.) t.x += dt.x; + if (ndotrd.y > 0.) t.y += dt.y; // sample weights float minperiod = PERIOD; - float maxperiod = sqrt( 2. )*PERIOD; - wt = smoothstep( maxperiod, minperiod, dt/ln ); + float maxperiod = sqrt(2.)*PERIOD; + wt = smoothstep(maxperiod, minperiod, dt/ln); wt /= (wt.x + wt.y); } -vec4 raymarch( in vec3 ro, in vec3 rd ) +vec4 raymarch(in vec3 ro, in vec3 rd) { vec4 sum = vec4(0, 0, 0, 0); // setup sampling - compute intersection of ray with 2 sets of planes float2 t, dt, wt; - SetupSampling( t, dt, wt, ro, rd ); + SetupSampling(t, dt, wt, ro, rd); // fade samples at far extent - float f = .6; // magic number - TODO justify this + float f = .6;// magic number - TODO justify this float endFade = f*float(SAMPLE_COUNT)*PERIOD; float startFade = .8*endFade; - for(int i=0; i 0.99 ) continue; + if (sum.a > 0.99) continue; // data for next sample - vec4 data = t.x < t.y ? vec4( t.x, wt.x, dt.x, 0. ) : vec4( t.y, wt.y, 0., dt.y ); + vec4 data = t.x < t.y ? vec4(t.x, wt.x, dt.x, 0.) : vec4(t.y, wt.y, 0., dt.y); // somewhat similar to: https://www.shadertoy.com/view/4dX3zl //vec4 data = mix( vec4( t.x, wt.x, dt.x, 0. ), vec4( t.y, wt.y, 0., dt.y ), float(t.x > t.y) ); vec3 pos = ro + data.x * rd; @@ -207,12 +207,12 @@ vec4 raymarch( in vec3 ro, in vec3 rd ) t += data.zw; // fade samples at far extent - w *= smoothstep( endFade, startFade, data.x ); + w *= smoothstep(endFade, startFade, data.x); - vec4 col = map( pos ); + vec4 col = map(pos); // iqs goodness - float dif = clamp((col.w - map(pos+0.6*sundir).w)/0.6, 0.0, 1.0 ); + float dif = clamp((col.w - map(pos+0.6*sundir).w)/0.6, 0.0, 1.0); vec3 lin = vec3(0.51, 0.53, 0.63)*1.35 + 0.55*vec3(0.85, 0.57, 0.3)*dif; col.xyz *= lin; @@ -227,38 +227,38 @@ vec4 raymarch( in vec3 ro, in vec3 rd ) sum.xyz /= (0.001+sum.w); - return clamp( sum, 0.0, 1.0 ); + return clamp(sum, 0.0, 1.0); } -vec3 sky( vec3 rd ) +vec3 sky(vec3 rd) { vec3 col = vec3(0.); float hort = 1. - clamp(abs(rd.y), 0., 1.); - col += 0.5*vec3(.99,.5,.0)*exp2(hort*8.-8.); - col += 0.1*vec3(.5,.9,1.)*exp2(hort*3.-3.); - col += 0.55*vec3(.6,.6,.9); - - float sun = clamp( dot(sundir,rd), 0.0, 1.0 ); - col += .2*vec3(1.0,0.3,0.2)*pow( sun, 2.0 ); - col += .5*vec3(1.,.9,.9)*exp2(sun*650.-650.); - col += .1*vec3(1.,1.,0.1)*exp2(sun*100.-100.); - col += .3*vec3(1.,.7,0.)*exp2(sun*50.-50.); - col += .5*vec3(1.,0.3,0.05)*exp2(sun*10.-10.); - - float ax = atan(rd.y,length(rd.xz))/1.; - float ay = atan(rd.z,rd.x)/2.; - float st = noise( vec3(ax,ay,1.0) ); - float st2 = noise( .25*vec3(ax,ay,0.5) ); + col += 0.5*vec3(.99, .5, .0)*exp2(hort*8.-8.); + col += 0.1*vec3(.5, .9, 1.)*exp2(hort*3.-3.); + col += 0.55*vec3(.6, .6, .9); + + float sun = clamp(dot(sundir, rd), 0.0, 1.0); + col += .2*vec3(1.0, 0.3, 0.2)*pow(sun, 2.0); + col += .5*vec3(1., .9, .9)*exp2(sun*650.-650.); + col += .1*vec3(1., 1., 0.1)*exp2(sun*100.-100.); + col += .3*vec3(1., .7, 0.)*exp2(sun*50.-50.); + col += .5*vec3(1., 0.3, 0.05)*exp2(sun*10.-10.); + + float ax = atan(rd.y, length(rd.xz))/1.; + float ay = atan(rd.z, rd.x)/2.; + float st = noise(vec3(ax, ay, 1.0)); + float st2 = noise(.25*vec3(ax, ay, 0.5)); st *= st2; - st = smoothstep(0.65,.9,st); - col = mix(col,col+1.8*st,clamp(1.-1.1*length(col),0.,1.)); + st = smoothstep(0.65, .9, st); + col = mix(col, col+1.8*st, clamp(1.-1.1*length(col), 0., 1.)); return col; } -void main( void ) { +void main(void) { vec2 q = gl_FragCoord.xy / resolution.xy; @@ -266,28 +266,28 @@ void main( void ) { p.x *= resolution.x/ resolution.y; // camera - vec3 ro = vec3(0.,1.5,0.) + 0.01*time*camVel; - vec3 ta = ro + lookDir; //vec3(ro.x, ro.y, ro.z-1.); - vec3 ww = normalize( ta - ro); - vec3 uu = normalize(cross( vec3(0.0,1.0,0.0), ww )); - vec3 vv = normalize(cross(ww,uu)); + vec3 ro = vec3(0., 1.5, 0.) + 0.01*time*camVel; + vec3 ta = ro + lookDir;//vec3(ro.x, ro.y, ro.z-1.); + vec3 ww = normalize(ta - ro); + vec3 uu = normalize(cross(vec3(0.0, 1.0, 0.0), ww)); + vec3 vv = normalize(cross(ww, uu)); float fov = 1.; - vec3 rd = normalize( fov*p.x*uu + fov*1.2*p.y*vv + 1.5*ww ); + vec3 rd = normalize(fov*p.x*uu + fov*1.2*p.y*vv + 1.5*ww); // divide by forward component to get fixed z layout instead of fixed dist layout //vec3 rd_layout = rd/mix(dot(rd,ww),1.0,samplesCurvature); - vec4 clouds = raymarch( ro, rd ); + vec4 clouds = raymarch(ro, rd); vec3 col = clouds.xyz; // sky if visible - if( clouds.w <= 0.99 ) - col = mix( sky(rd), col, clouds.w ); + if (clouds.w <= 0.99) + col = mix(sky(rd), col, clouds.w); - col = clamp(col, 0., 1.); - col = smoothstep(0.,1.,col); - col *= pow( 16.0*q.x*q.y*(1.0-q.x)*(1.0-q.y), 0.12 ); //Vign + col = clamp(col, 0., 1.); + col = smoothstep(0., 1., col); + col *= pow(16.0*q.x*q.y*(1.0-q.x)*(1.0-q.y), 0.12);//Vign - gl_FragColor = vec4( col, 1.0 ); + gl_FragColor = vec4(col, 1.0); } \ No newline at end of file diff --git a/src/main/resources/assets/shaders/menu/doughnuts.fsh b/src/main/resources/assets/shaders/menu/doughnuts.fsh index c18031606..ab56dd37d 100644 --- a/src/main/resources/assets/shaders/menu/doughnuts.fsh +++ b/src/main/resources/assets/shaders/menu/doughnuts.fsh @@ -11,79 +11,79 @@ uniform vec2 resolution; #define pi 3.14159265359 vec3 rotateY(in vec3 v, in float a) { - return vec3(cos(a)*v.x + sin(a)*v.z, v.y,-sin(a)*v.x + cos(a)*v.z); + return vec3(cos(a)*v.x + sin(a)*v.z, v.y, -sin(a)*v.x + cos(a)*v.z); } vec3 rotateX(in vec3 v, in float a) { - return vec3(v.x,cos(a)*v.y + sin(a)*v.z,-sin(a)*v.y + cos(a)*v.z); + return vec3(v.x, cos(a)*v.y + sin(a)*v.z, -sin(a)*v.y + cos(a)*v.z); } -float torus(in vec3 p,in float radius,in float dist){ - return max(pow(dist-length(p.xz),2.0)+p.y*p.y-radius*radius,0.0); +float torus(in vec3 p, in float radius, in float dist){ + return max(pow(dist-length(p.xz), 2.0)+p.y*p.y-radius*radius, 0.0); } vec3 hsv(in float h, in float s, in float v) { - return mix(vec3(1.0), clamp((abs(fract(h + vec3(3, 2, 1) / 3.0) * 6.0 - 3.0) - 1.0), 0.0 , 1.0), s) * v; + return mix(vec3(1.0), clamp((abs(fract(h + vec3(3, 2, 1) / 3.0) * 6.0 - 3.0) - 1.0), 0.0, 1.0), s) * v; } -float angleBetween(vec3 a,vec3 b){ - float f=acos(dot(a,b)); - if(sign(a.y)<0.0){ - return 2.0*pi-f; - } - return f; +float angleBetween(vec3 a, vec3 b){ + float f=acos(dot(a, b)); + if (sign(a.y)<0.0){ + return 2.0*pi-f; + } + return f; } -vec2 positionOnTorus(in vec3 p,in float dist){ - p=fract(p)-0.5; - float i=(atan(p.x,p.z)+pi)/(2.0*pi); +vec2 positionOnTorus(in vec3 p, in float dist){ + p=fract(p)-0.5; + float i=(atan(p.x, p.z)+pi)/(2.0*pi); - vec3 p2=normalize(vec3(p.x,0.0,p.z)); - vec3 p3=normalize(dist*p2-p); - float j=angleBetween(p3,p2)/(2.0*pi); - return vec2(i,j); + vec3 p2=normalize(vec3(p.x, 0.0, p.z)); + vec3 p3=normalize(dist*p2-p); + float j=angleBetween(p3, p2)/(2.0*pi); + return vec2(i, j); } vec3 texture(vec2 p){ - float si1=0.55+0.01*sin(p.x*20.0*pi); - float si2=0.95+0.01*sin(p.x*10.0*pi-0.3); - if(p.ysi1){ - return vec3(1,1,1); - } - return mix(vec3(0.98,0.8,0.5),vec3(0.95,0.6,0.05),pow(abs(p.y-0.5)*2.0,0.5)); + float si1=0.55+0.01*sin(p.x*20.0*pi); + float si2=0.95+0.01*sin(p.x*10.0*pi-0.3); + if (p.ysi1){ + return vec3(1, 1, 1); + } + return mix(vec3(0.98, 0.8, 0.5), vec3(0.95, 0.6, 0.05), pow(abs(p.y-0.5)*2.0, 0.5)); } //rayMarcher by http://glsl.heroku.com/e#14543.0 vec3 intersect(in vec3 rayOrigin, in vec3 rayDir) { - float total_dist = 990.0; - vec3 p = rayOrigin; - float d = 1.0; - float iter = 0.0; - - for (int i = 0; i < MAX_ITER; i++) - { - if (d < 0.001) break; - - d = torus(fract(p)-0.5,0.12,0.2); - p += d*rayDir; - total_dist += d; - iter++; - } - - if (d < 0.001) { - return texture(positionOnTorus(p,0.2))*vec3(1.0-iter/float(MAX_ITER)); - } - return vec3(0.0); + float total_dist = 990.0; + vec3 p = rayOrigin; + float d = 1.0; + float iter = 0.0; + + for (int i = 0; i < MAX_ITER; i++) + { + if (d < 0.001) break; + + d = torus(fract(p)-0.5, 0.12, 0.2); + p += d*rayDir; + total_dist += d; + iter++; + } + + if (d < 0.001) { + return texture(positionOnTorus(p, 0.2))*vec3(1.0-iter/float(MAX_ITER)); + } + return vec3(0.0); } void main() { - vec2 screenPos=gl_FragCoord.xy/resolution-0.5; - vec3 rayDir=normalize(vec3(screenPos.x*1.5,screenPos.y,0.5)); - rayDir=rotateX(rayDir,4.0*(mouse.y-0.5)); - rayDir=rotateY(rayDir,4.0*(mouse.x-0.5)); - vec3 cameraOrigin = vec3(0, 0, time); + vec2 screenPos=gl_FragCoord.xy/resolution-0.5; + vec3 rayDir=normalize(vec3(screenPos.x*1.5, screenPos.y, 0.5)); + rayDir=rotateX(rayDir, 4.0*(mouse.y-0.5)); + rayDir=rotateY(rayDir, 4.0*(mouse.x-0.5)); + vec3 cameraOrigin = vec3(0, 0, time); - gl_FragColor = vec4(intersect(cameraOrigin, rayDir), 1.0); + gl_FragColor = vec4(intersect(cameraOrigin, rayDir), 1.0); } diff --git a/src/main/resources/assets/shaders/menu/fire.fsh b/src/main/resources/assets/shaders/menu/fire.fsh index c524c0498..87ea9aa98 100644 --- a/src/main/resources/assets/shaders/menu/fire.fsh +++ b/src/main/resources/assets/shaders/menu/fire.fsh @@ -29,7 +29,7 @@ const vec3 c6 = vec3(0.9); // Original here: https://www.shadertoy.com/view/XsXXRN float rand(vec2 n) { - return fract(sin(cos(dot(n, vec2(12.9898,12.1414)))) * 83758.5453); + return fract(sin(cos(dot(n, vec2(12.9898, 12.1414)))) * 83758.5453); } float noise(vec2 n) { @@ -48,7 +48,7 @@ float fbm(vec2 n) { return total; } -void mainImage( out vec4 fragColor, in vec2 fragCoord ) { +void mainImage(out vec4 fragColor, in vec2 fragCoord) { vec2 speed = vec2(0.1, 0.9); float shift = 1.327+sin(iTime*2.0)/2.4; @@ -58,8 +58,8 @@ void mainImage( out vec4 fragColor, in vec2 fragCoord ) { vec2 uv = fragCoord.xy / iResolution.xy; vec2 p = fragCoord.xy * dist / iResolution.xx; - p += sin(p.yx*4.0+vec2(.2,-.3)*iTime)*0.04; - p += sin(p.yx*8.0+vec2(.6,+.1)*iTime)*0.01; + p += sin(p.yx*4.0+vec2(.2, -.3)*iTime)*0.04; + p += sin(p.yx*8.0+vec2(.6, +.1)*iTime)*0.01; p.x -= iTime/1.1; float q = fbm(p - iTime * 0.3+1.0*sin(iTime+0.5)/2.0); @@ -70,12 +70,12 @@ void mainImage( out vec4 fragColor, in vec2 fragCoord ) { q = (q + qb - .4 * q2 -2.0*q3 + .6*q4)/3.8; vec2 r = vec2(fbm(p + q /2.0 + iTime * speed.x - p.x - p.y), fbm(p + q - iTime * speed.y)); vec3 c = mix(c1, c2, fbm(p + r)) + mix(c3, c4, r.x) - mix(c5, c6, r.y); - vec3 color = vec3(1.0/(pow(c+1.61,vec3(4.0))) * cos(shift * fragCoord.y / iResolution.y)); + vec3 color = vec3(1.0/(pow(c+1.61, vec3(4.0))) * cos(shift * fragCoord.y / iResolution.y)); - color=vec3(1.0,.2,.05)/(pow((r.y+r.y)* max(.0,p.y)+0.1, 4.0));; - color += (texture(iChannel0,uv*0.6+vec2(.5,.1)).xyz*0.01*pow((r.y+r.y)*.65,5.0)+0.055)*mix( vec3(.9,.4,.3),vec3(.7,.5,.2), uv.y); - color = color/(1.0+max(vec3(0),color)); - fragColor = vec4(color.x, color.y, color.z, alpha); + color=vec3(1.0, .2, .05)/(pow((r.y+r.y)* max(.0, p.y)+0.1, 4.0));; + color += (texture(iChannel0, uv*0.6+vec2(.5, .1)).xyz*0.01*pow((r.y+r.y)*.65, 5.0)+0.055)*mix(vec3(.9, .4, .3), vec3(.7, .5, .2), uv.y); +color = color/(1.0+max(vec3(0), color)); +fragColor = vec4(color.x, color.y, color.z, alpha); } // --------[ Original ShaderToy ends here ]---------- // diff --git a/src/main/resources/assets/shaders/menu/jupiter.fsh b/src/main/resources/assets/shaders/menu/jupiter.fsh index 629364353..5f5b2cb67 100644 --- a/src/main/resources/assets/shaders/menu/jupiter.fsh +++ b/src/main/resources/assets/shaders/menu/jupiter.fsh @@ -12,14 +12,14 @@ const float Pi = 3.14159; void main() { - vec2 p=(2.0*gl_FragCoord.xy-resolution)/max(resolution.x,resolution.y); - for(int i=1;i<64;i++) - { - vec2 newp=p; - newp.x+=1./float(i)*sin(float(i)*.5*p.y+time*.1)+1.; - newp.y+=1./float(i)*cos(float(i)*.5*p.x+time*.1)-1.; - p=newp; - } - vec3 col=vec3(sin(p.x+p.y)*.5+.5,sin(p.x+p.y+6.)*.5+.5,sin(p.x+p.y+12.)*.5+.5); - gl_FragColor=vec4(col, 1.0); + vec2 p=(2.0*gl_FragCoord.xy-resolution)/max(resolution.x, resolution.y); + for (int i=1;i<64;i++) + { + vec2 newp=p; + newp.x+=1./float(i)*sin(float(i)*.5*p.y+time*.1)+1.; + newp.y+=1./float(i)*cos(float(i)*.5*p.x+time*.1)-1.; + p=newp; + } + vec3 col=vec3(sin(p.x+p.y)*.5+.5, sin(p.x+p.y+6.)*.5+.5, sin(p.x+p.y+12.)*.5+.5); + gl_FragColor=vec4(col, 1.0); } diff --git a/src/main/resources/assets/shaders/menu/matrix.fsh b/src/main/resources/assets/shaders/menu/matrix.fsh index a1bdaa7f6..83135d190 100644 --- a/src/main/resources/assets/shaders/menu/matrix.fsh +++ b/src/main/resources/assets/shaders/menu/matrix.fsh @@ -8,241 +8,241 @@ uniform float time; uniform vec2 resolution; vec2 rotate(vec2 p, float a) - { - return vec2(p.x * cos(a) - p.y * sin(a), p.x * sin(a) + p.y * cos(a)); - } +{ + return vec2(p.x * cos(a) - p.y * sin(a), p.x * sin(a) + p.y * cos(a)); +} float box(vec2 p, vec2 b, float r) - { - return length(max(abs(p) - b, 0.0)) - r; - } +{ + return length(max(abs(p) - b, 0.0)) - r; +} vec3 intersect(in vec3 o, in vec3 d, vec3 c, vec3 u, vec3 v) - { - vec3 q = o - c; - return vec3( - dot(cross(u, v), q), - dot(cross(q, u), d), - dot(cross(v, q), d)) / dot(cross(v, u), d); - } +{ + vec3 q = o - c; + return vec3( + dot(cross(u, v), q), + dot(cross(q, u), d), + dot(cross(v, q), d)) / dot(cross(v, u), d); +} float rand11(float p) - { - return fract(sin(p * 591.32) * 43758.5357); - } +{ + return fract(sin(p * 591.32) * 43758.5357); +} float rand12(vec2 p) - { - return fract(sin(dot(p.xy, vec2(12.9898, 78.233))) * 43758.5357); - } +{ + return fract(sin(dot(p.xy, vec2(12.9898, 78.233))) * 43758.5357); +} vec2 rand21(float p) - { - return fract(vec2(sin(p * 591.32), cos(p * 391.32))); - } +{ + return fract(vec2(sin(p * 591.32), cos(p * 391.32))); +} vec2 rand22(in vec2 p) - { - return fract(vec2(sin(p.x * 591.32 + p.y * 154.077), cos(p.x * 391.32 + p.y * 49.077))); - } +{ + return fract(vec2(sin(p.x * 591.32 + p.y * 154.077), cos(p.x * 391.32 + p.y * 49.077))); +} float noise11(float p) - { - float fl = floor(p); - return mix(rand11(fl), rand11(fl + 1.0), fract(p));//smoothstep(0.0, 1.0, fract(p))); - } +{ + float fl = floor(p); + return mix(rand11(fl), rand11(fl + 1.0), fract(p));//smoothstep(0.0, 1.0, fract(p))); +} float fbm11(float p) - { - return noise11(p) * 0.5 + noise11(p * 2.0) * 0.25 + noise11(p * 5.0) * 0.125; - } +{ + return noise11(p) * 0.5 + noise11(p * 2.0) * 0.25 + noise11(p * 5.0) * 0.125; +} vec3 noise31(float p) - { - return vec3(noise11(p), noise11(p + 18.952), noise11(p - 11.372)) * 2.0 - 1.0; - } +{ + return vec3(noise11(p), noise11(p + 18.952), noise11(p - 11.372)) * 2.0 - 1.0; +} float sky(vec3 p) - { - float a = atan(p.x, p.z); - float t = time * 0.1; - float v = rand11(floor(a * 4.0 + t)) * 0.5 + rand11(floor(a * 8.0 - t)) * 0.25 + rand11(floor(a * 16.0 + t)) * 0.125; - return v; - } +{ + float a = atan(p.x, p.z); + float t = time * 0.1; + float v = rand11(floor(a * 4.0 + t)) * 0.5 + rand11(floor(a * 8.0 - t)) * 0.25 + rand11(floor(a * 16.0 + t)) * 0.125; + return v; +} vec3 voronoi(in vec2 x) - { - vec2 n = floor(x); // grid cell id - vec2 f = fract(x); // grid internal position - vec2 mg; // shortest distance... - vec2 mr; // ..and second shortest distance - float md = 8.0, md2 = 8.0; - for(int j = -1; j <= 1; j ++) - { - for(int i = -1; i <= 1; i ++) - { - vec2 g = vec2(float(i), float(j)); // cell id - vec2 o = rand22(n + g); // offset to edge point - vec2 r = g + o - f; - - float d = max(abs(r.x), abs(r.y)); // distance to the edge - - if(d < md) - { - md2 = md; md = d; mr = r; mg = g; - } - else if(d < md2) - { - md2 = d; - } - } - } - return vec3(n + mg, md2 - md); - } - -#define A2V(a) vec2(sin((a) * 6.28318531 / 100.0), cos((a) * 6.28318531 / 100.0)) +{ + vec2 n = floor(x);// grid cell id + vec2 f = fract(x);// grid internal position + vec2 mg;// shortest distance... + vec2 mr;// ..and second shortest distance + float md = 8.0, md2 = 8.0; + for (int j = -1; j <= 1; j ++) + { + for (int i = -1; i <= 1; i ++) + { + vec2 g = vec2(float(i), float(j));// cell id + vec2 o = rand22(n + g);// offset to edge point + vec2 r = g + o - f; + + float d = max(abs(r.x), abs(r.y));// distance to the edge + + if (d < md) + { + md2 = md; md = d; mr = r; mg = g; + } + else if (d < md2) + { + md2 = d; + } + } + } + return vec3(n + mg, md2 - md); +} + + #define A2V(a) vec2(sin((a) * 6.28318531 / 100.0), cos((a) * 6.28318531 / 100.0)) float circles(vec2 p) - { - float v, w, l, c; - vec2 pp; - l = length(p); +{ + float v, w, l, c; + vec2 pp; + l = length(p); - pp = rotate(p, time * 3.0); - c = max(dot(pp, normalize(vec2(-0.2, 0.5))), -dot(pp, normalize(vec2(0.2, 0.5)))); - c = min(c, max(dot(pp, normalize(vec2(0.5, -0.5))), -dot(pp, normalize(vec2(0.2, -0.5))))); - c = min(c, max(dot(pp, normalize(vec2(0.3, 0.5))), -dot(pp, normalize(vec2(0.2, 0.5))))); + pp = rotate(p, time * 3.0); + c = max(dot(pp, normalize(vec2(-0.2, 0.5))), -dot(pp, normalize(vec2(0.2, 0.5)))); + c = min(c, max(dot(pp, normalize(vec2(0.5, -0.5))), -dot(pp, normalize(vec2(0.2, -0.5))))); + c = min(c, max(dot(pp, normalize(vec2(0.3, 0.5))), -dot(pp, normalize(vec2(0.2, 0.5))))); - // innerest stuff - v = abs(l - 0.5) - 0.03; - v = max(v, -c); - v = min(v, abs(l - 0.54) - 0.02); - v = min(v, abs(l - 0.64) - 0.05); + // innerest stuff + v = abs(l - 0.5) - 0.03; + v = max(v, -c); + v = min(v, abs(l - 0.54) - 0.02); + v = min(v, abs(l - 0.64) - 0.05); - pp = rotate(p, time * -1.333); - c = max(dot(pp, A2V(-5.0)), -dot(pp, A2V(5.0))); - c = min(c, max(dot(pp, A2V(25.0 - 5.0)), -dot(pp, A2V(25.0 + 5.0)))); - c = min(c, max(dot(pp, A2V(50.0 - 5.0)), -dot(pp, A2V(50.0 + 5.0)))); - c = min(c, max(dot(pp, A2V(75.0 - 5.0)), -dot(pp, A2V(75.0 + 5.0)))); + pp = rotate(p, time * -1.333); + c = max(dot(pp, A2V(-5.0)), -dot(pp, A2V(5.0))); +c = min(c, max(dot(pp, A2V(25.0 - 5.0)), -dot(pp, A2V(25.0 + 5.0)))); +c = min(c, max(dot(pp, A2V(50.0 - 5.0)), -dot(pp, A2V(50.0 + 5.0)))); +c = min(c, max(dot(pp, A2V(75.0 - 5.0)), -dot(pp, A2V(75.0 + 5.0)))); - w = abs(l - 0.83) - 0.09; - v = min(v, max(w, c)); +w = abs(l - 0.83) - 0.09; +v = min(v, max(w, c)); - return v; - } +return v; +} float shade1(float d) - { - float v = 1.0 - smoothstep(0.0, mix(0.012, 0.2, 0.0), d); - float g = exp(d * -20.0); - return v + g * 0.5; - } +{ + float v = 1.0 - smoothstep(0.0, mix(0.012, 0.2, 0.0), d); + float g = exp(d * -20.0); + return v + g * 0.5; +} void main() - { - vec2 uv = gl_FragCoord.xy / resolution.xy; - uv = uv * 2.0 - 1.0; - uv.x *= resolution.x / resolution.y; - - - // using an iq styled camera this time :) - // ray origin - vec3 ro = 0.7 * vec3(cos(0.2), 0.0, sin(0.2)); - ro.y = cos(0.6) * 0.3 + 0.65; - // camera look at - vec3 ta = vec3(0.0, 0.2, 0.0); - - // camera shake intensity - float shake = 0.0;//clamp(3.0 * (1.0 - length(ro.yz)), 0.3, 1.0); - float st = 0.0;//mod(time, 10.0) * 143.0; - - // build camera matrix - vec3 ww = normalize(ta - ro + noise31(st) * shake * 0.01); - vec3 uu = normalize(cross(ww, normalize(vec3(0.0, 1.0, 0.2)))); - vec3 vv = normalize(cross(uu, ww)); - // obtain ray direction - vec3 rd = normalize(uv.x * uu + uv.y * vv + 1.0 * ww); - - // shaking and movement - ro += noise31(-st) * shake * 0.015; - ro.x += time * -10.0; - - float inten = 0.0; - - // background - float sd = dot(rd, vec3(0.0, 1.0, 0.0)); - //inten = pow(1.0 - abs(sd), 20.0) + pow(sky(rd), 5.0) * step(0.0, rd.y) * 0.2; - - vec3 its; - float v, g; - - // voronoi floor layers - for(int i = 0; i < 4; i ++) - { - float layer = float(i); - its = intersect(ro, rd, vec3(0.0, -5.0 - layer * 5.0, 0.0), vec3(1.0, 0.0, 0.0), vec3(0.0, 0.0, 1.0)); - if(its.x > 0.0) - { - vec3 vo = voronoi((its.yz) * 0.05 + 8.0 * rand21(float(i))); - v = exp(-100.0 * (vo.z - 0.02)); - - float fx = 0.0; - - // add some special fx to lowest layer - if(i == 3) - { - //float crd = 0.0;//fract(time * 0.2) * 50.0 - 25.0; - float fxi = cos(vo.x * 0.2 + time * 1.5);//abs(crd - vo.x); - fx = clamp(smoothstep(0.9, 1.0, fxi), 0.0, 0.9) * 1.0 * rand12(vo.xy); - fx *= exp(-3.0 * vo.z) * 2.0; - } - inten += v * 0.1 + fx; - inten *= 64.0/its.x; - } - } - - // draw the gates, 4 should be enough - float gatex = floor(ro.x / 8.0 + 0.5) * 8.0 + 4.0; - float go = -32.0; - for(int i = 0; i < 4; i ++) - { - its = intersect(ro, rd, vec3(gatex + go, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, 0.0, 1.0)); - if(dot(its.yz, its.yz) < 2.0 && its.x > 0.0) - { - v = circles(its.yz); - //inten += shade1(v); - } - - go += 8.0; - } - - // draw the stream - for(int j = 0; j < 20; j ++) - { - float id = float(j); - - vec3 bp = vec3(0.0, (rand11(id) * 2.0 - 1.0) * 0.25, 0.0); - vec3 its = intersect(ro, rd, bp, vec3(1.0, 0.0, 0.0), vec3(0.0, 0.0, 1.0)); - - if(its.x > 0.0) - { - vec2 pp = its.yz; - float spd = (1.0 + rand11(id) * 3.0) * -2.5; - pp.y += time * spd; - pp += (rand21(id) * 2.0 - 1.0) * vec2(0.3, 1.0); - float rep = rand11(id) + 1.5; - pp.y = mod(pp.y, rep * 2.0) - rep; - float d = box(pp, vec2(0.02, 0.3), 0.1); - float foc = 0.0; - float v = 1.0 - smoothstep(0.0, 0.03, abs(d) - 0.001); - float g = min(exp(d * -20.0), 2.0); - - inten += (v + g * 0.7) * 0.5; - - } - } - - //inten *= 0.4 * 0.6;// (sin(time) * 0.5 + 0.5) * 0.6; - //inten *= mod(gl_FragCoord.y, 2.0); - - vec3 col = pow(vec3(inten), vec3(8.0, 0.75, 8.25)); - - gl_FragColor = vec4(col, 1.0); - } \ No newline at end of file +{ + vec2 uv = gl_FragCoord.xy / resolution.xy; + uv = uv * 2.0 - 1.0; + uv.x *= resolution.x / resolution.y; + + + // using an iq styled camera this time :) + // ray origin + vec3 ro = 0.7 * vec3(cos(0.2), 0.0, sin(0.2)); + ro.y = cos(0.6) * 0.3 + 0.65; + // camera look at + vec3 ta = vec3(0.0, 0.2, 0.0); + + // camera shake intensity + float shake = 0.0;//clamp(3.0 * (1.0 - length(ro.yz)), 0.3, 1.0); + float st = 0.0;//mod(time, 10.0) * 143.0; + + // build camera matrix + vec3 ww = normalize(ta - ro + noise31(st) * shake * 0.01); + vec3 uu = normalize(cross(ww, normalize(vec3(0.0, 1.0, 0.2)))); + vec3 vv = normalize(cross(uu, ww)); + // obtain ray direction + vec3 rd = normalize(uv.x * uu + uv.y * vv + 1.0 * ww); + + // shaking and movement + ro += noise31(-st) * shake * 0.015; + ro.x += time * -10.0; + + float inten = 0.0; + + // background + float sd = dot(rd, vec3(0.0, 1.0, 0.0)); + //inten = pow(1.0 - abs(sd), 20.0) + pow(sky(rd), 5.0) * step(0.0, rd.y) * 0.2; + + vec3 its; + float v, g; + + // voronoi floor layers + for (int i = 0; i < 4; i ++) + { + float layer = float(i); + its = intersect(ro, rd, vec3(0.0, -5.0 - layer * 5.0, 0.0), vec3(1.0, 0.0, 0.0), vec3(0.0, 0.0, 1.0)); + if (its.x > 0.0) + { + vec3 vo = voronoi((its.yz) * 0.05 + 8.0 * rand21(float(i))); + v = exp(-100.0 * (vo.z - 0.02)); + + float fx = 0.0; + + // add some special fx to lowest layer + if (i == 3) + { + //float crd = 0.0;//fract(time * 0.2) * 50.0 - 25.0; + float fxi = cos(vo.x * 0.2 + time * 1.5);//abs(crd - vo.x); + fx = clamp(smoothstep(0.9, 1.0, fxi), 0.0, 0.9) * 1.0 * rand12(vo.xy); + fx *= exp(-3.0 * vo.z) * 2.0; + } + inten += v * 0.1 + fx; + inten *= 64.0/its.x; + } + } + + // draw the gates, 4 should be enough + float gatex = floor(ro.x / 8.0 + 0.5) * 8.0 + 4.0; + float go = -32.0; + for (int i = 0; i < 4; i ++) + { + its = intersect(ro, rd, vec3(gatex + go, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, 0.0, 1.0)); + if (dot(its.yz, its.yz) < 2.0 && its.x > 0.0) + { + v = circles(its.yz); + //inten += shade1(v); + } + + go += 8.0; + } + + // draw the stream + for (int j = 0; j < 20; j ++) + { + float id = float(j); + + vec3 bp = vec3(0.0, (rand11(id) * 2.0 - 1.0) * 0.25, 0.0); + vec3 its = intersect(ro, rd, bp, vec3(1.0, 0.0, 0.0), vec3(0.0, 0.0, 1.0)); + + if (its.x > 0.0) + { + vec2 pp = its.yz; + float spd = (1.0 + rand11(id) * 3.0) * -2.5; + pp.y += time * spd; + pp += (rand21(id) * 2.0 - 1.0) * vec2(0.3, 1.0); + float rep = rand11(id) + 1.5; + pp.y = mod(pp.y, rep * 2.0) - rep; + float d = box(pp, vec2(0.02, 0.3), 0.1); + float foc = 0.0; + float v = 1.0 - smoothstep(0.0, 0.03, abs(d) - 0.001); + float g = min(exp(d * -20.0), 2.0); + + inten += (v + g * 0.7) * 0.5; + + } + } + + //inten *= 0.4 * 0.6;// (sin(time) * 0.5 + 0.5) * 0.6; + //inten *= mod(gl_FragCoord.y, 2.0); + + vec3 col = pow(vec3(inten), vec3(8.0, 0.75, 8.25)); + + gl_FragColor = vec4(col, 1.0); +} \ No newline at end of file diff --git a/src/main/resources/assets/shaders/menu/minecraft.fsh b/src/main/resources/assets/shaders/menu/minecraft.fsh index 3d61c8651..0932a596c 100644 --- a/src/main/resources/assets/shaders/menu/minecraft.fsh +++ b/src/main/resources/assets/shaders/menu/minecraft.fsh @@ -1,7 +1,6 @@ - // Necip's transf. https://www.shadertoy.com/view/MdlGz4 -#define iTime time +#define iTime time #define iResolution resolution @@ -16,8 +15,6 @@ uniform vec2 mouse; uniform vec2 resolution; - - // Minecraft Blocks. Created by Reinder Nijhoff 2013 // Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. // @reindernijhoff @@ -27,181 +24,181 @@ uniform vec2 resolution; // port of javascript minecraft: http://jsfiddle.net/uzMPU/ // original code by Markus Persson: https://twitter.com/notch/status/275331530040160256 -float hash( float n ) { +float hash(float n) { return fract(sin(n)*43758.5453); } // port of minecraft -bool getMaterialColor( int i, vec2 coord, out vec3 color ) { - // 16x16 tex - vec2 uv = floor( coord ); +bool getMaterialColor(int i, vec2 coord, out vec3 color) { + // 16x16 tex + vec2 uv = floor(coord); float n = uv.x + uv.y*347.0 + 4321.0 * float(i); - float h = hash(n); + float h = hash(n); float br = 1. - h * (96./255. - ); - color = vec3( 150./255., 108./255., 74./255.); // 0x966C4A; - - if (i == 4) { - color = vec3( 127./255., 127./255., 127./255.); // 0x7F7F7F; - } - - float xm1 = mod((uv.x * uv.x * 3. + uv.x * 81.) / 4., 4.); - - if (i == 1) { - if( uv.y < (xm1 + 18.)) { - color = vec3( 106./255., 170./255., 64./255.); // 0x6AAA40; - } else if (uv.y < (xm1 + 19.)) { - br = br * (2. / 3.); - } - } - - if (i == 7) { - color = vec3( 103./255., 82./255., 49./255.); // 0x675231; - if (uv.x > 0. && uv.x < 15. - && ((uv.y > 0. && uv.y < 15.) || (uv.y > 32. && uv.y < 47.))) { - color = vec3( 188./255., 152./255., 98./255.); // 0xBC9862; - float xd = (uv.x - 7.); - float yd = (mod(uv.y, 16.) - 7.); - if (xd < 0.) - xd = 1. - xd; - if (yd < 0.) - yd = 1. - yd; - if (yd > xd) - xd = yd; - - br = 1. - (h * (32./255.) + mod(xd, 4.) * (32./255.)); - } else if ( h < 0.5 ) { - br = br * (1.5 - mod(uv.x, 2.)); - } - } - - if (i == 5) { - color = vec3( 181./255., 58./255., 21./255.); // 0xB53A15; - if ( mod(uv.x + (floor(uv.y / 4.) * 5.), 8.) == 0. || mod( uv.y, 4.) == 0.) { - color = vec3( 188./255., 175./255., 165./255.); // 0xBCAFA5; - } - } - if (i == 9) { - color = vec3( 64./255., 64./255., 255./255.); // 0x4040ff; - } - - float brr = br; - if (uv.y >= 32.) - brr /= 2.; - - if (i == 8) { - color = vec3( 80./255., 217./255., 55./255.); // 0x50D937; - if ( h < 0.5) { - return false; - } - } - - color *= brr; - - return true; + ); + color = vec3(150./255., 108./255., 74./255.);// 0x966C4A; + + if (i == 4) { + color = vec3(127./255., 127./255., 127./255.);// 0x7F7F7F; + } + + float xm1 = mod((uv.x * uv.x * 3. + uv.x * 81.) / 4., 4.); + + if (i == 1) { + if (uv.y < (xm1 + 18.)) { + color = vec3(106./255., 170./255., 64./255.);// 0x6AAA40; + } else if (uv.y < (xm1 + 19.)) { + br = br * (2. / 3.); + } + } + + if (i == 7) { + color = vec3(103./255., 82./255., 49./255.);// 0x675231; + if (uv.x > 0. && uv.x < 15. + && ((uv.y > 0. && uv.y < 15.) || (uv.y > 32. && uv.y < 47.))) { + color = vec3(188./255., 152./255., 98./255.);// 0xBC9862; + float xd = (uv.x - 7.); + float yd = (mod(uv.y, 16.) - 7.); + if (xd < 0.) + xd = 1. - xd; + if (yd < 0.) + yd = 1. - yd; + if (yd > xd) + xd = yd; + + br = 1. - (h * (32./255.) + mod(xd, 4.) * (32./255.)); + } else if (h < 0.5) { + br = br * (1.5 - mod(uv.x, 2.)); + } + } + + if (i == 5) { + color = vec3(181./255., 58./255., 21./255.);// 0xB53A15; + if (mod(uv.x + (floor(uv.y / 4.) * 5.), 8.) == 0. || mod(uv.y, 4.) == 0.) { + color = vec3(188./255., 175./255., 165./255.);// 0xBCAFA5; + } + } + if (i == 9) { + color = vec3(64./255., 64./255., 255./255.);// 0x4040ff; + } + + float brr = br; + if (uv.y >= 32.) + brr /= 2.; + + if (i == 8) { + color = vec3(80./255., 217./255., 55./255.);// 0x50D937; + if (h < 0.5) { + return false; + } + } + + color *= brr; + + return true; } -int getMap( vec3 pos ) { - vec3 posf = floor( (pos - vec3(32.)) ); +int getMap(vec3 pos) { + vec3 posf = floor((pos - vec3(32.))); - float n = posf.x + posf.y*517.0 + 1313.0*posf.z; + float n = posf.x + posf.y*517.0 + 1313.0*posf.z; float h = hash(n); - if( h > sqrt( sqrt( dot( posf.yz, posf.yz )*0.16 ) ) - 0.8 ) { + if (h > sqrt(sqrt(dot(posf.yz, posf.yz)*0.16)) - 0.8) { return 0; - } + } - return int( hash( n * 465.233 ) * 16. ); + return int(hash(n * 465.233) * 16.); } -vec3 renderMinecraft( vec2 uv ) { - float xRot = sin( iTime*0.5 ) * 0.4 + (3.1415 / 2.); - float yRot = cos( iTime*0.5 ) * 0.4; +vec3 renderMinecraft(vec2 uv) { + float xRot = sin(iTime*0.5) * 0.4 + (3.1415 / 2.); + float yRot = cos(iTime*0.5) * 0.4; float yCos = cos(yRot); float ySin = sin(yRot); float xCos = cos(xRot); float xSin = sin(xRot); - vec3 opos = vec3( 32.5 + iTime * 6.4, 32.5, 32.5 ); + vec3 opos = vec3(32.5 + iTime * 6.4, 32.5, 32.5); - float gggxd = (uv.x - 0.5) * (iResolution.x / iResolution.y ); - float ggyd = (1.-uv.y - 0.5); - float ggzd = 1.; + float gggxd = (uv.x - 0.5) * (iResolution.x / iResolution.y); + float ggyd = (1.-uv.y - 0.5); + float ggzd = 1.; - float gggzd = ggzd * yCos + ggyd * ySin; + float gggzd = ggzd * yCos + ggyd * ySin; - vec3 _posd = vec3( gggxd * xCos + gggzd * xSin, - ggyd * yCos - ggzd * ySin, - gggzd * xCos - gggxd * xSin ); + vec3 _posd = vec3(gggxd * xCos + gggzd * xSin, + ggyd * yCos - ggzd * ySin, + gggzd * xCos - gggxd * xSin); - vec3 col = vec3( 0. ); - float br = 1.; - vec3 bdist = vec3( 255. - 100., 255. - 0., 255. - 50. ); - float ddist = 0.; + vec3 col = vec3(0.); + float br = 1.; + vec3 bdist = vec3(255. - 100., 255. - 0., 255. - 50.); + float ddist = 0.; - float closest = 32.; + float closest = 32.; - for ( int d = 0; d < 3; d++) { - float dimLength = _posd[d]; + for (int d = 0; d < 3; d++) { + float dimLength = _posd[d]; - float ll = abs( 1. / dimLength ); - vec3 posd = _posd * ll;; + float ll = abs(1. / dimLength); + vec3 posd = _posd * ll;; - float initial = fract( opos[d] ); - if (dimLength > 0.) initial = 1. - initial; + float initial = fract(opos[d]); + if (dimLength > 0.) initial = 1. - initial; - float dist = ll * initial; + float dist = ll * initial; - vec3 pos = opos + posd * initial; + vec3 pos = opos + posd * initial; - if (dimLength < 0.) { - pos[d] -= 1.; - } + if (dimLength < 0.) { + pos[d] -= 1.; + } - for (int i=0; i<30; i++) { - if( dist > closest )continue; + for (int i=0; i<30; i++) { + if (dist > closest)continue; - //int tex = getMap( mod( pos, 64. ) ); - int tex = getMap( pos ); + //int tex = getMap( mod( pos, 64. ) ); + int tex = getMap(pos); - if (tex > 0) { - vec2 texcoord; - texcoord.x = mod(((pos.x + pos.z) * 16.), 16.); - texcoord.y = mod((pos.y * 16.), 16.) + 16.; - if (d == 1) { - texcoord.x = mod(pos.x * 16., 16.); - texcoord.y = mod(pos.z * 16., 16.); - if (posd.y < 0.) - texcoord.y += 32.; - } + if (tex > 0) { + vec2 texcoord; + texcoord.x = mod(((pos.x + pos.z) * 16.), 16.); + texcoord.y = mod((pos.y * 16.), 16.) + 16.; + if (d == 1) { + texcoord.x = mod(pos.x * 16., 16.); + texcoord.y = mod(pos.z * 16., 16.); + if (posd.y < 0.) + texcoord.y += 32.; + } - if ( getMaterialColor( tex, texcoord, col ) ) { - ddist = 1. - (dist / 32.); - br = bdist[d]; - closest = dist; - } - } - pos += posd; - dist += ll; - } - } + if (getMaterialColor(tex, texcoord, col)) { + ddist = 1. - (dist / 32.); + br = bdist[d]; + closest = dist; + } + } + pos += posd; + dist += ll; + } + } - return col * ddist * (br/255.); + return col * ddist * (br/255.); } -void mainImage( out vec4 fragColor, in vec2 fragCoord ) +void mainImage(out vec4 fragColor, in vec2 fragCoord) { - vec2 uv = fragCoord.xy / iResolution.xy; + vec2 uv = fragCoord.xy / iResolution.xy; - fragColor = vec4( renderMinecraft( uv ) ,1.0); + fragColor = vec4(renderMinecraft(uv), 1.0); } -void main( void ) { +void main(void) { - mainImage( gl_FragColor, gl_FragCoord.xy ); + mainImage(gl_FragColor, gl_FragCoord.xy); } diff --git a/src/main/resources/assets/shaders/menu/purplegrid.fsh b/src/main/resources/assets/shaders/menu/purplegrid.fsh index 66c769233..69d25e5b4 100644 --- a/src/main/resources/assets/shaders/menu/purplegrid.fsh +++ b/src/main/resources/assets/shaders/menu/purplegrid.fsh @@ -16,79 +16,79 @@ uniform vec2 mouse; uniform vec2 resolution; void glow(float d) { - float br = 0.005 * resolution.y; - gl_FragColor.rgb += vec3(0.3, 0.15, 0.45) * br / d; + float br = 0.005 * resolution.y; + gl_FragColor.rgb += vec3(0.3, 0.15, 0.45) * br / d; } -void line( vec2 a, vec2 l ) { - l.x *= resolution.y/resolution.x; - l += 0.5; - l *= resolution; - - vec2 P = gl_FragCoord.xy; - - float angle = length(mouse)/10.0; - mat2 rot = mat2(cos(angle), -sin(angle), - sin(angle), cos(angle)); - P = rot * P; - - a.x *= resolution.y/resolution.x; - a += 0.5; - a *= resolution; - - vec2 aP = P-a; - vec2 al = l-a; - vec3 al3 = vec3(al, 0.0); - vec3 aP3 = vec3(aP, 0.0); - //float q = length(dot(aP,al))/length(al); - float q = length(cross(aP3,al3))/length(al3); - - float d = q; - if ( dot(al, aP) <= 0.0 ) { // before start - d = distance(P, a); - } - else if ( dot(al, al) <= dot(al, aP) ) { // after end - d = distance(P, l); - } - glow(d); +void line(vec2 a, vec2 l) { + l.x *= resolution.y/resolution.x; + l += 0.5; + l *= resolution; + + vec2 P = gl_FragCoord.xy; + + float angle = length(mouse)/10.0; + mat2 rot = mat2(cos(angle), -sin(angle), + sin(angle), cos(angle)); + P = rot * P; + + a.x *= resolution.y/resolution.x; + a += 0.5; + a *= resolution; + + vec2 aP = P-a; + vec2 al = l-a; + vec3 al3 = vec3(al, 0.0); + vec3 aP3 = vec3(aP, 0.0); + //float q = length(dot(aP,al))/length(al); + float q = length(cross(aP3, al3))/length(al3); + + float d = q; + if (dot(al, aP) <= 0.0) { // before start + d = distance(P, a); + } + else if (dot(al, al) <= dot(al, aP)) { // after end + d = distance(P, l); + } + glow(d); } void point(vec2 a) { - a.x *= resolution.y/resolution.x; - a += 0.5; - a *= resolution; + a.x *= resolution.y/resolution.x; + a += 0.5; + a *= resolution; - vec2 P = gl_FragCoord.xy; - float d = distance(P, a); - glow(d); + vec2 P = gl_FragCoord.xy; + float d = distance(P, a); + glow(d); } float rand(int seed) { - return fract(sin(float(seed)*15.234234) + sin(float(seed)*4.3456342) * 372.4532); + return fract(sin(float(seed)*15.234234) + sin(float(seed)*4.3456342) * 372.4532); } -void main( void ) { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - - // Horizontal grid lines - float y = 0.0; - for (int l=1; l<13; l++) { - y = -1.0/(0.6 * sin(time * 0.73) + float(l)*1.2) + 0.25; - line(vec2(-2.0, y), vec2(2.0, y)); - } - - // Perpendicular grid lines - for (int l=-30; l<31; l++) { - float x = float(l) + fract(time * 3.25); - line(vec2(x * 0.025, y), vec2(x, -1.0)); - } - - // Starfield - /* - for (int l=1; l<70; l++) { - float sx = (fract(rand(l+342) + time * (0.002 + 0.01*rand(l)))-0.5) * 3.0; - float sy = y + 0.4 * rand(l+8324); - point(vec2(sx,sy)); - } - */ +void main(void) { + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + + // Horizontal grid lines + float y = 0.0; + for (int l=1; l<13; l++) { + y = -1.0/(0.6 * sin(time * 0.73) + float(l)*1.2) + 0.25; + line(vec2(-2.0, y), vec2(2.0, y)); + } + + // Perpendicular grid lines + for (int l=-30; l<31; l++) { + float x = float(l) + fract(time * 3.25); + line(vec2(x * 0.025, y), vec2(x, -1.0)); + } + + // Starfield + /* + for (int l=1; l<70; l++) { + float sx = (fract(rand(l+342) + time * (0.002 + 0.01*rand(l)))-0.5) * 3.0; + float sy = y + 0.4 * rand(l+8324); + point(vec2(sx,sy)); + } + */ } \ No newline at end of file diff --git a/src/main/resources/assets/shaders/menu/purplemist.fsh b/src/main/resources/assets/shaders/menu/purplemist.fsh index 23eb4dca4..267b4b734 100644 --- a/src/main/resources/assets/shaders/menu/purplemist.fsh +++ b/src/main/resources/assets/shaders/menu/purplemist.fsh @@ -12,26 +12,26 @@ uniform float shift; float rand(vec2 n) { - //This is just a compounded expression to simulate a random number based on a seed given as n - return fract(cos(dot(n, vec2(12.9898, 4.1414))) * 43758.5453); + //This is just a compounded expression to simulate a random number based on a seed given as n + return fract(cos(dot(n, vec2(12.9898, 4.1414))) * 43758.5453); } float noise(vec2 n) { - //Uses the rand function to generate noise - const vec2 d = vec2(0.0, 1.0); - vec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n)); - return mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y); + //Uses the rand function to generate noise + const vec2 d = vec2(0.0, 1.0); + vec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n)); + return mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y); } float fbm(vec2 n) { - //fbm stands for "Fractal Brownian Motion" https://en.wikipedia.org/wiki/Fractional_Brownian_motion - float total = 0.0, amplitude = 1.0; - for (int i = 0; i < 4; i++) { - total += noise(n) * amplitude; - n += n; - amplitude *= 0.5; - } - return total; + //fbm stands for "Fractal Brownian Motion" https://en.wikipedia.org/wiki/Fractional_Brownian_motion + float total = 0.0, amplitude = 1.0; + for (int i = 0; i < 4; i++) { + total += noise(n) * amplitude; + n += n; + amplitude *= 0.5; + } + return total; } void main() { diff --git a/src/main/resources/assets/shaders/menu/redglow.fsh b/src/main/resources/assets/shaders/menu/redglow.fsh index e605003a9..ea46d3ce1 100644 --- a/src/main/resources/assets/shaders/menu/redglow.fsh +++ b/src/main/resources/assets/shaders/menu/redglow.fsh @@ -10,27 +10,27 @@ const float COUNT = 10.0; //MythicalFire by CuriousChettai@gmail.com -void main( void ) { - vec2 uPos = ( gl_FragCoord.xy / resolution.y );//normalize wrt y axis - uPos -= vec2((resolution.x/resolution.y)/2.0, 0.5);//shift origin to center - - float y = uPos.y; - - float vertColor = 0.0; - for(float i=0.0; ia.y) ? vec2(1.0,0.0) : vec2(0.0,1.0); //vec2 of = 0.5 + 0.5*vec2(sign(a.x-a.y), sign(a.y-a.x)); + vec2 o = (a.x>a.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);//vec2 of = 0.5 + 0.5*vec2(sign(a.x-a.y), sign(a.y-a.x)); vec2 b = a - o + K2; vec2 c = a - 1.0 + 2.0*K2; - vec3 h = max(0.5-vec3(dot(a,a), dot(b,b), dot(c,c) ), 0.0 ); - vec3 n = h*h*h*h*vec3( dot(a,hash(i+0.0)), dot(b,hash(i+o)), dot(c,hash(i+1.0))); + vec3 h = max(0.5-vec3(dot(a, a), dot(b, b), dot(c, c)), 0.0); + vec3 n = h*h*h*h*vec3(dot(a, hash(i+0.0)), dot(b, hash(i+o)), dot(c, hash(i+1.0))); return dot(n, vec3(70.0)); } float fbm(vec2 n) { - float total = 0.0, amplitude = 0.1; - for (int i = 0; i < 7; i++) { - total += noise(n) * amplitude; - n = m * n; - amplitude *= 0.4; - } - return total; + float total = 0.0, amplitude = 0.1; + for (int i = 0; i < 7; i++) { + total += noise(n) * amplitude; + n = m * n; + amplitude *= 0.4; + } + return total; } // ----------------------------------------------- @@ -61,54 +61,54 @@ void main() { float q = fbm(uv * cloudscale * 0.1); //ridged noise shape - float r = 0.0; - uv *= cloudscale; + float r = 0.0; + uv *= cloudscale; uv -= q - localTime; float weight = 0.8; for (int i=0; i<8; i++){ - r += abs(weight*noise( uv )); + r += abs(weight*noise(uv)); uv = m*uv + localTime; - weight *= 0.7; + weight *= 0.7; } //noise shape - float f = 0.0; - uv = p*vec2(resolution.x/resolution.y,1.0); - uv *= cloudscale; + float f = 0.0; + uv = p*vec2(resolution.x/resolution.y, 1.0); + uv *= cloudscale; uv -= q - localTime; weight = 0.7; for (int i=0; i<8; i++){ - f += weight*noise( uv ); + f += weight*noise(uv); uv = m*uv + localTime; - weight *= 0.6; + weight *= 0.6; } f *= r + f; //noise colour float c = 0.0; - localTime = time * speed * 2.0; - uv = p*vec2(resolution.x/resolution.y,1.0); - uv *= cloudscale*2.0; + localTime = time * speed * 2.0; + uv = p*vec2(resolution.x/resolution.y, 1.0); + uv *= cloudscale*2.0; uv -= q - localTime; weight = 0.4; for (int i=0; i<7; i++){ - c += weight*noise( uv ); + c += weight*noise(uv); uv = m*uv + localTime; - weight *= 0.6; + weight *= 0.6; } //noise ridge colour float c1 = 0.0; - localTime = time * speed * 3.0; - uv = p*vec2(resolution.x/resolution.y,1.0); - uv *= cloudscale*3.0; + localTime = time * speed * 3.0; + uv = p*vec2(resolution.x/resolution.y, 1.0); + uv *= cloudscale*3.0; uv -= q - localTime; weight = 0.4; for (int i=0; i<7; i++){ - c1 += abs(weight*noise( uv )); + c1 += abs(weight*noise(uv)); uv = m*uv + localTime; - weight *= 0.6; + weight *= 0.6; } c += c1; @@ -120,5 +120,5 @@ void main() { vec3 result = mix(skycolour, clamp(skytint * skycolour + cloudcolour, 0.0, 1.0), clamp(f + c, 0.0, 1.0)); - gl_FragColor = vec4( result, 1.0 ); + gl_FragColor = vec4(result, 1.0); } diff --git a/src/main/resources/assets/shaders/menu/snake.fsh b/src/main/resources/assets/shaders/menu/snake.fsh index 95367978f..96b3e47dc 100644 --- a/src/main/resources/assets/shaders/menu/snake.fsh +++ b/src/main/resources/assets/shaders/menu/snake.fsh @@ -22,33 +22,33 @@ float tunnel(vec3 p) float ribbon(vec3 p) { - return length(max(abs(p-vec3(cos(p.z*1.5)*.3,-.5+cos(p.z)*.2,.0))-vec3(.125,.02,iTime+3.),vec3(.0))); + return length(max(abs(p-vec3(cos(p.z*1.5)*.3, -.5+cos(p.z)*.2, .0))-vec3(.125, .02, iTime+3.), vec3(.0))); } float scene(vec3 p) { - return min(tunnel(p),ribbon(p)); + return min(tunnel(p), ribbon(p)); } vec3 getNormal(vec3 p) { - vec3 eps=vec3(.1,0,0); - return normalize(vec3(scene(p+eps.xyy),scene(p+eps.yxy),scene(p+eps.yyx))); + vec3 eps=vec3(.1, 0, 0); + return normalize(vec3(scene(p+eps.xyy), scene(p+eps.yxy), scene(p+eps.yyx))); } -void mainImage( out vec4 fragColor, in vec2 fragCoord ) +void mainImage(out vec4 fragColor, in vec2 fragCoord) { vec2 v = -1.0 + 2.0 * fragCoord.xy / iResolution.xy; v.x *= iResolution.x/iResolution.y; vec4 color = vec4(0.0); - vec3 org = vec3(sin(iTime)*.5,cos(iTime*.5)*.25+.25,iTime); - vec3 dir = normalize(vec3(v.x*1.6,v.y,1.0)); - vec3 p = org,pp; + vec3 org = vec3(sin(iTime)*.5, cos(iTime*.5)*.25+.25, iTime); + vec3 dir = normalize(vec3(v.x*1.6, v.y, 1.0)); + vec3 p = org, pp; float d = .0; //First raymarching - for(int i=0;i<64;i++) + for (int i=0;i<64;i++) { d = scene(p); p += d*dir; @@ -57,22 +57,22 @@ void mainImage( out vec4 fragColor, in vec2 fragCoord ) float f=length(p-org)*0.02; //Second raymarching (reflection) - dir=reflect(dir,getNormal(p)); + dir=reflect(dir, getNormal(p)); p+=dir; - for(int i=0;i<32;i++) + for (int i=0;i<32;i++) { d = scene(p); p += d*dir; } - color = max(dot(getNormal(p),vec3(.1,.1,.0)), .0) + vec4(.3,cos(iTime*.5)*.5+.5,sin(iTime*.5)*.5+.5,1.)*min(length(p-org)*.04, 1.); + color = max(dot(getNormal(p), vec3(.1, .1, .0)), .0) + vec4(.3, cos(iTime*.5)*.5+.5, sin(iTime*.5)*.5+.5, 1.)*min(length(p-org)*.04, 1.); //Ribbon Color - if(tunnel(pp)>ribbon(pp)) - color = mix(color, vec4(cos(iTime*.3)*.5+.5,cos(iTime*.2)*.5+.5,sin(iTime*.3)*.5+.5,1.),.3); + if (tunnel(pp)>ribbon(pp)) + color = mix(color, vec4(cos(iTime*.3)*.5+.5, cos(iTime*.2)*.5+.5, sin(iTime*.3)*.5+.5, 1.), .3); //Final Color - vec4 fcolor = ((color+vec4(f))+(1.-min(pp.y+1.9,1.))*vec4(1.,.8,.7,1.))*min(iTime*.5,1.); - fragColor = vec4(fcolor.xyz,1.0); + vec4 fcolor = ((color+vec4(f))+(1.-min(pp.y+1.9, 1.))*vec4(1., .8, .7, 1.))*min(iTime*.5, 1.); + fragColor = vec4(fcolor.xyz, 1.0); } // --------[ Original ShaderToy ends here ]---------- // diff --git a/src/main/resources/assets/shaders/menu/space.fsh b/src/main/resources/assets/shaders/menu/space.fsh index dc38d25f1..da4abf78c 100644 --- a/src/main/resources/assets/shaders/menu/space.fsh +++ b/src/main/resources/assets/shaders/menu/space.fsh @@ -8,29 +8,29 @@ uniform vec2 resolution; -float field(in vec3 p,float s, int idx) { - float strength = 7. + .03 * log(1.e-6 + fract(sin(time) * 4373.11)); - float accum = s/4.; - float prev = 0.; - float tw = 0.; - for (int i = 0; i < 26; ++i) { - float mag = dot(p, p); - p = abs(p) / mag + vec3(-.5, -.4, -1.5); - float w = exp(-float(i) / 7.); - accum += w * exp(-strength * pow(abs(mag - prev), 2.2)); - tw += w; - prev = mag; - } - return max(0., 5. * accum / tw - .7); +float field(in vec3 p, float s, int idx) { + float strength = 7. + .03 * log(1.e-6 + fract(sin(time) * 4373.11)); + float accum = s/4.; + float prev = 0.; + float tw = 0.; + for (int i = 0; i < 26; ++i) { + float mag = dot(p, p); + p = abs(p) / mag + vec3(-.5, -.4, -1.5); + float w = exp(-float(i) / 7.); + accum += w * exp(-strength * pow(abs(mag - prev), 2.2)); + tw += w; + prev = mag; + } + return max(0., 5. * accum / tw - .7); } -vec3 nrand3( vec2 co ) +vec3 nrand3(vec2 co) { - vec3 a = fract( cos( co.x*8.3e-3 + co.y )*vec3(1.3e5, 4.7e5, 2.9e5) ); - vec3 b = fract( sin( co.x*0.3e-3 + co.y )*vec3(8.1e5, 1.0e5, 0.1e5) ); - vec3 c = mix(a, b, 0.5); - return c; + vec3 a = fract(cos(co.x*8.3e-3 + co.y)*vec3(1.3e5, 4.7e5, 2.9e5)); + vec3 b = fract(sin(co.x*0.3e-3 + co.y)*vec3(8.1e5, 1.0e5, 0.1e5)); + vec3 c = mix(a, b, 0.5); + return c; } @@ -38,39 +38,39 @@ void main() { vec2 uv = 2. * gl_FragCoord.xy / resolution.xy - 1.; - vec2 uvs = uv * resolution.xy / max(resolution.x, resolution.y); - vec3 p = vec3(uvs / 4., 0) + vec3(1., -1.3, 0.); - p += .2 * vec3(sin(time / 16.), sin(time / 12.), sin(time / 128.)); + vec2 uvs = uv * resolution.xy / max(resolution.x, resolution.y); + vec3 p = vec3(uvs / 4., 0) + vec3(1., -1.3, 0.); + p += .2 * vec3(sin(time / 16.), sin(time / 12.), sin(time / 128.)); - float freqs[4]; - freqs[0] = 0.05; - freqs[1] = 0.3; - freqs[2] = 0.3; - freqs[3] = 0.7; + float freqs[4]; + freqs[0] = 0.05; + freqs[1] = 0.3; + freqs[2] = 0.3; + freqs[3] = 0.7; - float t = field(p,freqs[3], 26); - float v = (1. - exp((abs(uv.x) - 1.) * 6.)) * (1. - exp((abs(uv.y) - 1.) * 6.)); + float t = field(p, freqs[3], 26); + float v = (1. - exp((abs(uv.x) - 1.) * 6.)) * (1. - exp((abs(uv.y) - 1.) * 6.)); //Second Layer - vec3 p2 = vec3(uvs / (4.+sin(time*0.11)*0.2+0.2+sin(time*0.15)*0.3+0.4), 1.5) + vec3(2., -1.3, -1.); - p2 += 0.25 * vec3(sin(time / 16.), sin(time / 12.), sin(time / 128.)); - float t2 = field(p2,freqs[3], 18); - vec4 c2 = mix(.2, 0.2, v) * vec4(1.3 * t2 * t2 * t2 ,1.8 * t2 * t2 , t2* freqs[0], t2); - - - //Let's add some stars - //Thanks to http://glsl.heroku.com/e#6904.0 - vec2 seed = p.xy * 2.0; - seed = floor(seed * resolution.x); - vec3 rnd = nrand3( seed ); - vec4 starcolor = vec4(pow(rnd.y,20.0)); - - //Second Layer - vec2 seed2 = p2.xy * 3.0; - seed2 = floor(seed2 * resolution.x); - vec3 rnd2 = nrand3( seed2 ); - starcolor += vec4(pow(rnd2.y,40.0)); - - gl_FragColor = mix(freqs[3]-.5, 1.,1.0) * vec4(1.5*freqs[2] * t * t* t , 1.2*freqs[1] * t * t, freqs[3]*t, 1.0) +c2+starcolor; + vec3 p2 = vec3(uvs / (4.+sin(time*0.11)*0.2+0.2+sin(time*0.15)*0.3+0.4), 1.5) + vec3(2., -1.3, -1.); + p2 += 0.25 * vec3(sin(time / 16.), sin(time / 12.), sin(time / 128.)); + float t2 = field(p2, freqs[3], 18); + vec4 c2 = mix(.2, 0.2, v) * vec4(1.3 * t2 * t2 * t2, 1.8 * t2 * t2, t2* freqs[0], t2); + + + //Let's add some stars + //Thanks to http://glsl.heroku.com/e#6904.0 + vec2 seed = p.xy * 2.0; + seed = floor(seed * resolution.x); + vec3 rnd = nrand3(seed); + vec4 starcolor = vec4(pow(rnd.y, 20.0)); + + //Second Layer + vec2 seed2 = p2.xy * 3.0; + seed2 = floor(seed2 * resolution.x); + vec3 rnd2 = nrand3(seed2); + starcolor += vec4(pow(rnd2.y, 40.0)); + + gl_FragColor = mix(freqs[3]-.5, 1., 1.0) * vec4(1.5*freqs[2] * t * t* t, 1.2*freqs[1] * t * t, freqs[3]*t, 1.0) +c2+starcolor; } \ No newline at end of file diff --git a/src/main/resources/assets/shaders/menu/space2.fsh b/src/main/resources/assets/shaders/menu/space2.fsh index e26ef75be..0a326e6ed 100644 --- a/src/main/resources/assets/shaders/menu/space2.fsh +++ b/src/main/resources/assets/shaders/menu/space2.fsh @@ -17,62 +17,62 @@ uniform float time; uniform vec2 mouse; uniform vec2 resolution; -vec3 nrand3( vec2 co ) +vec3 nrand3(vec2 co) { - vec3 a = fract( cos( co.x*8.3e-3 + co.y )*vec3(1.3e5, 4.7e5, 2.9e5) ); - vec3 b = fract( sin( co.x*0.3e-3 + co.y )*vec3(8.1e5, 1.0e5, 0.1e5) ); - vec3 c = mix(a, b, 0.5); - return c; + vec3 a = fract(cos(co.x*8.3e-3 + co.y)*vec3(1.3e5, 4.7e5, 2.9e5)); + vec3 b = fract(sin(co.x*0.3e-3 + co.y)*vec3(8.1e5, 1.0e5, 0.1e5)); + vec3 c = mix(a, b, 0.5); + return c; } -float field(in vec3 p,float s, vec3 nebulae) { - float strength = 7. + .03 * log(1.e-6 + fract(sin(time) * 4373.11)); - float accum = s/4.; - float prev = 0.; - float tw = 0.; - for (int i = 0; i < 26; ++i) { - float mag = dot(p, p); - p = abs(p) / mag + nebulae; // these lines - float w = exp(-float(i) / 7.); - accum += w * exp(-strength * pow(abs(mag - prev), 2.2)); - tw += w; - prev = mag; - } - return max(0., 5. * accum / tw - .7); +float field(in vec3 p, float s, vec3 nebulae) { + float strength = 7. + .03 * log(1.e-6 + fract(sin(time) * 4373.11)); + float accum = s/4.; + float prev = 0.; + float tw = 0.; + for (int i = 0; i < 26; ++i) { + float mag = dot(p, p); + p = abs(p) / mag + nebulae;// these lines + float w = exp(-float(i) / 7.); + accum += w * exp(-strength * pow(abs(mag - prev), 2.2)); + tw += w; + prev = mag; + } + return max(0., 5. * accum / tw - .7); } void main() { - vec2 startPos = vec2(1.6, 3.); - float freqs[4]; - freqs[0] = 0.04; - freqs[1] = 0.6; - freqs[2] = 0.2; - freqs[3] = 0.4; + vec2 startPos = vec2(1.6, 3.); + float freqs[4]; + freqs[0] = 0.04; + freqs[1] = 0.6; + freqs[2] = 0.2; + freqs[3] = 0.4; - vec2 uv = 2. * gl_FragCoord.xy / resolution.xy - 1.; - vec2 uvs = uv * resolution.xy / max(resolution.x, resolution.y); - uvs += startPos; - vec3 p = vec3(uvs / 4., 0) + vec3(1., -1.3, 0.); - p += .2 * vec3(sin(time / 16.), sin(time / 12.), sin(time / 128.)); + vec2 uv = 2. * gl_FragCoord.xy / resolution.xy - 1.; + vec2 uvs = uv * resolution.xy / max(resolution.x, resolution.y); + uvs += startPos; + vec3 p = vec3(uvs / 4., 0) + vec3(1., -1.3, 0.); + p += .2 * vec3(sin(time / 16.), sin(time / 12.), sin(time / 128.)); - float t = field(p,freqs[2], vec3(-.1, -.4, -1.5)); - float v = (1. - exp((abs(uv.x) - 1.) * 6.)) * (1. - exp((abs(uv.y) - 1.) * 6.)); + float t = field(p, freqs[2], vec3(-.1, -.4, -1.5)); + float v = (1. - exp((abs(uv.x) - 1.) * 6.)) * (1. - exp((abs(uv.y) - 1.) * 6.)); - vec4 c1 = mix(freqs[3]-.3, 1., v) * vec4(1.5*freqs[2] * t * t* t , 1.2*freqs[1] * t * t, freqs[3]*t, 1.0); + vec4 c1 = mix(freqs[3]-.3, 1., v) * vec4(1.5*freqs[2] * t * t* t, 1.2*freqs[1] * t * t, freqs[3]*t, 1.0); //Second Layer - vec3 p2 = vec3(uvs *104., 0.)*time*0.11; //vec3(uvs / (4.+sin(time*0.11)*0.2+0.2+sin(time*0.15)*0.3+0.4), 1.5) + vec3(2., -1.3, -1.); - //p2 += 0.25 * vec3(sin(time / 16.), sin(time / 12.), sin(time / 128.)); - float t2 = field(p2,freqs[3], vec3(-.3, -.38, -1.41364)); - vec4 c2 = mix(.4, 1., v) * vec4(1.3 * t2 * t2 * t2 ,1.8 * t2 * t2 , t2* freqs[0], t2); + vec3 p2 = vec3(uvs *104., 0.)*time*0.11;//vec3(uvs / (4.+sin(time*0.11)*0.2+0.2+sin(time*0.15)*0.3+0.4), 1.5) + vec3(2., -1.3, -1.); + //p2 += 0.25 * vec3(sin(time / 16.), sin(time / 12.), sin(time / 128.)); + float t2 = field(p2, freqs[3], vec3(-.3, -.38, -1.41364)); + vec4 c2 = mix(.4, 1., v) * vec4(1.3 * t2 * t2 * t2, 1.8 * t2 * t2, t2* freqs[0], t2); - vec4 starcolor = vec4(0); + vec4 starcolor = vec4(0); - //Second Layer - vec2 seed2 = p.xy * 2.0 * time*0.1; - seed2 = floor(seed2 * resolution.x); - vec3 rnd2 = nrand3( seed2 ); - starcolor += vec4(pow(rnd2.z,20.0)); - gl_FragColor = c1+c2+starcolor; + //Second Layer + vec2 seed2 = p.xy * 2.0 * time*0.1; + seed2 = floor(seed2 * resolution.x); + vec3 rnd2 = nrand3(seed2); + starcolor += vec4(pow(rnd2.z, 20.0)); + gl_FragColor = c1+c2+starcolor; } \ No newline at end of file diff --git a/src/main/resources/assets/shaders/menu/storm.fsh b/src/main/resources/assets/shaders/menu/storm.fsh index 391e92a13..da24b48f1 100644 --- a/src/main/resources/assets/shaders/menu/storm.fsh +++ b/src/main/resources/assets/shaders/menu/storm.fsh @@ -22,7 +22,7 @@ vec4 iMouse = vec4(0.); mat2 mm2(in float a) { float c = cos(a); float s = sin(a); - return mat2(c,s,-s,c); + return mat2(c, s, -s, c); } // Returns the clamped version of the input @@ -38,7 +38,7 @@ mat2 mm2(in float a) { float hash12(vec2 p) { - vec3 p3 = fract(vec3(p.xyx) * 0.1031); + vec3 p3 = fract(vec3(p.xyx) * 0.1031); p3 += dot(p3, p3.yzx + 19.19); return fract((p3.x + p3.y) * p3.z); @@ -46,7 +46,7 @@ float hash12(vec2 p) { float hash13(vec3 p3) { - p3 = fract(p3 * 0.1031); + p3 = fract(p3 * 0.1031); p3 += dot(p3, p3.yzx + 19.19); return fract((p3.x + p3.y) * p3.z); @@ -54,9 +54,9 @@ float hash13(vec3 p3) { vec3 hash31(float p) { - vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973)); - p3 += dot(p3, p3.yzx+19.19); - return fract((p3.xxy+p3.yzz)*p3.zyx); + vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973)); + p3 += dot(p3, p3.yzx+19.19); + return fract((p3.xxy+p3.yzz)*p3.zyx); } @@ -67,46 +67,46 @@ vec3 hash31(float p) { float valueNoise(vec2 p) { - vec2 i = floor(p); + vec2 i = floor(p); vec2 f = fract(p); f = f*f*f*(f*(f*6.0-15.0)+10.0); - vec2 add = vec2(1.0,0.0); + vec2 add = vec2(1.0, 0.0); float res = mix( - mix(hash12(i + add.yy), hash12(i + add.xy), f.x), - mix(hash12(i + add.yx), hash12(i + add.xx), f.x), - f.y); + mix(hash12(i + add.yy), hash12(i + add.xy), f.x), + mix(hash12(i + add.yx), hash12(i + add.xx), f.x), + f.y); return res; } float valueNoise(vec3 p) { - vec3 i = floor(p); + vec3 i = floor(p); vec3 f = fract(p); f = f*f*f*(f*(f*6.0-15.0)+10.0); - vec2 add = vec2(1.0,0.0); + vec2 add = vec2(1.0, 0.0); float res = mix( - mix( - mix(hash13(i + add.yyy), hash13(i + add.xyy), f.x), - mix(hash13(i + add.yxy), hash13(i + add.xxy), f.x), - f.y), - mix( - mix(hash13(i + add.yyx), hash13(i + add.xyx), f.x), - mix(hash13(i + add.yxx), hash13(i + add.xxx), f.x), - f.y), - f.z); + mix( + mix(hash13(i + add.yyy), hash13(i + add.xyy), f.x), + mix(hash13(i + add.yxy), hash13(i + add.xxy), f.x), + f.y), + mix( + mix(hash13(i + add.yyx), hash13(i + add.xyx), f.x), + mix(hash13(i + add.yxx), hash13(i + add.xxx), f.x), + f.y), + f.z); return res; } -#define SPEED 1.0 + #define SPEED 1.0 float noise(vec2 p) { - return valueNoise(p); + return valueNoise(p); } float fbm4(vec2 p, mat2 m) { @@ -139,9 +139,9 @@ float warpedNoise(vec2 q) { float p2 = 4.0; float angle = 0.0; - float scale = 3.24; + float scale = 3.24; - mat2 m = mat2(cos(angle), sin(angle), -sin(angle), cos(angle)) * scale; + mat2 m = mat2(cos(angle), sin(angle), -sin(angle), cos(angle)) * scale; vec2 o = vec2(0.0); o.x = o1 * fbm6(o2*q + vec2(19.2), m); @@ -211,7 +211,7 @@ vec3 render(vec3 ro, vec3 rd) { for (int i = 0; i < noOfPlanes; i++) { vec4 col = planeCol(currentPos.xy, currentPos.z); if (col.a > 0.001) { - return col.rgb; + return col.rgb; } currentPos += rayStep * planeGap; } @@ -221,7 +221,7 @@ vec3 render(vec3 ro, vec3 rd) { } -void mainImage( out vec4 fragColor, in vec2 fragCoord ) { +void mainImage(out vec4 fragColor, in vec2 fragCoord) { // Normalises the fragCoord vec2 uv = fragCoord/iResolution.xy; @@ -235,7 +235,7 @@ void mainImage( out vec4 fragColor, in vec2 fragCoord ) { // Rotates the ray depending on the mouse position. I lifted this from // https://www.shadertoy.com/view/XtGGRt, but it seems to be the common approach vec2 mo = iMouse.xy / iResolution.xy-.5; - mo = (mo==vec2(-.5))?mo=vec2(0.0, -0.0):mo; // Default position of camera + mo = (mo==vec2(-.5))?mo=vec2(0.0, -0.0):mo;// Default position of camera mo.x *= iResolution.x/iResolution.y; mo *= 0.5; rd.yz *= mm2(mo.y); @@ -243,12 +243,12 @@ void mainImage( out vec4 fragColor, in vec2 fragCoord ) { // Render the ray if (rd.z > 0.0) { - vec3 col = render(ro, rd); - fragColor = vec4(col, 1.0); + vec3 col = render(ro, rd); + fragColor = vec4(col, 1.0); } - + else { - fragColor = vec4(1.0); + fragColor = vec4(1.0); } } diff --git a/src/main/resources/assets/shaders/menu/triangle.fsh b/src/main/resources/assets/shaders/menu/triangle.fsh index b11e0154f..2c239b313 100644 --- a/src/main/resources/assets/shaders/menu/triangle.fsh +++ b/src/main/resources/assets/shaders/menu/triangle.fsh @@ -11,77 +11,77 @@ uniform vec2 resolution; -#define Resolution resolution -#define Time time - -#define HorizontalAmplitude 0.30 -#define VerticleAmplitude 0.20 -#define HorizontalSpeed 0.90 -#define VerticleSpeed 1.50 -#define ParticleMinSize 1.76 -#define ParticleMaxSize 1.61 -#define ParticleBreathingSpeed 0.30 -#define ParticleColorChangeSpeed 0.70 -#define ParticleCount 2.0 -#define ParticleColor1 vec3(9.0, 5.0, 3.0) -#define ParticleColor2 vec3(1.0, 3.0, 9.0) - - -float hash( float x ) +#define Resolution resolution +#define Time time + +#define HorizontalAmplitude 0.30 +#define VerticleAmplitude 0.20 +#define HorizontalSpeed 0.90 +#define VerticleSpeed 1.50 +#define ParticleMinSize 1.76 +#define ParticleMaxSize 1.61 +#define ParticleBreathingSpeed 0.30 +#define ParticleColorChangeSpeed 0.70 +#define ParticleCount 2.0 +#define ParticleColor1 vec3(9.0, 5.0, 3.0) +#define ParticleColor2 vec3(1.0, 3.0, 9.0) + + +float hash(float x) { - return fract( sin( x ) * 43758.5453 ); + return fract(sin(x) * 43758.5453); } -float noise( vec2 uv ) // Thanks Inigo Quilez +float noise(vec2 uv)// Thanks Inigo Quilez { - vec3 x = vec3( uv.xy, 90.0 ); + vec3 x = vec3(uv.xy, 90.0); - vec3 p = floor( x ); - vec3 f = fract( x ); + vec3 p = floor(x); + vec3 f = fract(x); f = f*f*(3.0 - 2.0*f); float offset = 57.0; - float n = dot( p, vec3(1.0, offset, offset*2.0) ); + float n = dot(p, vec3(1.0, offset, offset*2.0)); - return mix( mix( mix( hash( n + 0.0 ), hash( n + 1.0 ), f.x ), - mix( hash( n + offset), hash( n + offset+1.0), f.x ), f.y ), - mix( mix( hash( n + offset*2.0), hash( n + offset*2.0+1.0), f.x), - mix( hash( n + offset*3.0), hash( n + offset*3.0+1.0), f.x), f.y), f.z); + return mix(mix(mix(hash(n + 0.0), hash(n + 1.0), f.x), + mix(hash(n + offset), hash(n + offset+1.0), f.x), f.y), + mix(mix(hash(n + offset*2.0), hash(n + offset*2.0+1.0), f.x), + mix(hash(n + offset*3.0), hash(n + offset*3.0+1.0), f.x), f.y), f.z); } -float snoise( vec2 uv ) +float snoise(vec2 uv) { - return noise( uv ) * 2.0 - 1.0; + return noise(uv) * 2.0 - 1.0; } -float perlinNoise( vec2 uv ) +float perlinNoise(vec2 uv) { - float n = noise( uv * 1.0 ) * 128.0 + - noise( uv * 2.0 ) * 64.0 + - noise( uv * 4.0 ) * 32.0 + - noise( uv * 8.0 ) * 16.0 + - noise( uv * 16.0 ) * 8.0 + - noise( uv * 32.0 ) * 4.0 + - noise( uv * 64.0 ) * 2.0 + - noise( uv * 128.0 ) * 1.0; - - float noiseVal = n / ( 1.0 + 2.0 + 4.0 + 8.0 + 16.0 + 32.0 + 64.0 + 128.0 ); + float n = noise(uv * 1.0) * 128.0 + + noise(uv * 2.0) * 64.0 + + noise(uv * 4.0) * 32.0 + + noise(uv * 8.0) * 16.0 + + noise(uv * 16.0) * 8.0 + + noise(uv * 32.0) * 4.0 + + noise(uv * 64.0) * 2.0 + + noise(uv * 128.0) * 1.0; + + float noiseVal = n / (1.0 + 2.0 + 4.0 + 8.0 + 16.0 + 32.0 + 64.0 + 128.0); noiseVal = abs(noiseVal * 2.0 - 1.0); - return noiseVal; + return noiseVal; } -float fBm( vec2 uv, float lacunarity, float gain ) +float fBm(vec2 uv, float lacunarity, float gain) { float sum = 0.0; float amp = 7.0; - for( int i = 0; i < 2; ++i ) + for (int i = 0; i < 2; ++i) { - sum += ( perlinNoise( uv ) ) * amp; + sum += (perlinNoise(uv)) * amp; amp *= gain; uv *= lacunarity; } @@ -89,86 +89,86 @@ float fBm( vec2 uv, float lacunarity, float gain ) return sum; } -vec3 particles( vec2 pos ) +vec3 particles(vec2 pos) { - vec3 c = vec3( 0, 0, 0 ); + vec3 c = vec3(0, 0, 0); - float noiseFactor = fBm( pos, 0.01, 0.1); + float noiseFactor = fBm(pos, 0.01, 0.1); - for( float i = 1.0; i < ParticleCount+1.0; ++i ) - { - float cs = cos( time * HorizontalSpeed * (i/ParticleCount) + noiseFactor ) * HorizontalAmplitude; - float ss = sin( time * VerticleSpeed * (i/ParticleCount) + noiseFactor ) * VerticleAmplitude; - vec2 origin = vec2( cs , ss ); + for (float i = 1.0; i < ParticleCount+1.0; ++i) + { + float cs = cos(time * HorizontalSpeed * (i/ParticleCount) + noiseFactor) * HorizontalAmplitude; + float ss = sin(time * VerticleSpeed * (i/ParticleCount) + noiseFactor) * VerticleAmplitude; + vec2 origin = vec2(cs, ss); - float t = sin( time * ParticleBreathingSpeed * i ) * 0.5 + 0.5; - float particleSize = mix( ParticleMinSize, ParticleMaxSize, t ); - float d = clamp( sin( length( pos - origin ) + particleSize ), 0.0, particleSize); + float t = sin(time * ParticleBreathingSpeed * i) * 0.5 + 0.5; + float particleSize = mix(ParticleMinSize, ParticleMaxSize, t); + float d = clamp(sin(length(pos - origin) + particleSize), 0.0, particleSize); - float t2 = sin( time * ParticleColorChangeSpeed * i ) * 0.5 + 0.5; - vec3 color = mix( ParticleColor1, ParticleColor2, t2 ); - c += color * pow( d, 10.0 ); - } + float t2 = sin(time * ParticleColorChangeSpeed * i) * 0.5 + 0.5; + vec3 color = mix(ParticleColor1, ParticleColor2, t2); + c += color * pow(d, 10.0); + } - return c; + return c; } -float line( vec2 a, vec2 b, vec2 p ) +float line(vec2 a, vec2 b, vec2 p) { - vec2 aTob = b - a; - vec2 aTop = p - a; + vec2 aTob = b - a; + vec2 aTop = p - a; - float t = dot( aTop, aTob ) / dot( aTob, aTob); + float t = dot(aTop, aTob) / dot(aTob, aTob); - t = clamp( t, 0.0, 1.0); + t = clamp(t, 0.0, 1.0); - float d = length( p - (a + aTob * t) ); - d = 1.0 / d; + float d = length(p - (a + aTob * t)); + d = 1.0 / d; - return clamp( d, 0.0, 1.0 ); + return clamp(d, 0.0, 1.0); } -void main( void ) { +void main(void) { - float aspectRatio = resolution.x / resolution.y; + float aspectRatio = resolution.x / resolution.y; - vec2 uv = ( gl_FragCoord.xy / resolution.xy ); + vec2 uv = (gl_FragCoord.xy / resolution.xy); - vec2 signedUV = uv * 2.0 - 1.0; - signedUV.x *= aspectRatio; + vec2 signedUV = uv * 2.0 - 1.0; + signedUV.x *= aspectRatio; - float freqA = mix( 0.4, 1.2, sin(time + 30.0) * 0.5 + 0.5 ); - float freqB = mix( 0.4, 1.2, sin(time + 20.0) * 0.5 + 0.5 ); - float freqC = mix( 0.4, 1.2, sin(time + 10.0) * 0.5 + 0.5 ); + float freqA = mix(0.4, 1.2, sin(time + 30.0) * 0.5 + 0.5); + float freqB = mix(0.4, 1.2, sin(time + 20.0) * 0.5 + 0.5); + float freqC = mix(0.4, 1.2, sin(time + 10.0) * 0.5 + 0.5); - float scale = 100.0; - const float v = 70.0; - vec3 finalColor = vec3( 0.0 ); + float scale = 100.0; + const float v = 70.0; + vec3 finalColor = vec3(0.0); - finalColor = (particles( sin( abs(signedUV) ) ) * length(signedUV)) * 0.20; + finalColor = (particles(sin(abs(signedUV))) * length(signedUV)) * 0.20; - float t = line( vec2(-v, -v), vec2(0.0, v), signedUV * scale ); - finalColor += vec3( 8.0 * t, 2.0 * t, 4.0 * t) * freqA; - t = line( vec2(0.0, v), vec2(v, -v), signedUV * scale ); - finalColor += vec3( 2.0 * t, 8.0 * t, 4.0 * t) * freqB; - t = line( vec2(-v, -v), vec2(v, -v), signedUV * scale ); - finalColor += vec3( 2.0 * t, 4.0 * t, 8.0 * t) * freqC; + float t = line(vec2(-v, -v), vec2(0.0, v), signedUV * scale); + finalColor += vec3(8.0 * t, 2.0 * t, 4.0 * t) * freqA; + t = line(vec2(0.0, v), vec2(v, -v), signedUV * scale); + finalColor += vec3(2.0 * t, 8.0 * t, 4.0 * t) * freqB; + t = line(vec2(-v, -v), vec2(v, -v), signedUV * scale); + finalColor += vec3(2.0 * t, 4.0 * t, 8.0 * t) * freqC; - //scale = scale * 1.2; - //t = line( vec2(0.0, v * 0.2), vec2(0.0, -v * 0.8), signedUV * scale ); - //finalColor += vec3( 8.0 * t, 4.0 * t, 2.0 * t) * 0.5; + //scale = scale * 1.2; + //t = line( vec2(0.0, v * 0.2), vec2(0.0, -v * 0.8), signedUV * scale ); + //finalColor += vec3( 8.0 * t, 4.0 * t, 2.0 * t) * 0.5; - //t = line( vec2(-v * 0.3, -v*0.1), vec2(v * 0.3, -v*0.1), signedUV * scale ); - //finalColor += vec3( 8.0 * t, 4.0 * t, 2.0 * t) * 0.4; + //t = line( vec2(-v * 0.3, -v*0.1), vec2(v * 0.3, -v*0.1), signedUV * scale ); + //finalColor += vec3( 8.0 * t, 4.0 * t, 2.0 * t) * 0.4; - gl_FragColor = vec4( finalColor, 1.0 ); + gl_FragColor = vec4(finalColor, 1.0); } \ No newline at end of file