Skip to content

Commit

Permalink
Merge branch '1.21' into VF16
Browse files Browse the repository at this point in the history
  • Loading branch information
thr3343 committed Oct 5, 2024
2 parents 6eeb144 + 3adda56 commit 1ee2e01
Show file tree
Hide file tree
Showing 98 changed files with 2,412 additions and 2,165 deletions.
20 changes: 9 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,26 @@ jobs:
matrix:
# Use these Java versions
java: [
17, # Current Java LTS & minimum supported by Minecraft
21, # Current Java LTS
]
# and run on both Linux and Windows
os: [ubuntu-20.04, windows-2022]
runs-on: ${{ matrix.os }}
runs-on: ubuntu-22.04
steps:
- name: checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
uses: gradle/wrapper-validation-action@v2
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'microsoft'
- name: make gradle wrapper executable
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew
- name: build
run: ./gradlew build
- name: capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v2
if: ${{ matrix.java == '21' }} # Only upload artifacts built from latest java
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/libs/
path: build/libs/
81 changes: 38 additions & 43 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,48 +1,17 @@
plugins {
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'fabric-loom' version '1.6.11'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

project.ext.lwjglVersion = "3.3.2"
project.ext.jomlVersion = "1.10.4"
project.ext.winNatives = "natives-windows"
project.ext.linuxNatives = "natives-linux"
project.ext.macosNatives = "natives-macos"
project.ext.macosArmNatives = "natives-macos-arm64"

dependencies {
include(implementation("org.lwjgl:lwjgl-vulkan:$lwjglVersion"))

include(implementation("org.lwjgl:lwjgl-vma:$lwjglVersion"))
include(runtimeOnly("org.lwjgl:lwjgl-vma:$lwjglVersion:$winNatives"))
include(runtimeOnly("org.lwjgl:lwjgl-vma:$lwjglVersion:$linuxNatives"))
include(runtimeOnly("org.lwjgl:lwjgl-vma:$lwjglVersion:$macosNatives"))
include(runtimeOnly("org.lwjgl:lwjgl-vma:$lwjglVersion:$macosArmNatives"))

include(implementation("org.lwjgl:lwjgl-shaderc:$lwjglVersion"))
include(runtimeOnly("org.lwjgl:lwjgl-shaderc:$lwjglVersion:$winNatives"))
include(runtimeOnly("org.lwjgl:lwjgl-shaderc:$lwjglVersion:$linuxNatives"))
include(runtimeOnly("org.lwjgl:lwjgl-shaderc:$lwjglVersion:$macosNatives"))
include(runtimeOnly("org.lwjgl:lwjgl-shaderc:$lwjglVersion:$macosArmNatives"))

//MoltenVK
include(runtimeOnly("org.lwjgl:lwjgl-vulkan:$lwjglVersion:$macosNatives"))
include(runtimeOnly("org.lwjgl:lwjgl-vulkan:$lwjglVersion:$macosArmNatives"))
base {
archivesName = project.archives_base_name
}

repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
loom {
accessWidenerPath = file("src/main/resources/vulkanmod.accesswidener")
}

dependencies {
Expand All @@ -67,6 +36,32 @@ dependencies {
includeModule("fabric-rendering-v1")
}

project.ext.lwjglVersion = "3.3.3"
project.ext.jomlVersion = "1.10.4"
project.ext.winNatives = "natives-windows"
project.ext.linuxNatives = "natives-linux"
project.ext.macosNatives = "natives-macos"
project.ext.macosArmNatives = "natives-macos-arm64"

dependencies {
include(implementation("org.lwjgl:lwjgl-vulkan:$lwjglVersion"))

ext.includeNatives = { name ->
include(implementation("$name:$lwjglVersion"))
include(runtimeOnly("$name:$lwjglVersion:$winNatives"))
include(runtimeOnly("$name:$lwjglVersion:$linuxNatives"))
include(runtimeOnly("$name:$lwjglVersion:$macosNatives"))
include(runtimeOnly("$name:$lwjglVersion:$macosArmNatives"))
}

includeNatives("org.lwjgl:lwjgl-vma")
includeNatives("org.lwjgl:lwjgl-shaderc")

//MoltenVK
include(runtimeOnly("org.lwjgl:lwjgl-vulkan:$lwjglVersion:$macosNatives"))
include(runtimeOnly("org.lwjgl:lwjgl-vulkan:$lwjglVersion:$macosArmNatives"))
}

processResources {
inputs.property "version", project.version

Expand All @@ -76,30 +71,30 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 17
}

loom {
accessWidenerPath = file("src/main/resources/vulkanmod.accesswidener")
it.options.release = 21
}

java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
rename { "${it}_${project.base.archivesName.get()}"}
}
}

// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
create("mavenJava", MavenPublication) {
artifactId = project.archives_base_name
from components.java
}
}
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.7
minecraft_version=1.21
yarn_mappings=1.21+build.1
loader_version=0.16.5

