Skip to content

Commit

Permalink
Update to 1.21 (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 authored Jul 22, 2024
1 parent 9b3351a commit ce88580
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 63 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id 'fabric-loom' version '1.1.+'
id 'io.github.juuxel.loom-quiltflower' version '1.8.+'
id 'fabric-loom' version '1.7.+'
id 'java-library'
id 'maven-publish'
}
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
org.gradle.jvmargs = -Xmx1G

#Fabric properties
minecraft_version = 1.19.4
quilt_mappings = 7
loader_version = 0.14.18
minecraft_version = 1.21
quilt_mappings = 2
loader_version = 0.15.11

#Mod properties
mod_version = 1.2.0
mod_version = 1.2.1
maven_group = io.github.queerbric
archives_base_name = pridelib

#Dependencies
fabric_api_version = 0.76.0+1.19.4
fabric_api_version = 0.100.4+1.21
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-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions src/main/java/io/github/queerbric/pride/PrideFlag.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public class PrideFlag {
protected PrideFlag(String id, Properties props) {
this.id = id;
if (props.shape == null) {
this.shapeId = new Identifier("pride", "horizontal_stripes");
this.shapeId = Identifier.of("pride", "horizontal_stripes");
} else {
this.shapeId = props.shape.contains(":") ? Identifier.tryParse(props.shape) : new Identifier("pride", props.shape);
this.shapeId = props.shape.contains(":") ? Identifier.tryParse(props.shape) : Identifier.of("pride", props.shape);
}

this.shape = PrideFlagShapes.get(this.shapeId);
Expand Down
105 changes: 54 additions & 51 deletions src/main/java/io/github/queerbric/pride/PrideFlagShapes.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package io.github.queerbric.pride;

import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.Tessellator;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.mojang.blaze3d.vertex.VertexFormats;
import com.mojang.blaze3d.vertex.*;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.unmapped.C_fpcijbbg;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import org.joml.Matrix4f;
Expand All @@ -28,61 +27,58 @@ private PrideFlagShapes() {

static {
PrideFlagShape horizStripes;
register(new Identifier("pride", "horizontal_stripes"), horizStripes = (colors, matrices, x, y, w, h) -> {
register(Identifier.of("pride", "horizontal_stripes"), horizStripes = (colors, matrices, x, y, w, h) -> {
float sh = h / colors.size();
Matrix4f mat = matrices.peek().getModel();
MatrixStack.Entry mat = matrices.peek();
Tessellator t = Tessellator.getInstance();
BufferBuilder bb = t.getBufferBuilder();
bb.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
BufferBuilder bb = t.method_60827(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
for (int i = 0; i < colors.size(); i++) {
int color = colors.getInt(i);
float r = ((color >> 16) & 0xFF) / 255f;
float g = ((color >> 8) & 0xFF) / 255f;
float b = ((color >> 0) & 0xFF) / 255f;
bb.vertex(mat, x, y + sh, 0).color(r, g, b, 1).next();
bb.vertex(mat, x + w, y + sh, 0).color(r, g, b, 1).next();
bb.vertex(mat, x + w, y, 0).color(r, g, b, 1).next();
bb.vertex(mat, x, y, 0).color(r, g, b, 1).next();
bb.method_56824(mat, x, y + sh, 0).method_22915(r, g, b, 1);
bb.method_56824(mat, x + w, y + sh, 0).method_22915(r, g, b, 1);
bb.method_56824(mat, x + w, y, 0).method_22915(r, g, b, 1);
bb.method_56824(mat, x, y, 0).method_22915(r, g, b, 1);
y += sh;
}
t.draw();
drawAndClear(bb, t);
});
register(new Identifier("pride", "vertical_stripes"), (colors, matrices, x, y, w, h) -> {
register(Identifier.of("pride", "vertical_stripes"), (colors, matrices, x, y, w, h) -> {
float sw = w / colors.size();
Matrix4f mat = matrices.peek().getModel();
MatrixStack.Entry mat = matrices.peek();
Tessellator t = Tessellator.getInstance();
BufferBuilder bb = t.getBufferBuilder();
bb.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
BufferBuilder bb = t.method_60827(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
for (int i = 0; i < colors.size(); i++) {
int color = colors.getInt(i);
float r = ((color >> 16) & 0xFF) / 255f;
float g = ((color >> 8) & 0xFF) / 255f;
float b = ((color >> 0) & 0xFF) / 255f;
bb.vertex(mat, x, y + h, 0).color(r, g, b, 1).next();
bb.vertex(mat, x + sw, y + h, 0).color(r, g, b, 1).next();
bb.vertex(mat, x + sw, y, 0).color(r, g, b, 1).next();
bb.vertex(mat, x, y, 0).color(r, g, b, 1).next();
bb.method_56824(mat, x, y + h, 0).method_22915(r, g, b, 1);
bb.method_56824(mat, x + sw, y + h, 0).method_22915(r, g, b, 1);
bb.method_56824(mat, x + sw, y, 0).method_22915(r, g, b, 1);
bb.method_56824(mat, x, y, 0).method_22915(r, g, b, 1);
x += sw;
}
t.draw();
drawAndClear(bb, t);
});
register(new Identifier("pride", "circle"), (colors, matrices, x, y, w, h) -> {
Matrix4f mat = matrices.peek().getModel();
register(Identifier.of("pride", "circle"), (colors, matrices, x, y, w, h) -> {
MatrixStack.Entry mat = matrices.peek();
Tessellator tess = Tessellator.getInstance();
BufferBuilder bb = tess.getBufferBuilder();
{
BufferBuilder bb = tess.method_60827(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
int color = colors.getInt(0);
float r = ((color >> 16) & 0xFF) / 255f;
float g = ((color >> 8) & 0xFF) / 255f;
float b = ((color >> 0) & 0xFF) / 255f;
bb.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
bb.vertex(mat, x, y + h, 0).color(r, g, b, 1).next();
bb.vertex(mat, x + w, y + h, 0).color(r, g, b, 1).next();
bb.vertex(mat, x + w, y, 0).color(r, g, b, 1).next();
bb.vertex(mat, x, y, 0).color(r, g, b, 1).next();
tess.draw();
bb.method_56824(mat, x, y + h, 0).method_22915(r, g, b, 1);
bb.method_56824(mat, x + w, y + h, 0).method_22915(r, g, b, 1);
bb.method_56824(mat, x + w, y, 0).method_22915(r, g, b, 1);
bb.method_56824(mat, x, y, 0).method_22915(r, g, b, 1);
drawAndClear(bb, tess);
}
bb.begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR);
BufferBuilder bb = tess.method_60827(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR);
float br = Math.min(w, h) * 0.3f;
float cx = x + (w / 2);
float cy = y + (h / 2);
Expand All @@ -92,32 +88,31 @@ private PrideFlagShapes() {
float r = ((color >> 16) & 0xFF) / 255f;
float g = ((color >> 8) & 0xFF) / 255f;
float b = ((color >> 0) & 0xFF) / 255f;
bb.vertex(mat, cx, cy, 0).color(r, g, b, 1).next();
bb.method_56824(mat, cx, cy, 0).method_22915(r, g, b, 1);
for (int i = 0; i < 65; i++) {
float t = (i / 64f);
final float TAU = (float) (Math.PI * 2);
bb.vertex(mat, cx + (MathHelper.sin(t * TAU) * rd), cy + (MathHelper.cos(t * TAU) * rd), 0).color(r, g, b, 1).next();
bb.method_56824(mat, cx + (MathHelper.sin(t * TAU) * rd), cy + (MathHelper.cos(t * TAU) * rd), 0).method_22915(r, g, b, 1);
}
}
tess.draw();
drawAndClear(bb, tess);
});
register(new Identifier("pride", "arrow"), (colors, matrices, x, y, w, h) -> {
register(Identifier.of("pride", "arrow"), (colors, matrices, x, y, w, h) -> {
float s = Math.min(w, h) / 2;
float cy = y + (h / 2);
horizStripes.render(colors.subList(1, colors.size()), matrices, x, y, w, h);
Matrix4f mat = matrices.peek().getModel();
MatrixStack.Entry mat = matrices.peek();
Tessellator t = Tessellator.getInstance();
BufferBuilder bb = t.getBufferBuilder();
bb.begin(VertexFormat.DrawMode.TRIANGLES, VertexFormats.POSITION_COLOR);
BufferBuilder bb = t.method_60827(VertexFormat.DrawMode.TRIANGLES, VertexFormats.POSITION_COLOR);
int color = colors.getInt(0);
float r = ((color >> 16) & 0xFF) / 255f;
float g = ((color >> 8) & 0xFF) / 255f;
float b = ((color >> 0) & 0xFF) / 255f;
bb.vertex(mat, x, cy + s, 0).color(r, g, b, 1).next();
bb.method_56824(mat, x, cy + s, 0).method_22915(r, g, b, 1);
// yes, 1.5. the demisexual flag triangle appears to not be equilateral?
bb.vertex(mat, x + (s * 1.5f), cy, 0).color(r, g, b, 1).next();
bb.vertex(mat, x, cy - s, 0).color(r, g, b, 1).next();
t.draw();
bb.method_56824(mat, x + (s * 1.5f), cy, 0).method_22915(r, g, b, 1);
bb.method_56824(mat, x, cy - s, 0).method_22915(r, g, b, 1);
drawAndClear(bb, t);
});
var progressBg = new IntArrayList(new int[]{
0xD40606,
Expand All @@ -127,14 +122,14 @@ private PrideFlagShapes() {
0x001A98,
0x760089,
});
register(new Identifier("pride", "progress"), (colors, matrices, x, y, w, h) -> {
register(Identifier.of("pride", "progress"), (colors, matrices, x, y, w, h) -> {
float hm = Math.min(w, h) / 2;
float cy = y + (h / 2);
Matrix4f mat = matrices.peek().getModel();
MatrixStack.Entry mat = matrices.peek();
Tessellator t = Tessellator.getInstance();
BufferBuilder bb = t.getBufferBuilder();
BufferBuilder bb = t.method_60827(VertexFormat.DrawMode.TRIANGLES, VertexFormats.POSITION_COLOR);

horizStripes.render(progressBg, matrices, x, y, w, h);
bb.begin(VertexFormat.DrawMode.TRIANGLES, VertexFormats.POSITION_COLOR);
int[] triangleColors = {
0x000000,
0x603813,
Expand All @@ -147,12 +142,20 @@ private PrideFlagShapes() {
float r = ((color >> 16) & 0xFF) / 255f;
float g = ((color >> 8) & 0xFF) / 255f;
float b = ((color >> 0) & 0xFF) / 255f;
bb.vertex(mat, x, cy + s, 0).color(r, g, b, 1).next();
bb.vertex(mat, x + (s * 1.1f), cy, 0).color(r, g, b, 1).next();
bb.vertex(mat, x, cy - s, 0).color(r, g, b, 1).next();
bb.method_56824(mat, x, cy + s, 0).method_22915(r, g, b, 1);
bb.method_56824(mat, x + (s * 1.1f), cy, 0).method_22915(r, g, b, 1);
bb.method_56824(mat, x, cy - s, 0).method_22915(r, g, b, 1);
s -= hm / 6;
}
t.draw();
drawAndClear(bb, t);
});
}

private static void drawAndClear(BufferBuilder builder, Tessellator tessellator) {
C_fpcijbbg builtBuffer = builder.method_60794();
if (builtBuffer != null) {
BufferRenderer.drawWithShader(builtBuffer);
}
tessellator.method_60828();
}
}
4 changes: 2 additions & 2 deletions src/main/java/io/github/queerbric/pride/PrideLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.regex.Pattern;

public class PrideLoader implements SimpleResourceReloadListener<List<PrideFlag>> {
private static final Identifier ID = new Identifier("pride", "flags");
private static final Identifier ID = Identifier.of("pride", "flags");
private static final Logger LOGGER = LogManager.getLogger("pride");
private static final Gson GSON = new Gson();
private static final Pattern HEX_COLOR_PATTERN = Pattern.compile("^#[0-9a-fA-F]{6}$");
Expand Down Expand Up @@ -87,7 +87,7 @@ public static List<PrideFlag> loadFlags(ResourceManager manager) {
LOGGER.warn("[pride] Malformed flag data for pride.json config");
}
} else {
var id = new Identifier("pride", "flags.json");
var id = Identifier.of("pride", "flags.json");

Optional<Resource> resource = manager.getResource(id);
if (resource.isPresent()) {
Expand Down

0 comments on commit ce88580

Please sign in to comment.