Skip to content

Commit dc57931

Browse files
authored
Merge pull request #8 from Avanatiker/feature/renderer
Render pipeline and ClickGUI
2 parents b929f0f + 3559754 commit dc57931

File tree

87 files changed

+2718
-255
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+2718
-255
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.lambda.mixin.render;
2+
3+
import com.lambda.graphics.gl.GlStateUtils;
4+
import com.mojang.blaze3d.platform.GlStateManager;
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.injection.At;
7+
import org.spongepowered.asm.mixin.injection.Inject;
8+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
9+
10+
import static org.lwjgl.opengl.GL11.*;
11+
import static org.lwjgl.opengl.GL11.GL_CULL_FACE;
12+
13+
@Mixin(GlStateManager.class)
14+
public class GlStateManagerMixin {
15+
@Inject(method = "_enableDepthTest", at = @At("TAIL"), remap = false)
16+
private static void depthTestEnable(CallbackInfo ci) {
17+
GlStateUtils.capSet(GL_DEPTH_TEST, true);
18+
}
19+
20+
@Inject(method = "_disableDepthTest", at = @At("TAIL"), remap = false)
21+
private static void depthTestDisable(CallbackInfo ci) {
22+
GlStateUtils.capSet(GL_DEPTH_TEST, false);
23+
}
24+
25+
@Inject(method = "_depthMask", at = @At("TAIL"), remap = false)
26+
private static void depthMask(boolean mask, CallbackInfo ci) {
27+
GlStateUtils.capSet(GL_DEPTH, mask);
28+
}
29+
30+
@Inject(method = "_enableBlend", at = @At("TAIL"), remap = false)
31+
private static void blendEnable(CallbackInfo ci) {
32+
GlStateUtils.capSet(GL_BLEND, true);
33+
}
34+
35+
@Inject(method = "_disableBlend", at = @At("TAIL"), remap = false)
36+
private static void blendDisable(CallbackInfo ci) {
37+
GlStateUtils.capSet(GL_BLEND, false);
38+
}
39+
40+
@Inject(method = "_enableCull", at = @At("TAIL"), remap = false)
41+
private static void cullEnable(CallbackInfo ci) {
42+
GlStateUtils.capSet(GL_CULL_FACE, true);
43+
}
44+
45+
@Inject(method = "_disableCull", at = @At("TAIL"), remap = false)
46+
private static void cullDisable(CallbackInfo ci) {
47+
GlStateUtils.capSet(GL_CULL_FACE, false);
48+
}
49+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.lambda.mixin.render;
2+
3+
import com.lambda.graphics.RenderMain;
4+
import net.minecraft.client.gui.DrawContext;
5+
import net.minecraft.client.gui.hud.InGameHud;
6+
import org.spongepowered.asm.mixin.Mixin;
7+
import org.spongepowered.asm.mixin.injection.At;
8+
import org.spongepowered.asm.mixin.injection.Inject;
9+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
10+
11+
@Mixin(InGameHud.class)
12+
public class InGameHudMixin {
13+
@Inject(method = "render", at = @At("TAIL"))
14+
private void onRender(DrawContext context, float tickDelta, CallbackInfo ci) {
15+
RenderMain.render2D();
16+
}
17+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.lambda.mixin.render;
2+
3+
import com.lambda.graphics.gl.VaoUtils;
4+
import com.mojang.blaze3d.systems.RenderSystem;
5+
import net.minecraft.client.gl.VertexBuffer;
6+
import net.minecraft.client.render.BufferBuilder;
7+
import org.spongepowered.asm.mixin.Mixin;
8+
import org.spongepowered.asm.mixin.Shadow;
9+
import org.spongepowered.asm.mixin.injection.At;
10+
import org.spongepowered.asm.mixin.injection.Inject;
11+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
12+
13+
import java.nio.ByteBuffer;
14+
15+
@Mixin(VertexBuffer.class)
16+
public class VertexBufferMixin {
17+
@Shadow
18+
private int indexBufferId;
19+
20+
@Inject(method = "uploadIndexBuffer", at = @At("RETURN"))
21+
private void onConfigureIndexBuffer(BufferBuilder.DrawParameters parameters, ByteBuffer vertexBuffer, CallbackInfoReturnable<RenderSystem.ShapeIndexBuffer> cir) {
22+
RenderSystem.ShapeIndexBuffer value = cir.getReturnValue();
23+
VaoUtils.lastIbo = value == null ? this.indexBufferId : value.id;
24+
}
25+
}

common/src/main/kotlin/com/lambda/Lambda.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ package com.lambda
33
import com.google.gson.Gson
44
import com.google.gson.GsonBuilder
55
import com.lambda.config.serializer.*
6+
import com.lambda.config.serializer.gui.ModuleTagSerializer
7+
import com.lambda.config.serializer.gui.TagWindowSerializer
68
import com.lambda.core.Loader
9+
import com.lambda.gui.impl.clickgui.windows.TagWindow
710
import com.lambda.module.tag.ModuleTag
811
import com.lambda.util.KeyCode
912
import net.minecraft.block.Block
@@ -24,6 +27,7 @@ object Lambda {
2427
val gson: Gson = GsonBuilder()
2528
.setPrettyPrinting()
2629
.registerTypeAdapter(ModuleTag::class.java, ModuleTagSerializer)
30+
.registerTypeAdapter(TagWindow::class.java, TagWindowSerializer)
2731
.registerTypeAdapter(KeyCode::class.java, KeyCodeSerializer)
2832
.registerTypeAdapter(Color::class.java, ColorSerializer)
2933
.registerTypeAdapter(BlockPos::class.java, BlockPosSerializer)

common/src/main/kotlin/com/lambda/command/CommandManager.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import org.reflections.Reflections
2020
import org.reflections.scanners.Scanners
2121
import org.reflections.util.ClasspathHelper
2222
import org.reflections.util.ConfigurationBuilder
23+
import java.awt.Color
2324
import kotlin.math.max
2425
import kotlin.math.min
2526

@@ -95,7 +96,7 @@ object CommandManager : Configurable(LambdaConfig), Loadable {
9596
val position = min(syntax.input.length, syntax.cursor)
9697
player.sendMessage(buildText {
9798
clickEvent(suggestCommand("$prefix${reader.string}")) {
98-
color(Color.GREY) {
99+
color(Color.GRAY) {
99100
if (position > ERROR_PADDING) {
100101
literal("...")
101102
}

common/src/main/kotlin/com/lambda/command/commands/ModuleCommand.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import com.lambda.util.Communication.warn
1919
import com.lambda.util.StringUtils
2020
import com.lambda.util.text.*
2121
import com.lambda.util.text.ClickEvents.suggestCommand
22+
import java.awt.Color
2223

2324
object ModuleCommand : LambdaCommand {
2425
override val name = "module"
@@ -36,7 +37,7 @@ object ModuleCommand : LambdaCommand {
3637
}
3738

3839
this@ModuleCommand.info(buildText {
39-
styled(Color.GREY) {
40+
styled(Color.GRAY) {
4041
literal("Enabled Modules: ")
4142
}
4243
enabled.forEachIndexed { index, module ->
@@ -70,7 +71,7 @@ object ModuleCommand : LambdaCommand {
7071
} ?: return@executeWithResult failure(buildText {
7172
styled(Color.RED) {
7273
literal("Module ")
73-
styled(Color.GREY) {
74+
styled(Color.GRAY) {
7475
literal("$name ")
7576
}
7677
literal("not found!")
@@ -88,7 +89,7 @@ object ModuleCommand : LambdaCommand {
8889
literal(", ")
8990
}
9091
clickEvent(suggestCommand("$prefix${input.replace(name, s)}")) {
91-
styled(Color.GREY) {
92+
styled(Color.GRAY) {
9293
literal(s)
9394
}
9495
}
@@ -102,7 +103,7 @@ object ModuleCommand : LambdaCommand {
102103
} else {
103104
if (enable().value() == module.isEnabled) {
104105
this@ModuleCommand.warn(buildText {
105-
styled(Color.GREY) {
106+
styled(Color.GRAY) {
106107
literal("$name already ")
107108
literal(if (module.isEnabled) "enabled" else "disabled")
108109
}
@@ -117,7 +118,7 @@ object ModuleCommand : LambdaCommand {
117118
}
118119
}
119120
this@ModuleCommand.info(buildText {
120-
styled(Color.GREY) {
121+
styled(Color.GRAY) {
121122
literal("$name ")
122123
}
123124
styled(if (module.isEnabled) Color.GREEN else Color.RED) {

common/src/main/kotlin/com/lambda/config/Configurable.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.lambda.config
22

33
import com.google.gson.JsonElement
44
import com.google.gson.JsonObject
5+
import com.google.gson.reflect.TypeToken
56
import com.lambda.Lambda
67
import com.lambda.Lambda.LOG
78
import com.lambda.config.settings.CharSetting
@@ -21,6 +22,7 @@ import com.lambda.util.Nameable
2122
import net.minecraft.block.Block
2223
import net.minecraft.util.math.BlockPos
2324
import java.awt.Color
25+
import java.lang.reflect.Type
2426

2527
/**
2628
* Represents a set of [AbstractSetting]s that are associated with the [name] of the [Configurable].
@@ -165,7 +167,7 @@ abstract class Configurable(configuration: Configuration) : Jsonable, Nameable {
165167
defaultValue: List<T>,
166168
description: String = "",
167169
noinline visibility: () -> Boolean = { true },
168-
) = ListSetting(name, defaultValue, description, visibility).also {
170+
) = ListSetting(name, defaultValue, object : TypeToken<List<T>>() {}.type, description, visibility).also {
169171
settings.add(it)
170172
}
171173

@@ -191,7 +193,7 @@ abstract class Configurable(configuration: Configuration) : Jsonable, Nameable {
191193
defaultValue: Map<K, V>,
192194
description: String = "",
193195
noinline visibility: () -> Boolean = { true },
194-
) = MapSetting(name, defaultValue, description, visibility).also {
196+
) = MapSetting(name, defaultValue, object : TypeToken<Map<K, V>>() {}.type, description, visibility).also {
195197
settings.add(it)
196198
}
197199

@@ -217,7 +219,7 @@ abstract class Configurable(configuration: Configuration) : Jsonable, Nameable {
217219
defaultValue: Set<T>,
218220
description: String = "",
219221
noinline visibility: () -> Boolean = { true },
220-
) = SetSetting(name, defaultValue, description, visibility).also {
222+
) = SetSetting(name, defaultValue, object : TypeToken<Set<T>>() {}.type, description, visibility).also {
221223
settings.add(it)
222224
}
223225

common/src/main/kotlin/com/lambda/config/Configuration.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ abstract class Configuration : Jsonable {
4141
init {
4242
unsafeListener<ClientEvent.Startup> { tryLoad() }
4343

44-
unsafeListener<ClientEvent.Shutdown> { trySave() }
44+
unsafeListener<ClientEvent.Shutdown>(Int.MIN_VALUE) { trySave() }
4545

4646
configurations.add(this)
4747
}
@@ -90,7 +90,7 @@ abstract class Configuration : Jsonable {
9090
}
9191
.onFailure {
9292
val message = "Failed to load ${configName.capitalize()} config, loading backup"
93-
LOG.error(message)
93+
LOG.error(message, it)
9494
this@Configuration.logError(message)
9595
runCatching { load(backup) }
9696
.onSuccess {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.lambda.config.configurations
2+
3+
import com.lambda.config.Configuration
4+
import com.lambda.util.FolderRegister
5+
6+
object GuiConfig : Configuration() {
7+
override val configName = "gui"
8+
override val primary = FolderRegister.config.resolve("$configName.json")
9+
}

common/src/main/kotlin/com/lambda/config/serializer/ModuleTagSerializer.kt renamed to common/src/main/kotlin/com/lambda/config/serializer/gui/ModuleTagSerializer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.lambda.config.serializer
1+
package com.lambda.config.serializer.gui
22

33
import com.google.gson.*
44
import com.lambda.module.tag.ModuleTag

0 commit comments

Comments
 (0)