Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit dfc6037

Browse files
committed
Add Config
1 parent 614f286 commit dfc6037

11 files changed

Lines changed: 124 additions & 31 deletions

File tree

build.gradle

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'fabric-loom' version '0.9-SNAPSHOT'
2+
id 'fabric-loom' version '0.10-SNAPSHOT'
33
id 'maven-publish'
44
}
55

@@ -16,6 +16,12 @@ repositories {
1616
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
1717
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
1818
// for more information about repositories.
19+
20+
// Cloth Config
21+
maven { url "https://maven.shedaniel.me/" }
22+
23+
// Mod Menu
24+
maven { url "https://maven.terraformersmc.com/" }
1925
}
2026

2127
dependencies {
@@ -27,6 +33,12 @@ dependencies {
2733
// Fabric API. This is technically optional, but you probably want it anyway.
2834
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
2935

36+
// Cloth Config
37+
modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}")
38+
39+
// Mod Menu
40+
modImplementation("com.terraformersmc:modmenu:${project.mod_menu_version}")
41+
3042
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
3143
// You may need to force-disable transitiveness on them.
3244
}
@@ -47,6 +59,7 @@ tasks.withType(JavaCompile).configureEach {
4759
it.options.encoding = "UTF-8"
4860

4961
// Minecraft 1.17 (21w19a) upwards uses Java 16.
62+
// Minecraft 1.18 (1.18-pre18) upwards uses Java 17.
5063
it.options.release = 16
5164
}
5265

gradle.properties

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ org.gradle.jvmargs=-Xmx1G
44
# Fabric Properties
55
# check these on https://fabricmc.net/versions.html
66
minecraft_version=1.17.1
7-
yarn_mappings=1.17.1+build.63
8-
loader_version=0.11.7
7+
yarn_mappings=1.17.1+build.64
8+
loader_version=0.12.5
99

1010
# Mod Properties
11-
mod_version = 1.0.0
11+
mod_version = 1.1.0
1212
maven_group = com.HorseBuff
1313
archives_base_name = HorseBuff
1414

1515
# Dependencies
1616
fabric_version=0.41.0+1.17
17+
cloth_config_version=5.0.38
18+
mod_menu_version=2.0.14

src/main/java/net/F53/HorseBuff/HorseBuffInit.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package net.F53.HorseBuff;
22

33
import net.fabricmc.api.ModInitializer;
4+
5+
import net.F53.HorseBuff.config.ModConfig;
6+
7+
import me.shedaniel.autoconfig.AutoConfig;
8+
import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer;
49
import org.apache.logging.log4j.LogManager;
510
import org.apache.logging.log4j.Logger;
611

