Skip to content

Commit

Permalink
Multiversion and too much other stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterCheezeCake committed Nov 7, 2024
1 parent a2a178f commit 57cdd2d
Show file tree
Hide file tree
Showing 74 changed files with 1,242 additions and 463 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ jobs:
- name: make gradle wrapper executable
run: chmod +x ./gradlew
- name: build
run: ./gradlew build
run: ./gradlew chiseledBuild
- name: capture build artifacts
if: ${{ matrix.java == '21' }} # Only upload artifacts built from latest java
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/libs/
path: versions/**/build/libs/*.jar
8 changes: 6 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
id("fabric-loom") version "1.7-SNAPSHOT"
id("fabric-loom") version "1.8-SNAPSHOT"
id("maven-publish")
}

version = property("mod_version")!!
version = property("mod_version")!! as String + "+mc" + property("minecraft_version")!!
group = property("maven_group")!!

base {
Expand All @@ -24,6 +24,7 @@ repositories {
includeGroup("net.azureaaron")
}
}
maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1")
}

dependencies {
Expand All @@ -34,6 +35,8 @@ dependencies {
modImplementation ("dev.isxander:yet-another-config-lib:${property("yacl_version")}")
modImplementation ("com.terraformersmc:modmenu:${property("modmenu_version")}")
include(modImplementation("net.azureaaron:hm-api:${property("hmapi_version")}") as Any)
modRuntimeOnly("me.djtheredstoner:DevAuth-fabric:1.2.1")


}
tasks.processResources {
Expand All @@ -55,6 +58,7 @@ java {
}

tasks.named<Jar>("jar") {

from("LICENSE") {
rename { "${it}_${project.base.archivesName.get()}" }
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ archives_base_name=SkyblockTweaks
loader_version=0.16.7

# Mod Properties
mod_version=0.1.0-Alpha.7
mod_version=0.1.0-Alpha.8
# mod_version = Unstable


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.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# 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
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -246,4 +249,4 @@ eval "set -- $(
tr '\n' ' '
)" '"$@"'

exec "$JAVACMD" "$@"
exec "$JAVACMD" "$@"
4 changes: 3 additions & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -89,4 +91,4 @@ exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
:omega
4 changes: 2 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ stonecutter {
centralScript = "build.gradle.kts"

create(rootProject) {
versions("1.21.1", "1.21.2")
vcsVersion = "1.21.2"
versions("1.21.1", "1.21.3")
vcsVersion = "1.21.3"
}
}
17 changes: 13 additions & 4 deletions src/main/java/wtf/cheeze/sbt/SkyblockTweaks.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package wtf.cheeze.sbt;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import net.fabricmc.api.ModInitializer;

import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
Expand All @@ -32,33 +33,42 @@

import wtf.cheeze.sbt.command.SBTCommand;
import wtf.cheeze.sbt.config.SBTConfig;
import wtf.cheeze.sbt.config.migration.BarColorTransformation;
import wtf.cheeze.sbt.config.migration.MigrationManager;
import wtf.cheeze.sbt.config.persistent.PersistentData;
import wtf.cheeze.sbt.features.chat.ChatProtections;
import wtf.cheeze.sbt.features.chat.PartyFeatures;
import wtf.cheeze.sbt.features.huds.*;
import wtf.cheeze.sbt.utils.*;
import wtf.cheeze.sbt.utils.actionbar.ActionBarTransformer;
import wtf.cheeze.sbt.utils.hud.HUD;
import wtf.cheeze.sbt.hud.HUD;
import wtf.cheeze.sbt.utils.skyblock.ModAPIUtils;
import wtf.cheeze.sbt.utils.skyblock.ProfileManager;
import wtf.cheeze.sbt.utils.skyblock.SkyblockData;

import java.util.ArrayList;

public class SkyblockTweaks implements ModInitializer {
public static final Gson GSON = new Gson();
public static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
public static final Logger LOGGER = LoggerFactory.getLogger("SkyblockTweaks");
public static final SkyblockData DATA = new SkyblockData();
public static final PersistentData PD = PersistentData.load();
public static final ArrayList<HUD> HUDS = new ArrayList<HUD>();
public static final Version VERSION = new Version(Version.VersionType.ALPHA, 0, 1, 0, 7);
public static final Version VERSION = new Version(Version.VersionType.ALPHA, 0, 1, 0, 8);
public static final MinecraftClient mc = MinecraftClient.getInstance();


@Override
public void onInitialize() {

MigrationManager.handleMigrations();


SBTConfig.HANDLER.load();

MigrationManager.runTransformation(BarColorTransformation.INSTANCE);


HUDS.add(SkillHUDManager.INSTANCE.SKILL_HUD);
HUDS.add(SkillHUDManager.INSTANCE.SKILL_BAR);

Expand All @@ -81,7 +91,6 @@ public void onInitialize() {

HUDS.add(new TickerHUD());


HudRenderCallback.EVENT.register((context, tickCounter) -> {
HUDS.forEach(hud -> hud.render(context, false));
});
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/wtf/cheeze/sbt/command/SBTCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import wtf.cheeze.sbt.utils.NumberUtils;
import wtf.cheeze.sbt.utils.skyblock.SkyblockConstants;
import wtf.cheeze.sbt.utils.skyblock.SkyblockUtils;
import wtf.cheeze.sbt.utils.hud.HudScreen;
import wtf.cheeze.sbt.hud.HudScreen;

import java.util.Arrays;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/wtf/cheeze/sbt/config/ConfigImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import wtf.cheeze.sbt.utils.Version;
import wtf.cheeze.sbt.utils.actionbar.ActionBarTransformer;

public class ConfigImpl {
public class ConfigImpl extends VersionedObject {
@SerialEntry // This defines the spec version of the config, so that in the future, migration code can be written if necessary
public int configVersion = 1;

Expand Down
16 changes: 12 additions & 4 deletions src/main/java/wtf/cheeze/sbt/config/SBTConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,19 @@
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import wtf.cheeze.sbt.config.categories.*;
import wtf.cheeze.sbt.utils.hud.HudLine;
import wtf.cheeze.sbt.hud.utils.DrawMode;

import java.nio.file.Path;


public class SBTConfig {

public static final Path PATH = FabricLoader.getInstance().getConfigDir().resolve("skyblocktweaks-config.json");

public static final ConfigClassHandler<ConfigImpl> HANDLER = ConfigClassHandler.createBuilder(ConfigImpl.class)
.id(Identifier.of("skyblocktweaks", "config"))
.serializer(config -> GsonConfigSerializerBuilder.create(config).appendGsonBuilder(builder -> builder.setFieldNamingPolicy(FieldNamingPolicy.IDENTITY))
.setPath(FabricLoader.getInstance().getConfigDir().resolve("skyblocktweaks-config.json"))
.setPath(PATH)
.build())
.build();
public static Screen getScreen(Screen parent) {
Expand Down Expand Up @@ -78,6 +82,10 @@ public static Huds huds() {
return get().huds;
}

public static void override(ConfigImpl config) {

}



public static ControllerBuilder generateBooleanController(Option<Boolean> opt) {
Expand All @@ -89,8 +97,8 @@ public static FloatSliderControllerBuilder generateScaleController(Option<Float>
.step(0.1f);
}

public static EnumControllerBuilder<HudLine.DrawMode> generateDrawModeController(Option<HudLine.DrawMode> opt) {
return EnumControllerBuilder.create(opt).enumClass(HudLine.DrawMode.class);
public static EnumControllerBuilder<DrawMode> generateDrawModeController(Option<DrawMode> opt) {
return EnumControllerBuilder.create(opt).enumClass(DrawMode.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import net.minecraft.util.Identifier;
import wtf.cheeze.sbt.SkyblockTweaks;
import wtf.cheeze.sbt.utils.render.RenderUtils;
import wtf.cheeze.sbt.utils.hud.HudScreen;
import wtf.cheeze.sbt.hud.HudScreen;

public class SkyblockTweaksScreenMain extends Screen {
public static final Identifier ICON = Identifier.of("skyblocktweaks", "icon.png");
Expand Down Expand Up @@ -94,8 +94,8 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
MinecraftClient mc = MinecraftClient.getInstance();
var centerX = mc.getWindow().getScaledWidth() / 2;
super.render(context, mouseX, mouseY, delta);
RenderUtils.drawCenteredString(context, Text.literal("SkyblockTweaks"), centerX, 3, 3658595, true, 2.5f);
RenderUtils.drawCenteredString(context, Text.literal("v" + SkyblockTweaks.VERSION.getVersionString()), centerX, 25, 0xFFFFFF, true);
RenderUtils.drawCenteredString(context, Text.literal("By MisterCheezeCake"), centerX, 36, 16733525, true);
RenderUtils.drawCenteredText(context, Text.literal("SkyblockTweaks"), centerX, 3, 3658595, true, 2.5f);
RenderUtils.drawCenteredText(context, Text.literal("v" + SkyblockTweaks.VERSION.getVersionString()), centerX, 25, 0xFFFFFF, true);
RenderUtils.drawCenteredText(context, Text.literal("By MisterCheezeCake"), centerX, 36, 16733525, true);
}
}
5 changes: 5 additions & 0 deletions src/main/java/wtf/cheeze/sbt/config/VersionedObject.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package wtf.cheeze.sbt.config;

public class VersionedObject {
public int configVersion;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package wtf.cheeze.sbt.config.migration;

import net.minecraft.util.Identifier;
import wtf.cheeze.sbt.config.ConfigImpl;
import wtf.cheeze.sbt.utils.render.Colors;

import java.util.function.Function;


/**
* In mod versions prior to 0.1.0-Alpha.8, bar colors (all colors actually), defaulted to RGB ints.
* This was fine pre 1.21.2 since the shader system was used, which was fine with RGB ints
* However, in 1.21.2, the shader system was tweaked, and we moved to the color parameter in {@link net.minecraft.client.gui.DrawContext#drawTexture(Function, Identifier, int, int, float, float, int, int, int, int, int)}
* This method interprets ints as ARGB, not RGB, which resulted in the bars not rendering with default settings due to the alpha value being 0
* YACL always treated the color as ARGB, so this issue only affects users who never modified the settings
* This transformation checks for the old defaults and updates them to the new defaults
*/
public class BarColorTransformation implements ConfigTransformation<ConfigImpl> {

private static final int OLD_HEALTH = 16733525;
private static final int OLD_HEALTH_ABSORB = 16755200;
private static final int OLD_MANA = 5592575;
private static final int OLD_SKILL = 43690;
private static final int OLD_DRILL = 43520;

private BarColorTransformation() {}

public static final BarColorTransformation INSTANCE = new BarColorTransformation();

@Override
public ConfigImpl tranform(ConfigImpl config) {
if (config.huds.healthBar.color == OLD_HEALTH) config.huds.healthBar.color = Colors.RED;
if (config.huds.healthBar.colorAbsorption == OLD_HEALTH_ABSORB) config.huds.healthBar.colorAbsorption = Colors.ORANGE;
if (config.huds.manaBar.color == OLD_MANA) config.huds.manaBar.color = Colors.BLUE;
if (config.huds.skillBar.color == OLD_SKILL) config.huds.skillBar.color = Colors.CYAN;
if (config.huds.drillFuelBar.color == OLD_DRILL) config.huds.drillFuelBar.color = Colors.GREEN;

return config;
}

@Override
public boolean isApplicable(ConfigImpl config) {
return config.huds.healthBar.color == OLD_HEALTH
|| config.huds.healthBar.colorAbsorption == OLD_HEALTH_ABSORB
|| config.huds.manaBar.color == OLD_MANA
|| config.huds.skillBar.color == OLD_SKILL
|| config.huds.drillFuelBar.color == OLD_DRILL;
}

@Override
public boolean isApplicable(int configVersion) {
return configVersion == 1;
}


}
23 changes: 23 additions & 0 deletions src/main/java/wtf/cheeze/sbt/config/migration/ConfigMigration.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package wtf.cheeze.sbt.config.migration;


/**
* A ConfigMigration migrates a config object from one version to another.
* These should be used instead of Transformations when the actual structure
* of the config changes, as opposed to simply needing to modify certain values.
* A ConfigMigration will always be accompanied by an increase in the config version
*/
public interface ConfigMigration<Source, Target> {


Source migrate(Target config);

boolean isApplicable(int aVersion);

int getTargetVersion();
int getSourceVersion();

Class<Source> getSourceClass();
Class<Target> getTargetClass();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package wtf.cheeze.sbt.config.migration;

/**
* A ConfigTransformation transforms a single version of a config, rather than migrating from one version to another.
*/
public interface ConfigTransformation<T>{

T tranform(T config);

boolean isApplicable(T config);

boolean isApplicable(int configVersion);
}
Loading

0 comments on commit 57cdd2d

Please sign in to comment.