#Fabric api
fabric_version=0.96.4+1.20.4
# Fabric API
fabric_version=0.102.0+1.21

# Mod Properties
mod_version = 0.4.6_dev
mod_version = 0.4.8_dev
maven_group = net.vulkanmod
archives_base_name = VulkanMod_1.20.4
archives_base_name = VulkanMod_1.21
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
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.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
108 changes: 68 additions & 40 deletions src/main/java/net/vulkanmod/config/gui/GuiRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
public abstract class GuiRenderer {

public static Minecraft minecraft;
public static GuiGraphics guiGraphics;
public static Font font;

public static GuiGraphics guiGraphics;
public static PoseStack pose;


public static BufferBuilder bufferBuilder;
public static boolean batching = false;

public static void setPoseStack(PoseStack poseStack) {
pose = poseStack;
}
Expand Down Expand Up @@ -52,57 +54,65 @@ public static void fill(float x0, float y0, float x1, float y1, int color) {
public static void fill(float x0, float y0, float x1, float y1, float z, int color) {
Matrix4f matrix4f = pose.last().pose();

float a = (float)FastColor.ARGB32.alpha(color) / 255.0F;
float r = (float)FastColor.ARGB32.red(color) / 255.0F;
float g = (float)FastColor.ARGB32.green(color) / 255.0F;
float b = (float)FastColor.ARGB32.blue(color) / 255.0F;

BufferBuilder bufferBuilder = Tesselator.getInstance().getBuilder();
float a = (float) FastColor.ARGB32.alpha(color) / 255.0F;
float r = (float) FastColor.ARGB32.red(color) / 255.0F;
float g = (float) FastColor.ARGB32.green(color) / 255.0F;
float b = (float) FastColor.ARGB32.blue(color) / 255.0F;

RenderSystem.setShader(GameRenderer::getPositionColorShader);
bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
bufferBuilder.vertex(matrix4f, x0, y0, z).color(r, g, b, a).endVertex();
bufferBuilder.vertex(matrix4f, x0, y1, z).color(r, g, b, a).endVertex();
bufferBuilder.vertex(matrix4f, x1, y1, z).color(r, g, b, a).endVertex();
bufferBuilder.vertex(matrix4f, x1, y0, z).color(r, g, b, a).endVertex();
Tesselator.getInstance().end();
}

public static void renderBoxBorder(float x0, float y0, float width, float height, float borderWidth, int color) {
renderBorder(x0, y0, x0 + width, y0 + height, borderWidth, color);
}
if (!batching)
bufferBuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);

public static void renderBorder(float x0, float y0, float x1, float y1, float width, int color) {
GuiRenderer.fill(x0, y0, x1, y0 + width, color);
GuiRenderer.fill(x0, y1 - width, x1, y1, color);
bufferBuilder.addVertex(matrix4f, x0, y0, z).setColor(r, g, b, a);
bufferBuilder.addVertex(matrix4f, x0, y1, z).setColor(r, g, b, a);
bufferBuilder.addVertex(matrix4f, x1, y1, z).setColor(r, g, b, a);
bufferBuilder.addVertex(matrix4f, x1, y0, z).setColor(r, g, b, a);

GuiRenderer.fill(x0, y0 + width, x0 + width, y1 - width, color);
GuiRenderer.fill(x1 - width, y0 + width, x1, y1 - width, color);
if (!batching)
BufferUploader.drawWithShader(bufferBuilder.buildOrThrow());
}

public static void fillGradient(float x0, float y0, float x1, float y1, int color1, int color2) {
fillGradient(x0, y0, x1, y1, 0, color1, color2);
}

public static void fillGradient(float x0, float y0, float x1, float y1, float z, int color1, int color2) {
float a1 = (float)FastColor.ARGB32.alpha(color1) / 255.0F;
float r1 = (float)FastColor.ARGB32.red(color1) / 255.0F;
float g1 = (float)FastColor.ARGB32.green(color1) / 255.0F;
float b1 = (float)FastColor.ARGB32.blue(color1) / 255.0F;
float a2 = (float)FastColor.ARGB32.alpha(color2) / 255.0F;
float r2 = (float)FastColor.ARGB32.red(color2) / 255.0F;
float g2 = (float)FastColor.ARGB32.green(color2) / 255.0F;
float b2 = (float)FastColor.ARGB32.blue(color2) / 255.0F;
float a1 = (float) FastColor.ARGB32.alpha(color1) / 255.0F;
float r1 = (float) FastColor.ARGB32.red(color1) / 255.0F;
float g1 = (float) FastColor.ARGB32.green(color1) / 255.0F;
float b1 = (float) FastColor.ARGB32.blue(color1) / 255.0F;
float a2 = (float) FastColor.ARGB32.alpha(color2) / 255.0F;
float r2 = (float) FastColor.ARGB32.red(color2) / 255.0F;
float g2 = (float) FastColor.ARGB32.green(color2) / 255.0F;
float b2 = (float) FastColor.ARGB32.blue(color2) / 255.0F;

Matrix4f matrix4f = pose.last().pose();

BufferBuilder bufferBuilder = Tesselator.getInstance().getBuilder();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
bufferBuilder.vertex(matrix4f, x0, y0, z).color(r1, g1, b1, a1).endVertex();
bufferBuilder.vertex(matrix4f, x0, y1, z).color(r2, g2, b2, a2).endVertex();
bufferBuilder.vertex(matrix4f, x1, y1, z).color(r2, g2, b2, a2).endVertex();
bufferBuilder.vertex(matrix4f, x1, y0, z).color(r1, g1, b1, a1).endVertex();
Tesselator.getInstance().end();

if (!batching)
bufferBuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);

bufferBuilder.addVertex(matrix4f, x0, y0, z).setColor(r1, g1, b1, a1);
bufferBuilder.addVertex(matrix4f, x0, y1, z).setColor(r2, g2, b2, a2);
bufferBuilder.addVertex(matrix4f, x1, y1, z).setColor(r2, g2, b2, a2);
bufferBuilder.addVertex(matrix4f, x1, y0, z).setColor(r1, g1, b1, a1);

if (!batching)
BufferUploader.drawWithShader(bufferBuilder.buildOrThrow());
}

