Skip to content

Commit

Permalink
port work
Browse files Browse the repository at this point in the history
  • Loading branch information
ix0rai committed May 7, 2024
1 parent 91cf5df commit b751fec
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 71 deletions.
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "fabric-loom" version "1.5.+"
id "com.github.johnrengelman.shadow" version "7.1.2"
id "fabric-loom" version "1.6.+"
id "com.github.johnrengelman.shadow" version "7.1.+"
id "com.modrinth.minotaur" version "2.+"
}

Expand All @@ -25,7 +25,6 @@ dependencies {
mappings("org.quiltmc:quilt-mappings:${project.minecraft_version}+build.${project.quilt_mappings}:intermediary-v2")
modImplementation("net.fabricmc:fabric-loader:${project.loader_version}")

include(modImplementation("dev.lambdaurora:spruceui:${project.spruceui_version}"))
modImplementation("com.terraformersmc:modmenu:${project.mod_menu_version}")

Set<String> apiModules = [
Expand Down
9 changes: 4 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ org.gradle.jvmargs=-Xmx1G

# minecraft, mappings and loader dependencies
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.20.4
minecraft_version=1.20.6
quilt_mappings=3
loader_version=0.15.7

# mod properties
mod_version=1.2.0+mc1.20.4
mod_version=1.2.0+mc1.20.6
maven_group=rainglow
archives_base_name=rainglow

# other dependencies
java_version=17
spruceui_version=5.0.3+1.20.4
java_version=21
mod_menu_version=9.0.0
fabric_api_version=0.96.4+1.20.4
fabric_api_version=0.97.8+1.20.6
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.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
17 changes: 9 additions & 8 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -144,15 +145,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -201,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
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
15 changes: 8 additions & 7 deletions src/main/java/io/ix0rai/rainglow/config/CustomModeScreen.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
package io.ix0rai.rainglow.config;

import dev.lambdaurora.spruceui.Position;
import dev.lambdaurora.spruceui.option.SpruceBooleanOption;
import dev.lambdaurora.spruceui.option.SpruceOption;
import dev.lambdaurora.spruceui.option.SpruceSimpleActionOption;
import dev.lambdaurora.spruceui.widget.container.SpruceOptionListWidget;
import io.ix0rai.rainglow.Rainglow;
import io.ix0rai.rainglow.data.RainglowColour;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.option.SimpleOptionsScreen;
import org.jetbrains.annotations.Nullable;

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

public class CustomModeScreen extends RainglowScreen {
public class CustomModeScreen extends SimpleOptionsScreen {
private final SpruceOption clearOption;
private final SpruceOption saveOption;
private final SpruceBooleanOption[] colourToggles = new SpruceBooleanOption[RainglowColour.values().length];
private final boolean[] toggleStates = new boolean[RainglowColour.values().length];

public CustomModeScreen(@Nullable Screen parent) {
super(parent, Rainglow.translatableText("config.title"));
super(parent, MinecraftClient.getInstance().options, Rainglow.translatableText("config.title"),

);

// todo subclass option to allow saving via a save button
// ephemeral value, not saved until a specific method is called (will happen on save pressed)

// create toggles for each colour
for (int i = 0; i < RainglowColour.values().length; i ++) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.ix0rai.rainglow.config;

import net.minecraft.client.option.Option;

public class DeferredSaveOption<T> extends Option<T> {
private final T deferredValue;
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
package io.ix0rai.rainglow.config;

import dev.lambdaurora.spruceui.Position;
import dev.lambdaurora.spruceui.option.SpruceBooleanOption;
import dev.lambdaurora.spruceui.option.SpruceCyclingOption;
import dev.lambdaurora.spruceui.option.SpruceIntegerInputOption;
import dev.lambdaurora.spruceui.option.SpruceOption;
import dev.lambdaurora.spruceui.option.SpruceSimpleActionOption;
import dev.lambdaurora.spruceui.widget.SpruceLabelWidget;
import dev.lambdaurora.spruceui.widget.container.SpruceOptionListWidget;
import io.ix0rai.rainglow.Rainglow;
import io.ix0rai.rainglow.data.RainglowColour;
import io.ix0rai.rainglow.data.RainglowEntity;
import io.ix0rai.rainglow.data.RainglowMode;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.option.Option;
import net.minecraft.client.toast.SystemToast;
import net.minecraft.client.toast.Toast;
import net.minecraft.text.Style;
Expand All @@ -39,6 +32,7 @@ public class RainglowConfigScreen extends RainglowScreen {

public RainglowConfigScreen(@Nullable Screen parent) {
super(parent, Rainglow.translatableText("config.title"));
Option.ofBoolean()
this.mode = Rainglow.CONFIG.getMode();

// mode option cycles through available modes
Expand Down Expand Up @@ -171,7 +165,7 @@ private SpruceLabelWidget createColourListLabel(String translationKey, RainglowM
}

private static void sendConfigLockedToast() {
Toast toast = new SystemToast(SystemToast.C_ozahoshp.field_47585, Rainglow.translatableText("config.server_locked_title"), Rainglow.translatableText("config.server_locked_description"));
Toast toast = new SystemToast(SystemToast.Id.PACK_LOAD_FAILURE, Rainglow.translatableText("config.server_locked_title"), Rainglow.translatableText("config.server_locked_description"));
MinecraftClient.getInstance().getToastManager().add(toast);
}
}
24 changes: 0 additions & 24 deletions src/main/java/io/ix0rai/rainglow/config/RainglowScreen.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected AllayEntityMixin(EntityType<? extends AllayEntity> entityType, World w

@Inject(method = "initDataTracker", at = @At("TAIL"))
protected void initDataTracker(CallbackInfo ci) {
this.getDataTracker().startTracking(Rainglow.getTrackedColourData(RainglowEntity.ALLAY), RainglowColour.BLUE.getId());
this.getDataTracker().set(Rainglow.getTrackedColourData(RainglowEntity.ALLAY), RainglowColour.BLUE.getId());
}

@Inject(method = "writeCustomDataToNbt", at = @At("TAIL"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import io.ix0rai.rainglow.Rainglow;
import io.ix0rai.rainglow.data.RainglowColour;
import io.ix0rai.rainglow.data.RainglowEntity;
import net.minecraft.client.render.entity.AllayRenderer;
import net.minecraft.client.render.entity.AllayEntityRenderer;
import net.minecraft.entity.passive.AllayEntity;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(AllayRenderer.class)
@Mixin(AllayEntityRenderer.class)
public class AllayEntityRendererMixin {

@Inject(method = "getTexture*", at = @At("HEAD"), cancellable = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void createParticle(DefaultParticleType defaultParticleType, ClientWorld
rgb = RainglowColour.WHITE.getInkRgb();
}

cir.setReturnValue(new SquidInkParticle(clientWorld, d, e, f, g, h, i, ColorUtil.ARGB32.getArgb(255, (int) rgb.r(), (int) rgb.g(), (int) rgb.b()), this.spriteProvider));
cir.setReturnValue(new SquidInkParticle(clientWorld, d, e, f, g, h, i, ColorUtil.Argb32.of(255, (int) rgb.r(), (int) rgb.g(), (int) rgb.b()), this.spriteProvider));
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/rainglow.accesswidener
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
accessWidener v1 named

accessible class net/minecraft/client/particle/GlowParticle$GlowFactory
extendable class net/minecraft/client/option/Option

accessible method net/minecraft/client/particle/GlowParticle <init> (Lnet/minecraft/client/world/ClientWorld;DDDDDDLnet/minecraft/client/particle/SpriteProvider;)V
accessible field net/minecraft/client/particle/GlowParticle RANDOM Lnet/minecraft/util/random/RandomGenerator;
Expand Down

0 comments on commit b751fec

Please sign in to comment.