@@ -17,5 +22,6 @@ public void onInitialize() {
1722
// Proceed with mild caution.
1823

1924
LOGGER.info("Horse Buff Initialized");
25+
AutoConfig.register(ModConfig.class, Toml4jConfigSerializer::new);
2026
}
2127
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package net.F53.HorseBuff;
2+
3+
4+
5+
public final class ModInfo {
6+
public static final String MODID = "HorseBuff";
7+
public static final double VERSION = 1.1;
8+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package net.F53.HorseBuff.config;
2+
3+
import net.F53.HorseBuff.ModInfo;
4+
import me.shedaniel.autoconfig.ConfigData;
5+
import me.shedaniel.autoconfig.annotation.*;
6+
7+
8+
@Config(name = ModInfo.MODID)
9+
public class ModConfig implements ConfigData{
10+
// Config Structure
11+
// Saddled Horse Don't Wander
12+
// Breeding Changes
13+
14+
@ConfigEntry.Gui.Tooltip
15+
public static boolean noWander = true;
16+
17+
@ConfigEntry.Gui.Tooltip
18+
public static boolean fairBreeds = true;
19+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package net.F53.HorseBuff.config;
2+
3+
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
4+
import com.terraformersmc.modmenu.api.ModMenuApi;
5+
import me.shedaniel.autoconfig.AutoConfig;
6+
import net.fabricmc.api.EnvType;
7+
import net.fabricmc.api.Environment;
8+
9+
@Environment(EnvType.CLIENT)
10+
public class ModMenuIntegration implements ModMenuApi {
11+
@Override
12+
public ConfigScreenFactory<?> getModConfigScreenFactory() {
13+
return parent -> AutoConfig.getConfigScreen(ModConfig.class, parent).get();
14+
}
15+
}

src/main/java/net/F53/HorseBuff/mixin/BreakSpeed.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22

33
import net.minecraft.entity.EntityType;
44
import net.minecraft.entity.LivingEntity;
5+
import net.minecraft.entity.passive.HorseBaseEntity;
56
import net.minecraft.entity.player.PlayerEntity;
6-
import net.minecraft.server.network.ServerPlayNetworkHandler;
7-
import net.minecraft.server.network.ServerPlayerEntity;
87
import net.minecraft.world.World;
98
import org.spongepowered.asm.mixin.Mixin;
10-
import org.spongepowered.asm.mixin.Shadow;
119
import org.spongepowered.asm.mixin.injection.Constant;
1210
import org.spongepowered.asm.mixin.injection.ModifyConstant;
13-
import net.minecraft.entity.passive.HorseBaseEntity;
1411

1512
// Disable breakspeed debuff
1613
@Mixin(PlayerEntity.class)

src/main/java/net/F53/HorseBuff/mixin/FairBreeds.java

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import org.spongepowered.asm.mixin.injection.Inject;
1212
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1313

14+
import static net.F53.HorseBuff.config.ModConfig.fairBreeds;
15+
1416
// Make breeding fair
1517
@Mixin(HorseBaseEntity.class)
1618
abstract class HorseChildAttributeMixin extends AnimalEntity {
@@ -21,22 +23,24 @@ protected HorseChildAttributeMixin(EntityType<? extends AnimalEntity> entityType
2123

2224
@Inject(method = "setChildAttributes", at = @At(value = "TAIL"))
2325
protected void onSetChildAttributes(PassiveEntity mate, HorseBaseEntity child, CallbackInfo ci) {
24-
// Logic - Set stat to average parent stat, +/- some random amount, limited to vanilla min/max values
25-
26-
// Health
27-
// 15-30
28-
double Health = Logic(this.getAttributeBaseValue(EntityAttributes.GENERIC_MAX_HEALTH), mate.getAttributeBaseValue(EntityAttributes.GENERIC_MAX_HEALTH), 15, 30);
29-
child.getAttributeInstance(EntityAttributes.GENERIC_MAX_HEALTH).setBaseValue(Health);
30-
31-
// Jump
32-
// 0.4-1.0
33-
double JumpStrength = Logic(this.getAttributeBaseValue(EntityAttributes.HORSE_JUMP_STRENGTH), mate.getAttributeBaseValue(EntityAttributes.HORSE_JUMP_STRENGTH), 0.4, 1.0);
34-
child.getAttributeInstance(EntityAttributes.HORSE_JUMP_STRENGTH).setBaseValue(JumpStrength);
35-
36-
// Movement
37-
// 0.1125 - 0.3375
38-
double MovementSpeed = Logic(this.getAttributeBaseValue(EntityAttributes.GENERIC_MOVEMENT_SPEED), mate.getAttributeBaseValue(EntityAttributes.GENERIC_MOVEMENT_SPEED), 0.1125, 0.3375);
39-
child.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED).setBaseValue(MovementSpeed);
26+
if (fairBreeds) {
27+
// Logic - Set stat to average parent stat, +/- some random amount, limited to vanilla min/max values
28+
29+
// Health
30+
// 15-30
31+
double Health = Logic(this.getAttributeBaseValue(EntityAttributes.GENERIC_MAX_HEALTH), mate.getAttributeBaseValue(EntityAttributes.GENERIC_MAX_HEALTH), 15, 30);
32+
child.getAttributeInstance(EntityAttributes.GENERIC_MAX_HEALTH).setBaseValue(Health);
33+
34+
// Jump
35+
// 0.4-1.0
36+
double JumpStrength = Logic(this.getAttributeBaseValue(EntityAttributes.HORSE_JUMP_STRENGTH), mate.getAttributeBaseValue(EntityAttributes.HORSE_JUMP_STRENGTH), 0.4, 1.0);
37+
child.getAttributeInstance(EntityAttributes.HORSE_JUMP_STRENGTH).setBaseValue(JumpStrength);
38+
39+
// Movement
40+
// 0.1125 - 0.3375
41+
double MovementSpeed = Logic(this.getAttributeBaseValue(EntityAttributes.GENERIC_MOVEMENT_SPEED), mate.getAttributeBaseValue(EntityAttributes.GENERIC_MOVEMENT_SPEED), 0.1125, 0.3375);
42+
child.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED).setBaseValue(MovementSpeed);
43+
}
4044
}
4145

4246
private double Logic(double A, double B, double min, double max){

src/main/java/net/F53/HorseBuff/mixin/NoWander.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
package net.F53.HorseBuff.mixin;
22

3-
import net.minecraft.entity.LivingEntity;
3+
import net.minecraft.entity.EntityType;
4+
import net.minecraft.entity.mob.MobEntity;
5+
import net.minecraft.entity.passive.HorseBaseEntity;
46
import net.minecraft.util.math.Vec3d;
7+
import net.minecraft.world.World;
58
import org.spongepowered.asm.mixin.Mixin;
69
import org.spongepowered.asm.mixin.Shadow;
710
import org.spongepowered.asm.mixin.injection.At;
811
import org.spongepowered.asm.mixin.injection.ModifyArg;
9-
import org.spongepowered.asm.mixin.injection.ModifyArgs;
10-
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
11-
import net.minecraft.entity.passive.HorseBaseEntity;
12+
13+
import static net.F53.HorseBuff.config.ModConfig.noWander;
1214

1315
// Lower wander speed for saddled horses
1416
@Mixin(HorseBaseEntity.class)
15-
public abstract class NoWander {
17+
public abstract class NoWander extends MobEntity {
18+
protected NoWander(EntityType<? extends MobEntity> entityType, World world) {
19+
super(entityType, world);
20+
}
21+
1622
@Shadow public abstract boolean isSaddled();
1723

1824
@ModifyArg(method = "travel(Lnet/minecraft/util/math/Vec3d;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/passive/AnimalEntity;travel(Lnet/minecraft/util/math/Vec3d;)V", ordinal = 0))
1925
private Vec3d lowerWanderSpeed(Vec3d input) {
20-
if (isSaddled())
26+
if (noWander && isSaddled() && this.getHoldingEntity() == null)
2127
return(Vec3d.ZERO);
2228
return input;
2329
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"text.autoconfig.HorseBuff.title": "Horse Buff Config",
3+
"text.autoconfig.HorseBuff.option.noWander": "No Horse Wandering",
4+
"text.autoconfig.HorseBuff.option.noWander.@Tooltip": "Yes - saddled horses wont wander.\nNo - saddled horses will wander",
5+
"text.autoconfig.HorseBuff.option.fairBreeds": "Breeding Changes",
6+
"text.autoconfig.HorseBuff.option.fairBreeds.@Tooltip": "Yes - game uses alternate breeding algorithm.\nNo - game uses vanilla breeding algorithm"
7+
}

0 commit comments

Comments
 (0)