Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -87,10 +88,22 @@ private void refreshEmojiSuggestion(CallbackInfo ci) {
int start = neoLambda$getLastColon(textToCursor);
if (start == -1) return;

String emojiString = typing.substring(start + 1);
Matcher emojiMatcher = EMOJI_PATTERN.matcher(textToCursor);
Map<String, ?> emojiKeys = LambdaAtlas.INSTANCE.getKeys(RenderSettings.INSTANCE.getEmojiFont());
while (emojiMatcher.find()) {
int openingColon = emojiMatcher.start(1);
String key = emojiMatcher.group(2);
int closingColon = emojiMatcher.end(3);

if (emojiKeys.containsKey(key) && start >= openingColon && start < closingColon) {
// If the colon is part of a previous valid emoji, return
return;
}
}

String emojiString = textToCursor.substring(start + 1);

Stream<String> results = LambdaAtlas.INSTANCE.getKeys(RenderSettings.INSTANCE.getEmojiFont())
.keySet().stream()
Stream<String> results = emojiKeys.keySet().stream()
.filter(s -> s.startsWith(emojiString))
.map(s -> s + ":");

Expand All @@ -105,6 +118,9 @@ private void refreshEmojiSuggestion(CallbackInfo ci) {
@Unique
private static final Pattern COLON_PATTERN = Pattern.compile("(:[a-zA-Z0-9_]+)");

@Unique
private static final Pattern EMOJI_PATTERN = Pattern.compile("(:)([a-zA-Z0-9_]+)(:)");

@Unique
private int neoLambda$getLastColon(String input) {
if (Strings.isNullOrEmpty(input)) return -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package com.lambda.mixin.render;

import com.lambda.graphics.buffer.vertex.ElementBuffer;
import com.lambda.graphics.buffer.Buffer;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gl.VertexBuffer;
import net.minecraft.client.render.BufferBuilder;
Expand All @@ -37,6 +37,6 @@ public class VertexBufferMixin {
@Inject(method = "uploadIndexBuffer", at = @At("RETURN"))
private void onConfigureIndexBuffer(BufferBuilder.DrawParameters parameters, ByteBuffer vertexBuffer, CallbackInfoReturnable<RenderSystem.ShapeIndexBuffer> cir) {
RenderSystem.ShapeIndexBuffer value = cir.getReturnValue();
ElementBuffer.lastIbo = value == null ? this.indexBufferId : value.id;
Buffer.lastIbo = value == null ? this.indexBufferId : value.id;
}
}
35 changes: 35 additions & 0 deletions common/src/main/kotlin/com/lambda/config/Configurable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import com.lambda.util.KeyCode
import com.lambda.util.Nameable
import net.minecraft.block.Block
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Vec3d
import java.awt.Color

/**
Expand Down Expand Up @@ -387,6 +388,40 @@ abstract class Configurable(
visibility: () -> Boolean = { true },
) = ColorSetting(name, defaultValue, description, visibility).register()

/**
* Creates a [Vec3dSetting] with the provided parameters and adds it to the [settings].
*
* @param name The unique identifier for the setting.
* @param defaultValue The default [Vec3d] value of the setting.
* @param description A brief explanation of the setting's purpose and behavior.
* @param visibility A lambda expression that determines the visibility status of the setting.
*
* @return The created [Vec3dSetting].
*/
fun setting(
name: String,
defaultValue: Vec3d,
description: String = "",
visibility: () -> Boolean = { true },
) = Vec3dSetting(name, defaultValue, description, visibility).register()

/**
* Creates a [BlockPosSetting] with the provided parameters and adds it to the [settings].
*
* @param name The unique identifier for the setting.
* @param defaultValue The default [BlockPos.Mutable] value of the setting.
* @param description A brief explanation of the setting's purpose and behavior.
* @param visibility A lambda expression that determines the visibility status of the setting.
*
* @return The created [BlockPosSetting].
*/
fun setting(
name: String,
defaultValue: BlockPos.Mutable,
description: String = "",
visibility: () -> Boolean = { true },
) = BlockPosSetting(name, defaultValue, description, visibility).register()

/**
* Creates a [BlockPosSetting] with the provided parameters and adds it to the [settings].
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,27 @@ class EnumSetting<T : Enum<T>>(
description,
visibility,
) {
val enumValues: Array<T> = defaultValue.declaringJavaClass.enumConstants

fun next() {
value = enumValues[((value.ordinal + 1) % enumValues.size)]
value = value.enumValues[((value.ordinal + 1) % value.enumValues.size)]
}

override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) {
required(word(name)) { parameter ->
suggests { _, builder ->
enumValues.forEach { builder.suggest(it.name.capitalize()) }
value.enumValues.forEach { builder.suggest(it.name.capitalize()) }
builder.buildFuture()
}
executeWithResult {
val newValue = enumValues.find { it.name.equals(parameter().value(), true) }
val newValue = value.enumValues.find { it.name.equals(parameter().value(), true) }
?: return@executeWithResult failure("Invalid value")
trySetValue(newValue)
return@executeWithResult success()
}
}
}

companion object {
val <T : Enum<T>> T.enumValues: Array<T> get() =
declaringJavaClass.enumConstants
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright 2024 Lambda
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.lambda.config.settings.complex

import com.google.gson.reflect.TypeToken
import com.lambda.brigadier.argument.double
import com.lambda.brigadier.argument.integer
import com.lambda.brigadier.argument.value
import com.lambda.brigadier.execute
import com.lambda.brigadier.required
import com.lambda.config.AbstractSetting
import com.lambda.util.extension.CommandBuilder
import net.minecraft.command.CommandRegistryAccess
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Vec3d

class Vec3dSetting(
override val name: String,
defaultValue: Vec3d,
description: String,
visibility: () -> Boolean,
) : AbstractSetting<Vec3d>(
defaultValue,
TypeToken.get(Vec3d::class.java).type,
description,
visibility
) {
override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) {
required(double("X", -30000000.0, 30000000.0)) { x ->
required(double("Y", -64.0, 255.0)) { y ->
required(double("Z", -30000000.0, 30000000.0)) { z ->
execute {
trySetValue(Vec3d(x().value(), y().value(), z().value()))
}
}
}
}
}
}
19 changes: 19 additions & 0 deletions common/src/main/kotlin/com/lambda/graphics/RenderMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ package com.lambda.graphics
import com.lambda.Lambda.mc
import com.lambda.event.EventFlow.post
import com.lambda.event.events.RenderEvent
import com.lambda.event.events.TickEvent
import com.lambda.event.listener.SafeListener.Companion.listen
import com.lambda.graphics.gl.GlStateUtils.setupGL
import com.lambda.graphics.gl.Matrices
import com.lambda.graphics.gl.Matrices.resetMatrices
import com.lambda.graphics.renderer.esp.global.DynamicESP
import com.lambda.graphics.renderer.esp.global.StaticESP
import com.lambda.module.modules.client.GuiSettings
import com.lambda.util.Communication.info
import com.lambda.util.math.Vec2d
import com.mojang.blaze3d.systems.RenderSystem.getProjectionMatrix
import org.joml.Matrix4f
Expand Down Expand Up @@ -57,6 +62,20 @@ object RenderMain {

setupGL {
RenderEvent.World().post()
StaticESP.render()
DynamicESP.render()
}
}

init {
listen<TickEvent.Post> {
StaticESP.clear()
RenderEvent.StaticESP().post()
StaticESP.upload()

DynamicESP.clear()
RenderEvent.DynamicESP().post()
DynamicESP.upload()
}
}

Expand Down
Loading