dacl dependency & translation support
This commit is contained in:
11
build.gradle
11
build.gradle
@@ -12,9 +12,11 @@ base {
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = "Terraformers"
|
||||
url = "https://maven.terraformersmc.com/"
|
||||
}
|
||||
maven {
|
||||
url = "https://maven.kasetoatz.com/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -24,8 +26,8 @@ dependencies {
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}"
|
||||
modImplementation "com.kasetoatz:dumbassconfiglib:1.0"
|
||||
modCompileOnly "com.terraformersmc:modmenu:${project.modmenu_version}"
|
||||
modCompileOnly "com.kasetoatz:dacl:${project.dacl_version}"
|
||||
}
|
||||
|
||||
processResources {
|
||||
@@ -37,7 +39,8 @@ processResources {
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version,
|
||||
"minecraft_version": project.minecraft_version,
|
||||
"loader_version": project.loader_version
|
||||
"loader_version": project.loader_version,
|
||||
"dacl_version": project.dacl_version
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,4 +13,5 @@ archives_base_name=fastghast
|
||||
# Dependencies
|
||||
# check this on https://modmuss50.me/fabric.html
|
||||
fabric_version=0.136.0+1.21.10
|
||||
modmenu_version=16.0.0-rc.1
|
||||
modmenu_version=16.0.0-rc.1
|
||||
dacl_version=1.1
|
||||
@@ -7,5 +7,3 @@ pluginManagement {
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
includeBuild("../DumbassConfigLib")
|
||||
@@ -1,11 +1,8 @@
|
||||
package com.kasetoatz.fastghast;
|
||||
|
||||
import com.kasetoatz.dumbassconfig.DumbassConfig;
|
||||
import com.kasetoatz.dumbassconfig.options.BoolOption;
|
||||
import com.kasetoatz.dumbassconfig.options.FloatOption;
|
||||
import com.kasetoatz.dumbassconfig.options.validators.RangeValidator;
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
import com.kasetoatz.dacl.DumbassConfig;
|
||||
import com.kasetoatz.dacl.options.FloatOption;
|
||||
import com.kasetoatz.dacl.options.validators.RangeValidator;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||
import net.minecraft.entity.Leashable;
|
||||
@@ -15,19 +12,18 @@ import net.minecraft.text.Text;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import static com.kasetoatz.fastghast.config.Config.load;
|
||||
|
||||
public class Fastghast implements ModInitializer, ModMenuApi
|
||||
public class Fastghast implements ModInitializer
|
||||
{
|
||||
private final DumbassConfig config = DumbassConfig.builder(Text.of("TEST SCREEN"))
|
||||
.withOption(new BoolOption("Test Boolean Option", "test_bool_opt", false))
|
||||
.withOption(new FloatOption("Test Float Option", "test_float_opt", 1.F, new RangeValidator<>(0.F, null)))
|
||||
public static final FloatOption UNMOUNTED_SPEED = new FloatOption(Text.translatable("fastghast.speed.unmounted"), "unmounted-speed", 0.05F, new RangeValidator<>(0.F, null));
|
||||
public static final FloatOption MOUNTED_SPEED = new FloatOption(Text.translatable("fastghast.speed.mounted"), "mounted-speed", 0.15F, new RangeValidator<>(0.F, null));
|
||||
public static final DumbassConfig CONFIG = DumbassConfig.builder(Text.translatable("fastghast.config.title"), "fastghast.json")
|
||||
.withOption(UNMOUNTED_SPEED)
|
||||
.withOption(MOUNTED_SPEED)
|
||||
.build();
|
||||
|
||||
@Override
|
||||
public void onInitialize()
|
||||
{
|
||||
load();
|
||||
ServerTickEvents.END_SERVER_TICK.register((server) -> server.getWorlds().forEach(world -> world.iterateEntities().forEach(entity -> {
|
||||
if (entity instanceof Leashable leashed && leashed.isLeashed() && leashed.getLeashHolder() instanceof HappyGhastEntity ghast && leashed.getDistanceToCenter(ghast) > 8)
|
||||
{
|
||||
@@ -35,10 +31,4 @@ public class Fastghast implements ModInitializer, ModMenuApi
|
||||
}
|
||||
})));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory()
|
||||
{
|
||||
return this.config::getUI;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,62 +1,15 @@
|
||||
package com.kasetoatz.fastghast.config;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.util.crash.CrashException;
|
||||
import net.minecraft.util.crash.CrashReport;
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import static com.kasetoatz.fastghast.Fastghast.CONFIG;
|
||||
|
||||
public class Config
|
||||
public class Config implements ModMenuApi
|
||||
{
|
||||
public static double UNMOUNTED_SPEED = 0.05;
|
||||
public static double MOUNTED_SPEED = 0.15;
|
||||
|
||||
private static final Path FILE = FabricLoader.getInstance().getConfigDir().resolve("fastghast.json");
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
public static void load() {
|
||||
if (!Files.exists(FILE))
|
||||
{
|
||||
save();
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
String json = Files.readString(FILE);
|
||||
JsonObject data = GSON.fromJson(json, JsonObject.class);
|
||||
if (data.has("unmounted-speed"))
|
||||
{
|
||||
UNMOUNTED_SPEED = data.get("unmounted-speed").getAsDouble();
|
||||
}
|
||||
if (data.has("mounted-speed"))
|
||||
{
|
||||
MOUNTED_SPEED = data.get("mounted-speed").getAsDouble();
|
||||
}
|
||||
save();
|
||||
}
|
||||
catch (IOException exc)
|
||||
{
|
||||
throw new CrashException(CrashReport.create(exc, "Loading config file."));
|
||||
}
|
||||
}
|
||||
|
||||
private static void save()
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory()
|
||||
{
|
||||
try
|
||||
{
|
||||
JsonObject data = new JsonObject();
|
||||
data.addProperty("unmounted-speed", UNMOUNTED_SPEED);
|
||||
data.addProperty("mounted-speed", MOUNTED_SPEED);
|
||||
Files.writeString(FILE, GSON.toJson(data));
|
||||
}
|
||||
catch (IOException exc)
|
||||
{
|
||||
throw new CrashException(CrashReport.create(exc, "Saving config file."));
|
||||
}
|
||||
return CONFIG::getUI;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import static com.kasetoatz.fastghast.config.Config.MOUNTED_SPEED;
|
||||
import static com.kasetoatz.fastghast.config.Config.UNMOUNTED_SPEED;
|
||||
import static com.kasetoatz.fastghast.Fastghast.MOUNTED_SPEED;
|
||||
import static com.kasetoatz.fastghast.Fastghast.UNMOUNTED_SPEED;
|
||||
|
||||
@Mixin(HappyGhastEntity.class)
|
||||
public abstract class HappyGhastMixin
|
||||
@@ -22,6 +22,6 @@ public abstract class HappyGhastMixin
|
||||
@Redirect(method="travel", at=@At(value="INVOKE", target="Lnet/minecraft/entity/passive/HappyGhastEntity;getAttributeValue(Lnet/minecraft/registry/entry/RegistryEntry;)D"))
|
||||
public double speed(HappyGhastEntity instance, RegistryEntry<EntityAttribute> registryEntry)
|
||||
{
|
||||
return getControllingPassenger() instanceof PlayerEntity ? MOUNTED_SPEED : UNMOUNTED_SPEED;
|
||||
return getControllingPassenger() instanceof PlayerEntity ? MOUNTED_SPEED.getValue() : UNMOUNTED_SPEED.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
5
src/main/resources/assets/fastghast/lang/en_us.json
Normal file
5
src/main/resources/assets/fastghast/lang/en_us.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"fastghast.speed.unmounted": "Unmounted speed",
|
||||
"fastghast.speed.mounted": "Mounted speed",
|
||||
"fastghast.config.title": "FastGhast Config"
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
"com.kasetoatz.fastghast.Fastghast"
|
||||
],
|
||||
"modmenu": [
|
||||
"com.kasetoatz.fastghast.Fastghast"
|
||||
"com.kasetoatz.fastghast.config.Config"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
@@ -28,6 +28,7 @@
|
||||
"depends": {
|
||||
"fabricloader": ">=${loader_version}",
|
||||
"fabric": "*",
|
||||
"minecraft": "${minecraft_version}"
|
||||
"minecraft": "${minecraft_version}",
|
||||
"dacl": ">=${dacl_version}"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user