1 Commits

Author SHA1 Message Date
86f67529dc 1.21.11 2025-12-11 21:34:32 +01:00
9 changed files with 73 additions and 96 deletions

View File

@@ -10,24 +10,11 @@ base {
archivesName = project.archives_base_name archivesName = project.archives_base_name
} }
repositories {
maven {
url = "https://maven.terraformersmc.com/"
}
maven {
url = "https://maven.kasetoatz.com/"
}
}
dependencies { dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}" minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "com.kasetoatz:dacl:${project.dacl_version}"
modCompileOnly "com.terraformersmc:modmenu:${project.modmenu_version}"
} }
processResources { processResources {
@@ -39,17 +26,12 @@ processResources {
filesMatching("fabric.mod.json") { filesMatching("fabric.mod.json") {
expand "version": project.version, expand "version": project.version,
"minecraft_version": project.minecraft_version, "minecraft_version": project.minecraft_version,
"loader_version": project.loader_version, "loader_version": project.loader_version
"dacl_version": project.dacl_version
} }
} }
def targetJavaVersion = 21 def targetJavaVersion = 21
tasks.withType(JavaCompile).configureEach { 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
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8" it.options.encoding = "UTF-8"
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
it.options.release.set(targetJavaVersion) it.options.release.set(targetJavaVersion)
@@ -61,32 +43,5 @@ java {
if (JavaVersion.current() < javaVersion) { if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
} }
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar() withSourcesJar()
} }
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}" }
}
}
// configure the maven publication
publishing {
publications {
create("mavenJava", MavenPublication) {
artifactId = project.archives_base_name
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}

View File

@@ -2,16 +2,14 @@
org.gradle.jvmargs=-Xmx1G org.gradle.jvmargs=-Xmx1G
# Fabric Properties # Fabric Properties
# check these on https://modmuss50.me/fabric.html # check these on https://modmuss50.me/fabric.html
minecraft_version=1.21.10 minecraft_version=1.21.11
yarn_mappings=1.21.10+build.2 yarn_mappings=1.21.11+build.2
loader_version=0.17.3 loader_version=0.18.2
loom_version=1.13-SNAPSHOT loom_version=1.14-SNAPSHOT
# Mod Properties # Mod Properties
mod_version=1.3 mod_version=1.3
maven_group=com.kasetoatz maven_group=com.kasetoatz
archives_base_name=fastghast archives_base_name=fastghast
# Dependencies # Dependencies
# check this on https://modmuss50.me/fabric.html # check this on https://modmuss50.me/fabric.html
fabric_version=0.136.0+1.21.10 fabric_version=0.139.5+1.21.11
modmenu_version=16.0.0-rc.1
dacl_version=1.2

View File

@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

View File

@@ -1,29 +1,21 @@
package com.kasetoatz.fastghast; package com.kasetoatz.fastghast;
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.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.minecraft.entity.Leashable; import net.minecraft.entity.Leashable;
import net.minecraft.entity.passive.HappyGhastEntity; import net.minecraft.entity.passive.HappyGhastEntity;
import net.minecraft.network.packet.s2c.play.PositionFlag; import net.minecraft.network.packet.s2c.play.PositionFlag;
import net.minecraft.text.Text;
import java.util.EnumSet; import java.util.EnumSet;
public class Fastghast implements ModInitializer import static com.kasetoatz.fastghast.config.Config.load;
{
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();
public class FastGhast implements ModInitializer
{
@Override @Override
public void onInitialize() public void onInitialize()
{ {
load();
ServerTickEvents.END_SERVER_TICK.register((server) -> server.getWorlds().forEach(world -> world.iterateEntities().forEach(entity -> { 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) if (entity instanceof Leashable leashed && leashed.isLeashed() && leashed.getLeashHolder() instanceof HappyGhastEntity ghast && leashed.getDistanceToCenter(ghast) > 8)
{ {

View File

@@ -1,15 +1,62 @@
package com.kasetoatz.fastghast.config; package com.kasetoatz.fastghast.config;
import com.terraformersmc.modmenu.api.ConfigScreenFactory; import com.google.gson.Gson;
import com.terraformersmc.modmenu.api.ModMenuApi; 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 static com.kasetoatz.fastghast.Fastghast.CONFIG; import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
public class Config implements ModMenuApi public class Config
{ {
@Override public static double UNMOUNTED_SPEED = 0.05;
public ConfigScreenFactory<?> getModConfigScreenFactory() 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()
{ {
return CONFIG::getUI; 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."));
}
} }
} }

View File

@@ -11,8 +11,8 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.Redirect;
import static com.kasetoatz.fastghast.Fastghast.MOUNTED_SPEED; import static com.kasetoatz.fastghast.config.Config.MOUNTED_SPEED;
import static com.kasetoatz.fastghast.Fastghast.UNMOUNTED_SPEED; import static com.kasetoatz.fastghast.config.Config.UNMOUNTED_SPEED;
@Mixin(HappyGhastEntity.class) @Mixin(HappyGhastEntity.class)
public abstract class HappyGhastMixin 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")) @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) public double speed(HappyGhastEntity instance, RegistryEntry<EntityAttribute> registryEntry)
{ {
return getControllingPassenger() instanceof PlayerEntity ? MOUNTED_SPEED.getValue() : UNMOUNTED_SPEED.getValue(); return getControllingPassenger() instanceof PlayerEntity ? MOUNTED_SPEED : UNMOUNTED_SPEED;
} }
} }

View File

@@ -1,5 +0,0 @@
{
"fastghast.speed.unmounted": "Unmounted speed",
"fastghast.speed.mounted": "Mounted speed",
"fastghast.config.title": "FastGhast Config"
}

View File

@@ -3,23 +3,14 @@
"id": "fastghast", "id": "fastghast",
"version": "${version}", "version": "${version}",
"name": "FastGhast", "name": "FastGhast",
"description": "Mod that modifies the speed of the Happy Ghast", "description": "",
"authors": ["KaseToatz"], "authors": [],
"contact": { "contact": {},
"email": "kasetoatz@kasetoatz.com",
"homepage": "https://modrinth.com/mod/fastghast",
"issues": "https://git.kasetoatz.com/KaseToatz/FastGhast/issues",
"sources": "https://git.kasetoatz.com/KaseToatz/FastGhast"
},
"license": "MIT", "license": "MIT",
"icon": "icon.png",
"environment": "*", "environment": "*",
"entrypoints": { "entrypoints": {
"main": [ "main": [
"com.kasetoatz.fastghast.Fastghast" "com.kasetoatz.fastghast.FastGhast"
],
"modmenu": [
"com.kasetoatz.fastghast.config.Config"
] ]
}, },
"mixins": [ "mixins": [
@@ -28,7 +19,6 @@
"depends": { "depends": {
"fabricloader": ">=${loader_version}", "fabricloader": ">=${loader_version}",
"fabric": "*", "fabric": "*",
"minecraft": "${minecraft_version}", "minecraft": "${minecraft_version}"
"dacl": ">=${dacl_version}"
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB