Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# User-specific stuff
.idea/
.ai
MCVR-Repo/

*.iml
*.ipr
Expand Down Expand Up @@ -124,4 +126,4 @@ core.lib
libnvidia-ngx-dlss*
include/
shaders/
libxess*
libxess*
37 changes: 34 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.11-SNAPSHOT'
id 'fabric-loom' version '1.8.13'
id 'maven-publish'
}

Expand Down Expand Up @@ -40,6 +40,10 @@ repositories {
mavenCentral()
}

configurations {
shade
}

dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
Expand All @@ -50,7 +54,7 @@ dependencies {

// https://mvnrepository.com/artifact/org.yaml/snakeyaml
implementation "org.yaml:snakeyaml:2.5"
include "org.yaml:snakeyaml:2.5"
shade "org.yaml:snakeyaml:2.5"
}

processResources {
Expand All @@ -66,7 +70,7 @@ processResources {
}
}

def targetJavaVersion = 21
def targetJavaVersion = 17
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
Expand All @@ -93,6 +97,12 @@ jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}" }
}

from({
configurations.shade.collect { it.isDirectory() ? it : zipTree(it) }
}) {
exclude "META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA"
}
}

tasks.named("remapJar") {
Expand All @@ -103,6 +113,27 @@ tasks.named("remapSourcesJar") {
archiveFileName.set("${project.archives_base_name}-${project.version}-fabric-${project.minecraft_version}-sources.jar")
}

def stripArchiveCopyAction = { task ->
def filteredActions = task.actions.findAll { action ->
if (action.class.name != "org.gradle.api.internal.project.taskfactory.StandardTaskAction") {
return true
}

def methodField = action.class.getDeclaredField("method")
methodField.accessible = true
methodField.get(action).name != "copy"
}
task.setActions(filteredActions)
}

tasks.named("remapJar") {
stripArchiveCopyAction(delegate)
}

tasks.named("remapSourcesJar") {
stripArchiveCopyAction(delegate)
}

// configure the maven publication
publishing {
publications {
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
org.gradle.jvmargs=-Xmx2G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.8
loader_version=0.18.3
loom_version=1.14-SNAPSHOT
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.16.14
loom_version=1.8.13
# Mod Properties
mod_version=0.1.4-alpha
maven_group=com.radiance
archives_base_name=Radiance
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.119.4+1.21.4
fabric_version=0.92.5+1.20.1
5 changes: 2 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#Wed Mar 25 17:01:10 CET 2026
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
13 changes: 13 additions & 0 deletions src/main/java/com/radiance/client/RadianceClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.AccessDeniedException;
import java.nio.file.FileSystem;
import java.nio.file.FileSystemNotFoundException;
import java.nio.file.FileSystems;
Expand Down Expand Up @@ -98,6 +99,12 @@ public void copyFileFromResource(Path targetPath, Path resourcePath) {

Files.createDirectories(targetPath.getParent());
Files.copy(is, targetPath, StandardCopyOption.REPLACE_EXISTING);
} catch (AccessDeniedException e) {
if (Files.exists(targetPath)) {
LOGGER.warn("Using existing locked native/resource file {}", targetPath);
return;
}
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand All @@ -111,6 +118,12 @@ public void copyOptionalFileFromResource(Path targetPath, Path resourcePath) {

Files.createDirectories(targetPath.getParent());
Files.copy(is, targetPath, StandardCopyOption.REPLACE_EXISTING);
} catch (AccessDeniedException e) {
if (Files.exists(targetPath)) {
LOGGER.warn("Using existing locked optional file {}", targetPath);
return;
}
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down
32 changes: 6 additions & 26 deletions src/main/java/com/radiance/client/constant/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.Map;
import java.util.stream.Collectors;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.RenderPhase;
import net.minecraft.client.render.VertexFormat;

public class Constants {
Expand Down Expand Up @@ -102,8 +101,8 @@ public enum VertexFormats {
private static final Map<VertexFormat, Integer>
BY_VERTEX_FORMAT =
Collections.unmodifiableMap(Arrays.stream(values())
.collect(
Collectors.toMap(VertexFormats::getVertexFormat, VertexFormats::getValue)));
.collect(Collectors.toMap(VertexFormats::getVertexFormat,
VertexFormats::getValue, (existing, ignored) -> existing)));

private final VertexFormat vertexFormat;
private final int value;
Expand Down Expand Up @@ -166,30 +165,11 @@ public static GeometryTypes getGeometryType(RenderLayer renderLayer, boolean ref
return WORLD_SOLID;
}

if (multiPhase.isTranslucent()) {
if (multiPhase.name.contains("translucent") || multiPhase.name.contains("glint")
|| multiPhase.name.contains("lightning") || multiPhase.name.contains("crumbling")
|| multiPhase.name.contains("tripwire")) {
// transparent
if (RenderPhase.NO_TRANSPARENCY.equals(multiPhase.phases.transparency)) {
return WORLD_TRANSPARENT;
} else if (RenderPhase.ADDITIVE_TRANSPARENCY.equals(
multiPhase.phases.transparency)) {
return WORLD_TRANSPARENT;
} else if (RenderPhase.LIGHTNING_TRANSPARENCY.equals(
multiPhase.phases.transparency)) {
return WORLD_TRANSPARENT;
} else if (RenderPhase.GLINT_TRANSPARENCY.equals(multiPhase.phases.transparency)) {
return WORLD_TRANSPARENT;
} else if (RenderPhase.CRUMBLING_TRANSPARENCY.equals(
multiPhase.phases.transparency)) {
return WORLD_TRANSPARENT;
} else if (RenderPhase.OVERLAY_TRANSPARENCY.equals(
multiPhase.phases.transparency)) {
return WORLD_TRANSPARENT;
} else if (RenderPhase.TRANSLUCENT_TRANSPARENCY.equals(
multiPhase.phases.transparency)) {
return WORLD_TRANSPARENT;
} else {
throw new IllegalArgumentException("Invalid render layer " + multiPhase);
}
return WORLD_TRANSPARENT;
} else {
// cut out
return WORLD_TRANSPARENT;
Expand Down
146 changes: 4 additions & 142 deletions src/main/java/com/radiance/client/gui/ModuleAttributeScreen.java
Original file line number Diff line number Diff line change
@@ -1,167 +1,29 @@
package com.radiance.client.gui;

import com.radiance.client.pipeline.Module;
import com.radiance.client.pipeline.config.AttributeConfig;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.text.Text;

public class ModuleAttributeScreen extends Screen {

private static final int OK_BORDER = 0xFF34D058;
private static final int BAD_BORDER = 0xFFE5534B;
private static final int ROW_LEFT = 20;
private static final int ROW_RIGHT = 20;
private static final int WIDGET_WIDTH = 160;
private static final int VEC3_COMPONENT_WIDTH = 52;
private static final int VEC3_GAP = 2;

private static final int HEADER_HEIGHT = 32;
private static final String MODULE_ATTRIBUTE_SCREEN_NO_ATTRIBUTES = "module_attribute_screen.no_attributes";

private final Screen parent;
private final Module module;

private final List<Row> rows = new ArrayList<>();

private int scrollY = 0;

public ModuleAttributeScreen(Screen parent, Module module) {
super(Text.translatable(module.name));
this.parent = parent;
this.module = module;
}

@Override
protected void init() {
addDrawableChild(
ButtonWidget.builder(Text.translatable("Back"), button -> close())
.dimensions(10, 6, 60, 20)
.build());

rows.clear();

List<AttributeConfig> list = module.attributeConfigs;
if (list == null || list.isEmpty()) {
return;
}

for (AttributeConfig cfg : list) {
List<ClickableWidget> ws = AttributeWidgetUtil.buildWidgets(cfg, textRenderer, WIDGET_WIDTH,
VEC3_COMPONENT_WIDTH);
for (ClickableWidget w : ws) {
addDrawableChild(w);
}
rows.add(new Row(cfg, ws));
}
}

@Override
public void close() {
MinecraftClient.getInstance().setScreen(parent);
if (this.client != null) {
this.client.setScreen(this.parent);
}
}

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

context.drawTextWithShadow(textRenderer, Text.translatable(module.name), 10, HEADER_HEIGHT + 8, 0xFFEAEAEA);

if (rows.isEmpty()) {
context.drawTextWithShadow(textRenderer, MODULE_ATTRIBUTE_SCREEN_NO_ATTRIBUTES, 10, 60, 0xFFB0B0B0);
return;
}

int baseY = (HEADER_HEIGHT + 28) + scrollY;
int rowH = 22;

for (int i = 0; i < rows.size(); i++) {
Row row = rows.get(i);
int y = baseY + i * rowH;

boolean visible = y >= (HEADER_HEIGHT + 18) && y <= (this.height - 24);
if (visible) {
context.drawTextWithShadow(textRenderer, Text.translatable(row.cfg.name), ROW_LEFT, y + 6,
0xFFD0D0D0);
}

layoutRowWidgets(row, y);

String type = row.cfg.type == null ? "" : row.cfg.type.toLowerCase(Locale.ROOT);
boolean doBorder = AttributeWidgetUtil.shouldValidateBorder(type);

for (ClickableWidget w : row.widgets) {
w.visible = visible;
w.active = visible;

if (!doBorder) {
continue;
}

boolean ok = true;

if (type.equals("vec3")) {
if (w instanceof TextFieldWidget tf) {
ok = AttributeWidgetUtil.isStrictFloat(tf.getText());
}
} else if (type.equals("int")) {
if (w instanceof TextFieldWidget tf) {
ok = AttributeWidgetUtil.isStrictInt(tf.getText());
}
} else if (type.equals("float")) {
if (w instanceof TextFieldWidget tf) {
ok = AttributeWidgetUtil.isStrictFloat(tf.getText());
}
}

if (w instanceof TextFieldWidget tf) {
int c = ok ? OK_BORDER : BAD_BORDER;
AttributeWidgetUtil.drawBorder(context, tf.getX(), tf.getY(), tf.getWidth(), tf.getHeight(), c);
}
}
}
}

private void layoutRowWidgets(Row row, int y) {
int widgetWidth = AttributeWidgetUtil.totalWidgetWidth(row.widgets, WIDGET_WIDTH, VEC3_COMPONENT_WIDTH,
VEC3_GAP);
int x = this.width - ROW_RIGHT - widgetWidth;
AttributeWidgetUtil.layoutWidgets(row.widgets, x, y, WIDGET_WIDTH, VEC3_COMPONENT_WIDTH, VEC3_GAP);
}

@Override
public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmount, double verticalAmount) {
int rowH = 22;
int contentH = 60 + rows.size() * rowH + 20;
int minScroll = Math.min(0, this.height - contentH);

scrollY += (int) (verticalAmount * 10);
if (scrollY > 0) {
scrollY = 0;
}
if (scrollY < minScroll) {
scrollY = minScroll;
}
return true;
}

private static class Row {

private final AttributeConfig cfg;
private final List<ClickableWidget> widgets;

private Row(AttributeConfig cfg, List<ClickableWidget> widgets) {
this.cfg = cfg;
this.widgets = widgets;
}
}
}
Loading