Skip to content

Commit

Permalink
Switch mappings.
Browse files Browse the repository at this point in the history
  • Loading branch information
LambdAurora committed Jul 23, 2024
1 parent 9812fd0 commit c55e73c
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 48 deletions.
17 changes: 13 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("fabric-loom") version "1.7.+"
id("fabric-loom") version "1.6.+"
`java-library`
`maven-publish`
}
Expand All @@ -14,15 +14,24 @@ val targetJavaVersion = 21

repositories {
maven {
name = "Quilt"
url = uri("https://maven.quiltmc.org/repository/release")
name = "Gegy"
url = uri("https://maven.gegy.dev/releases/")
}
maven {
name = "ParchmentMC"
url = uri("https://maven.parchmentmc.org")
}
mavenLocal()
}

dependencies {
minecraft("com.mojang:minecraft:${minecraftVersion}")
@Suppress("UnstableApiUsage")
mappings("org.quiltmc:quilt-mappings:${minecraftVersion}+build.${project.property("quilt_mappings")}:intermediary-v2")
mappings(loom.layered {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${minecraftVersion}:${project.property("parchment_version")}@zip")
mappings("dev.lambdaurora:yalmm:${minecraftVersion}+build.${project.property("yalmm_version")}")
})
modImplementation("net.fabricmc:fabric-loader:${project.property("loader_version")}")

modImplementation(fabricApi.module("fabric-resource-loader-v0", project.property("fabric_api_version") as String))
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ org.gradle.jvmargs = -Xmx1G

#Fabric properties
minecraft_version = 1.21
quilt_mappings = 2
yalmm_version = 4
parchment_version = 2024.07.07
loader_version = 0.15.11

#Mod properties
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/github/queerbric/pride/PrideClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.minecraft.resource.ResourceType;
import net.minecraft.resources.io.ResourceType;

@Environment(EnvType.CLIENT)
public class PrideClient implements ClientModInitializer {
Expand Down
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
@@ -1,12 +1,12 @@
package io.github.queerbric.pride;

import com.mojang.blaze3d.vertex.MatrixStack;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.ints.IntLists;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
import net.minecraft.resources.Identifier;

/**
* Represents a pride flag.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.github.queerbric.pride;

import com.mojang.blaze3d.vertex.MatrixStack;
import it.unimi.dsi.fastutil.ints.IntList;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.util.math.MatrixStack;

public interface PrideFlagShape {
@Environment(EnvType.CLIENT)
Expand Down
65 changes: 31 additions & 34 deletions src/main/java/io/github/queerbric/pride/PrideFlagShapes.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
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.resources.Identifier;
import net.minecraft.util.math.MathHelper;
import org.joml.Matrix4f;

import java.util.Map;

Expand All @@ -31,16 +28,16 @@ private PrideFlagShapes() {
float sh = h / colors.size();
MatrixStack.Entry mat = matrices.peek();
Tessellator t = Tessellator.getInstance();
BufferBuilder bb = t.method_60827(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
BufferBuilder bb = t.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.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.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);
bb.addVertex(mat, x, y + sh, 0).setColor(r, g, b, 1);
bb.addVertex(mat, x + w, y + sh, 0).setColor(r, g, b, 1);
bb.addVertex(mat, x + w, y, 0).setColor(r, g, b, 1);
bb.addVertex(mat, x, y, 0).setColor(r, g, b, 1);
y += sh;
}
drawAndClear(bb, t);
Expand All @@ -49,16 +46,16 @@ private PrideFlagShapes() {
float sw = w / colors.size();
MatrixStack.Entry mat = matrices.peek();
Tessellator t = Tessellator.getInstance();
BufferBuilder bb = t.method_60827(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
BufferBuilder bb = t.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.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.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);
bb.addVertex(mat, x, y + h, 0).setColor(r, g, b, 1);
bb.addVertex(mat, x + sw, y + h, 0).setColor(r, g, b, 1);
bb.addVertex(mat, x + sw, y, 0).setColor(r, g, b, 1);
bb.addVertex(mat, x, y, 0).setColor(r, g, b, 1);
x += sw;
}
drawAndClear(bb, t);
Expand All @@ -67,18 +64,18 @@ private PrideFlagShapes() {
MatrixStack.Entry mat = matrices.peek();
Tessellator tess = Tessellator.getInstance();
{
BufferBuilder bb = tess.method_60827(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
BufferBuilder bb = tess.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.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.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);
bb.addVertex(mat, x, y + h, 0).setColor(r, g, b, 1);
bb.addVertex(mat, x + w, y + h, 0).setColor(r, g, b, 1);
bb.addVertex(mat, x + w, y, 0).setColor(r, g, b, 1);
bb.addVertex(mat, x, y, 0).setColor(r, g, b, 1);
drawAndClear(bb, tess);
}
BufferBuilder bb = tess.method_60827(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR);
BufferBuilder bb = tess.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR);
float br = Math.min(w, h) * 0.3f;
float cx = x + (w / 2);
float cy = y + (h / 2);
Expand All @@ -88,11 +85,11 @@ private PrideFlagShapes() {
float r = ((color >> 16) & 0xFF) / 255f;
float g = ((color >> 8) & 0xFF) / 255f;
float b = ((color >> 0) & 0xFF) / 255f;
bb.method_56824(mat, cx, cy, 0).method_22915(r, g, b, 1);
bb.addVertex(mat, cx, cy, 0).setColor(r, g, b, 1);
for (int i = 0; i < 65; i++) {
float t = (i / 64f);
final float TAU = (float) (Math.PI * 2);
bb.method_56824(mat, cx + (MathHelper.sin(t * TAU) * rd), cy + (MathHelper.cos(t * TAU) * rd), 0).method_22915(r, g, b, 1);
bb.addVertex(mat, cx + (MathHelper.sin(t * TAU) * rd), cy + (MathHelper.cos(t * TAU) * rd), 0).setColor(r, g, b, 1);
}
}
drawAndClear(bb, tess);
Expand All @@ -103,15 +100,15 @@ private PrideFlagShapes() {
horizStripes.render(colors.subList(1, colors.size()), matrices, x, y, w, h);
MatrixStack.Entry mat = matrices.peek();
Tessellator t = Tessellator.getInstance();
BufferBuilder bb = t.method_60827(VertexFormat.DrawMode.TRIANGLES, VertexFormats.POSITION_COLOR);
BufferBuilder bb = t.begin(VertexFormat.Mode.TRIANGLES, DefaultVertexFormat.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.method_56824(mat, x, cy + s, 0).method_22915(r, g, b, 1);
bb.addVertex(mat, x, cy + s, 0).setColor(r, g, b, 1);
// yes, 1.5. the demisexual flag triangle appears to not be equilateral?
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);
bb.addVertex(mat, x + (s * 1.5f), cy, 0).setColor(r, g, b, 1);
bb.addVertex(mat, x, cy - s, 0).setColor(r, g, b, 1);
drawAndClear(bb, t);
});
var progressBg = new IntArrayList(new int[]{
Expand All @@ -127,7 +124,7 @@ private PrideFlagShapes() {
float cy = y + (h / 2);
MatrixStack.Entry mat = matrices.peek();
Tessellator t = Tessellator.getInstance();
BufferBuilder bb = t.method_60827(VertexFormat.DrawMode.TRIANGLES, VertexFormats.POSITION_COLOR);
BufferBuilder bb = t.begin(VertexFormat.Mode.TRIANGLES, DefaultVertexFormat.POSITION_COLOR);

horizStripes.render(progressBg, matrices, x, y, w, h);
int[] triangleColors = {
Expand All @@ -142,20 +139,20 @@ private PrideFlagShapes() {
float r = ((color >> 16) & 0xFF) / 255f;
float g = ((color >> 8) & 0xFF) / 255f;
float b = ((color >> 0) & 0xFF) / 255f;
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);
bb.addVertex(mat, x, cy + s, 0).setColor(r, g, b, 1);
bb.addVertex(mat, x + (s * 1.1f), cy, 0).setColor(r, g, b, 1);
bb.addVertex(mat, x, cy - s, 0).setColor(r, g, b, 1);
s -= hm / 6;
}
drawAndClear(bb, t);
});
}

private static void drawAndClear(BufferBuilder builder, Tessellator tessellator) {
C_fpcijbbg builtBuffer = builder.method_60794();
if (builtBuffer != null) {
BufferRenderer.drawWithShader(builtBuffer);
MeshData meshData = builder.build();
if (meshData != null) {
BufferUploader.drawWithShader(meshData);
}
tessellator.method_60828();
tessellator.clear();
}
}
10 changes: 5 additions & 5 deletions src/main/java/io/github/queerbric/pride/PrideLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.google.gson.Gson;
import net.fabricmc.fabric.api.resource.SimpleResourceReloadListener;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.resource.Resource;
import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier;
import net.minecraft.resources.Identifier;
import net.minecraft.resources.io.Resource;
import net.minecraft.resources.io.ResourceManager;
import net.minecraft.util.profiler.Profiler;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -50,9 +50,9 @@ public static List<PrideFlag> loadFlags(ResourceManager manager) {
var flags = new ArrayList<PrideFlag>();

outer:
for (var entry : manager.findResources("flags", path -> path.getPath().endsWith(".json")).entrySet()) {
for (var entry : manager.findResources("flags", path -> path.path().endsWith(".json")).entrySet()) {
Identifier id = entry.getKey();
String[] parts = id.getPath().split("/");
String[] parts = id.path().split("/");
String name = parts[parts.length - 1];
name = name.substring(0, name.length() - 5);

Expand Down

0 comments on commit c55e73c

Please sign in to comment.