Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d28ba934eb | |||
| 77628be954 | |||
| 7f478b9ad6 | |||
| 76ed28afeb | |||
| bd74bce522 | |||
| e421b1a5a0 | |||
| f9c0411e59 | |||
| f4f4337b39 | |||
| 9a6daaf25a |
19
build.gradle
19
build.gradle
@@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '1.11-SNAPSHOT'
|
id 'fabric-loom' version "${loom_version}"
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -10,13 +10,13 @@ base {
|
|||||||
archivesName = project.archives_base_name
|
archivesName = project.archives_base_name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
// Add repositories to retrieve artifacts from in here.
|
maven {
|
||||||
// You should only use this when depending on other mods because
|
url = "https://maven.terraformersmc.com/"
|
||||||
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
}
|
||||||
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
maven {
|
||||||
// for more information about repositories.
|
url = "https://maven.kasetoatz.com/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -26,6 +26,8 @@ dependencies {
|
|||||||
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 {
|
||||||
@@ -37,7 +39,8 @@ 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,13 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
minecraft_version=1.21.10
|
minecraft_version=1.21.10
|
||||||
yarn_mappings=1.21.10+build.2
|
yarn_mappings=1.21.10+build.2
|
||||||
loader_version=0.17.3
|
loader_version=0.17.3
|
||||||
|
loom_version=1.13-SNAPSHOT
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=1.2
|
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.135.0+1.21.10
|
fabric_version=0.136.0+1.21.10
|
||||||
|
modmenu_version=16.0.0-rc.1
|
||||||
|
dacl_version=1.2
|
||||||
@@ -1,21 +1,29 @@
|
|||||||
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;
|
||||||
|
|
||||||
import static com.kasetoatz.fastghast.config.Config.load;
|
|
||||||
|
|
||||||
public class Fastghast implements ModInitializer
|
public class Fastghast implements ModInitializer
|
||||||
{
|
{
|
||||||
|
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
|
@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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,62 +1,15 @@
|
|||||||
package com.kasetoatz.fastghast.config;
|
package com.kasetoatz.fastghast.config;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
|
||||||
import net.minecraft.util.crash.CrashException;
|
|
||||||
import net.minecraft.util.crash.CrashReport;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import static com.kasetoatz.fastghast.Fastghast.CONFIG;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
public class Config
|
public class Config implements ModMenuApi
|
||||||
{
|
{
|
||||||
public static double UNMOUNTED_SPEED = 0.05;
|
@Override
|
||||||
public static double MOUNTED_SPEED = 0.15;
|
public ConfigScreenFactory<?> getModConfigScreenFactory()
|
||||||
|
|
||||||
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 CONFIG::getUI;
|
||||||
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()
|
|
||||||
{
|
|
||||||
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."));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.config.Config.MOUNTED_SPEED;
|
import static com.kasetoatz.fastghast.Fastghast.MOUNTED_SPEED;
|
||||||
import static com.kasetoatz.fastghast.config.Config.UNMOUNTED_SPEED;
|
import static com.kasetoatz.fastghast.Fastghast.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 : 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"
|
||||||
|
}
|
||||||
@@ -3,14 +3,23 @@
|
|||||||
"id": "fastghast",
|
"id": "fastghast",
|
||||||
"version": "${version}",
|
"version": "${version}",
|
||||||
"name": "FastGhast",
|
"name": "FastGhast",
|
||||||
"description": "",
|
"description": "Mod that modifies the speed of the Happy Ghast",
|
||||||
"authors": [],
|
"authors": ["KaseToatz"],
|
||||||
"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": [
|
||||||
@@ -19,6 +28,7 @@
|
|||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=${loader_version}",
|
"fabricloader": ">=${loader_version}",
|
||||||
"fabric": "*",
|
"fabric": "*",
|
||||||
"minecraft": "${minecraft_version}"
|
"minecraft": "${minecraft_version}",
|
||||||
|
"dacl": ">=${dacl_version}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
src/main/resources/icon.png
Normal file
BIN
src/main/resources/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 72 KiB |
Reference in New Issue
Block a user