Skip to content

Commit

Permalink
Independence from clothconfig on neoforge
Browse files Browse the repository at this point in the history
  • Loading branch information
dima-dencep committed Jan 16, 2024
1 parent 7e94f09 commit 26366d8
Show file tree
Hide file tree
Showing 21 changed files with 395 additions and 167 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ jobs:
game-versions: |
${{ steps.read_property.outputs.minecraft_version }}
dependencies: |
cloth-config
java: |
17
Expand Down
2 changes: 0 additions & 2 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ loom {

dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.loader_version}"

modImplementation "me.shedaniel.cloth:cloth-config:${rootProject.cloth_config_version}"
}

jar {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.github.dimadencep.mods.rrls;

import com.github.dimadencep.mods.rrls.config.AprilFool;
import com.github.dimadencep.mods.rrls.config.HideType;
import com.github.dimadencep.mods.rrls.config.ShowIn;
import com.github.dimadencep.mods.rrls.config.Type;
import dev.architectury.injectables.annotations.ExpectPlatform;

public class ConfigExpectPlatform {
@ExpectPlatform
public static HideType hideType() {
throw new AssertionError();
}

@ExpectPlatform
public static boolean rgbProgress() {
throw new AssertionError();
}

@ExpectPlatform
public static boolean forceClose() {
throw new AssertionError();
}

@ExpectPlatform
public static ShowIn showIn() {
throw new AssertionError();
}

@ExpectPlatform
public static Type type() {
throw new AssertionError();
}

@ExpectPlatform
public static String reloadText() {
throw new AssertionError();
}

@ExpectPlatform
public static boolean resetResources() {
throw new AssertionError();
}

@ExpectPlatform
public static boolean reInitScreen() {
throw new AssertionError();
}

@ExpectPlatform
public static boolean earlyPackStatusSend() {
throw new AssertionError();
}

@ExpectPlatform
public static float animationSpeed() {
throw new AssertionError();
}

@ExpectPlatform
public static AprilFool aprilFool() {
throw new AssertionError();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
package com.github.dimadencep.mods.rrls;

import com.github.dimadencep.mods.rrls.accessor.SplashAccessor;
import com.github.dimadencep.mods.rrls.config.ModConfig;
import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Overlay;
import org.apache.logging.log4j.LogManager;
Expand All @@ -23,8 +20,8 @@
import java.util.Optional;

public class Rrls {
public static final ModConfig MOD_CONFIG = AutoConfig.register(ModConfig.class, Toml4jConfigSerializer::new).get();
public static final Logger LOGGER = LogManager.getLogger("rrls");
public static final String MOD_ID = "rrls";
public static final Logger LOGGER = LogManager.getLogger(MOD_ID);

@Nullable
public static Overlay tryGetOverlay() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

package com.github.dimadencep.mods.rrls.accessor;

import com.github.dimadencep.mods.rrls.Rrls;
import com.github.dimadencep.mods.rrls.ConfigExpectPlatform;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.MessageScreen;
import net.minecraft.client.gui.screen.Screen;
Expand Down Expand Up @@ -38,10 +38,10 @@ public interface SplashAccessor {
}

default AttachType rrls$filterAttachType(Screen screen, boolean reloading) {
if (!Rrls.MOD_CONFIG.hideType.canHide(reloading))
if (!ConfigExpectPlatform.hideType().canHide(reloading))
return AttachType.DEFAULT;

if (reloading || Rrls.MOD_CONFIG.forceClose)
if (reloading ||ConfigExpectPlatform.forceClose())
return AttachType.HIDE;

if (screen instanceof MessageScreen msg) // Loading Minecraft
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.github.dimadencep.mods.rrls.config;

import java.util.Calendar;

public enum AprilFool {
ON_APRIL,
ALWAYS,
DISABLED;

private static Calendar calendar;

public boolean canUes() {
if (this == ALWAYS)
return true;

try {
if (this == ON_APRIL) {
if (calendar == null) {
calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
}

return calendar.get(Calendar.MONTH) == Calendar.APRIL && calendar.get(Calendar.DAY_OF_MONTH) == 1;
}
} catch (Throwable ignored) {
}

return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.github.dimadencep.mods.rrls.config;

public enum HideType {
ALL,
LOADING,
RELOADING,
NONE;

public boolean canHide(boolean reloading) {
if (this == NONE) return false;

if (this == ALL) return true;

if (reloading) {
return this == RELOADING;
} else {
return this == LOADING;
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.github.dimadencep.mods.rrls.config;

public enum ShowIn {
DISABLED,
ONLY_GAME,
ONLY_GUI,
ALL;

public boolean canShow(boolean isGame) {
if (this == DISABLED) return false;

if (this == ALL) return true;

if (isGame) {
return this == ONLY_GAME;
} else {
return this == ONLY_GUI;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.github.dimadencep.mods.rrls.config;

public enum Type {
PROGRESS,
TEXT
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

package com.github.dimadencep.mods.rrls.mixins;

import com.github.dimadencep.mods.rrls.ConfigExpectPlatform;
import com.github.dimadencep.mods.rrls.Rrls;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Overlay;
Expand Down Expand Up @@ -41,7 +42,7 @@ public abstract class MinecraftClientMixin {
cancellable = true
)
public void rrls$forceClose(CallbackInfoReturnable<Boolean> cir) {
if (Rrls.MOD_CONFIG.forceClose)
if (ConfigExpectPlatform.forceClose())
cir.setReturnValue(true);
}

Expand All @@ -53,7 +54,7 @@ public abstract class MinecraftClientMixin {
cancellable = true
)
public void rrls$onResourceReloadFailure(Throwable exception, Text resourceName, MinecraftClient.LoadingContext loadingContext, CallbackInfo ci) {
if (!Rrls.MOD_CONFIG.resetResources) {
if (!ConfigExpectPlatform.resetResources()) {
Rrls.LOGGER.error("Caught error loading resourcepacks!", exception);

this.reloadResources(true, loadingContext).thenRun(() -> this.showResourceReloadFailureToast(resourceName));
Expand Down

0 comments on commit 26366d8

Please sign in to comment.