Skip to content

Commit

Permalink
Well, this works
Browse files Browse the repository at this point in the history
  • Loading branch information
KrLite committed Jul 11, 2024
1 parent 785f5e8 commit 22b67c9
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
* Provides access to the screen and window properties.
*/
public class FrameInfo {
public static float tickDelta() {
return MinecraftClient.getInstance().getTickDelta();
}

public static Box scaled() {
return new Box(Vector.fromCartesian(MinecraftClient.getInstance().getWindow().getScaledWidth(), MinecraftClient.getInstance().getWindow().getScaledHeight()));
}
Expand Down
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ archives-animation-name = "equator-animation"
archives-math-name = "equator-math"
archives-visual-name = "equator-visual"

minecraft = "1.20"
yarn = "1.20+build.1"
minecraft = "1.21"
yarn = "1.21+build.7"
fabric-loader = "0.15.7"
fabric-api = "0.83.0+1.20"
fabric-loom = "1.5-SNAPSHOT"
fabric-api = "0.100.4+1.21"
fabric-loom = "1.6-SNAPSHOT"

mixbox = "2.0.0"
word-wrap = "0.1.12"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion jitpack.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
jdk:
- openjdk17
- openjdk21
4 changes: 0 additions & 4 deletions src/main/java/net/krlite/equator/render/frame/FrameInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
* Provides access to the screen and window properties.
*/
public class FrameInfo {
public static float tickDelta() {
return MinecraftClient.getInstance().getTickDelta();
}

public static Box scaled() {
return new Box(Vector.fromCartesian(MinecraftClient.getInstance().getWindow().getScaledWidth(), MinecraftClient.getInstance().getWindow().getScaledHeight()));
}
Expand Down
30 changes: 12 additions & 18 deletions src/main/java/net/krlite/equator/render/renderer/Flat.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ private enum State {
UNABLE(null, null),
COLOR(VertexFormats.POSITION_COLOR, GameRenderer::getPositionColorProgram),
TEXTURE(VertexFormats.POSITION_TEXTURE, GameRenderer::getPositionTexProgram),
COLOR_TEXTURE(VertexFormats.POSITION_COLOR_TEXTURE, GameRenderer::getPositionColorTexProgram);
TEXTURE_COLOR(VertexFormats.POSITION_TEXTURE_COLOR, GameRenderer::getPositionTexColorProgram);

private final @Nullable VertexFormat vertexFormat;
private final @Nullable Supplier<ShaderProgram> shaderProgram;
Expand Down Expand Up @@ -307,7 +307,7 @@ private AccurateColor assertColor(AccurateColor color) {

private State state() {
if (hasColor() && hasTexture())
return State.COLOR_TEXTURE;
return State.TEXTURE_COLOR;
else if (hasColor())
return State.COLOR;
else if (hasTexture())
Expand All @@ -321,15 +321,12 @@ else if (hasTexture())
private void renderVertex(BufferBuilder builder, Matrix4f matrix, Vector vertex, Vector uv, AccurateColor color, float z) {
switch (state()) {
case COLOR -> builder.vertex(matrix, (float) vertex.x(), (float) vertex.y(), z)
.color(color.redAsFloat(), color.greenAsFloat(), color.blueAsFloat(), color.opacityAsFloat())
.next();
.color(color.redAsFloat(), color.greenAsFloat(), color.blueAsFloat(), color.opacityAsFloat());
case TEXTURE -> builder.vertex(matrix, (float) vertex.x(), (float) vertex.y(), z)
.texture((float) uv.x(), (float) uv.y())
.next();
case COLOR_TEXTURE -> builder.vertex(matrix, (float) vertex.x(), (float) vertex.y(), z)
.color(color.redAsFloat(), color.greenAsFloat(), color.blueAsFloat(), color.opacityAsFloat())
.texture((float) uv.x(), (float) uv.y())
.next();
.texture((float) uv.x(), (float) uv.y());
case TEXTURE_COLOR -> builder.vertex(matrix, (float) vertex.x(), (float) vertex.y(), z)
.texture((float) uv.x(), (float) uv.y())
.color(color.redAsFloat(), color.greenAsFloat(), color.blueAsFloat(), color.opacityAsFloat());
}
}

Expand All @@ -346,10 +343,8 @@ private void renderNormal() {
RenderSystem.setShaderTexture(0, Objects.requireNonNull(texture()).identifier());
}

BufferBuilder builder = Tessellator.getInstance().getBuffer();
Matrix4f matrix = matrixStack().peek().getPositionMatrix();

builder.begin(VertexFormat.DrawMode.TRIANGLE_STRIP, state().vertexFormat());
BufferBuilder builder = Tessellator.getInstance().begin(VertexFormat.DrawMode.TRIANGLE_STRIP, state().vertexFormat());

double xDelta, yDelta;

Expand Down Expand Up @@ -1352,8 +1347,7 @@ public double eccentricity() {

private void renderVertex(BufferBuilder builder, Matrix4f matrix, Vector vertex, AccurateColor color, float z) {
builder.vertex(matrix, (float) vertex.x(), (float) vertex.y(), z)
.color(color.redAsFloat(), color.greenAsFloat(), color.blueAsFloat(), color.opacityAsFloat())
.next();
.color(color.redAsFloat(), color.greenAsFloat(), color.blueAsFloat(), color.opacityAsFloat());
}

private void renderInnerVertex(BufferBuilder builder, Matrix4f matrix, double offset, AccurateColor color, float z) {
Expand Down Expand Up @@ -1402,15 +1396,15 @@ public void render() {
RenderSystem.setShader(GameRenderer::getPositionColorProgram);
RenderSystem.disableCull(); // Prevents triangles from being culled

BufferBuilder builder = Tessellator.getInstance().getBuffer();
BufferBuilder builder;
Matrix4f matrix = matrixStack().peek().getPositionMatrix();

if (outline() == VertexProvider.NONE) { // Full circle
builder.begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR);
builder = Tessellator.getInstance().begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR);

renderVertex(builder, matrix, box().center(), colorCenter(), z());
} else { // Ring
builder.begin(VertexFormat.DrawMode.TRIANGLE_STRIP, VertexFormats.POSITION_COLOR);
builder = Tessellator.getInstance().begin(VertexFormat.DrawMode.TRIANGLE_STRIP, VertexFormats.POSITION_COLOR);
}

for (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.client.util.math.MatrixStack;

public class VanillaWidgets {
/*
public static class Button {
public enum State implements Cyclic.Enum<State> {
UNAVAILABLE,
Expand All @@ -35,6 +36,8 @@ public static void render(DrawContext context, Box box, State state) {
}
}
*/

public static class Tooltip {
public static void render(DrawContext context, Box box) {
Box bleed = box.expand(-1);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/krlite/equator/test/CanvasScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected void init() {

@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
renderBackground(context);
renderBackground(context, mouseX, mouseY, delta);

//VanillaWidgets.Tooltip.render(context, box);

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/krlite/equator/visual/texture/Texture.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ public static Texture fromIdentifier(Identifier texture) {
}

public static Texture fromNamespacePath(String namespace, String... paths) {
return new Texture(new Identifier(namespace, combinePaths(paths)));
return new Texture(Identifier.of(namespace, combinePaths(paths)));
}

public static Texture fromPath(String... paths) {
return new Texture(new Identifier(combinePaths(paths)));
return new Texture(Identifier.of(combinePaths(paths)));
}

protected Texture(Identifier identifier, Box uvBox, boolean flippedX, boolean flippedY) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"depends": {
"fabricloader": "*",
"fabric-api": "*",
"minecraft": "1.20.x"
"minecraft": "1.21.x"
},
"suggests": {
"immediatelyfast": "*"
Expand Down

0 comments on commit 22b67c9

Please sign in to comment.