public static void renderBoxBorder(float x0, float y0, float width, float height, float borderWidth, int color) {
renderBorder(x0, y0, x0 + width, y0 + height, borderWidth, color);
}

public static void renderBorder(float x0, float y0, float x1, float y1, float width, int color) {
GuiRenderer.fill(x0, y0, x1, y0 + width, color);
GuiRenderer.fill(x0, y1 - width, x1, y1, color);

GuiRenderer.fill(x0, y0 + width, x0 + width, y1 - width, color);
GuiRenderer.fill(x1 - width, y0 + width, x1, y1 - width, color);
}

public static void drawString(Font font, Component component, int x, int y, int color) {
Expand All @@ -113,19 +123,37 @@ public static void drawString(Font font, FormattedCharSequence formattedCharSequ
guiGraphics.drawString(font, formattedCharSequence, x, y, color);
}

public static void drawString(Font font, Component component, int x, int y, int color, boolean shadow) {
drawString(font, component.getVisualOrderText(), x, y, color, shadow);
}

public static void drawString(Font font, FormattedCharSequence formattedCharSequence, int x, int y, int color, boolean shadow) {
guiGraphics.drawString(font, formattedCharSequence, x, y, color, shadow);
}

public static void drawCenteredString(Font font, Component component, int x, int y, int color) {
FormattedCharSequence formattedCharSequence = component.getVisualOrderText();
guiGraphics.drawString(font, formattedCharSequence, x - font.width(formattedCharSequence) / 2, y, color);
}

public static int getMaxTextWidth(Font font, List<FormattedCharSequence> list) {
int maxWidth = 0;
for(var text : list) {
for (var text : list) {
int width = font.width(text);
if (width > maxWidth) {
maxWidth = width;
}
}
return maxWidth;
}

public static void beginBatch(VertexFormat.Mode mode, VertexFormat format) {
bufferBuilder = Tesselator.getInstance().begin(mode, format);
batching = true;
}

public static void endBatch() {
BufferUploader.drawWithShader(bufferBuilder.buildOrThrow());
batching = false;
}
}
Loading

0 comments on commit 1ee2e01

Please sign in to comment.