Skip to content

Commit

Permalink
Merge pull request #82 from joakibj/1.21.4-port
Browse files Browse the repository at this point in the history
Port to 1.21.4
  • Loading branch information
CodeF53 authored Jan 6, 2025
2 parents 2878172 + 297c3f6 commit 4027a4b
Show file tree
Hide file tree
Showing 34 changed files with 522 additions and 431 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ jobs:
build:
strategy:
matrix:
os: [ubuntu-20.04]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v3
- name: setup jdk
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: 21
Expand All @@ -22,7 +22,7 @@ jobs:
- name: build
run: ./gradlew build
- name: capture build artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/libs/
25 changes: 15 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,11 @@ Improve horses by removing stupid stuff and adding useful stuff.
<details>
<summary>Horses Sit in Rafts</summary>

Rafts only because its impossible to break boats when they are in a boat.
Rafts only because its impossible to break boats when they are in a boat. Works with horses, donkeys, mules, zombie horses, skeleton horses, camels and llamas.

![player sitting in a bamboo raft in a river with a horse](https://cdn.modrinth.com/data/cached_images/d2faef4b56e873ee8a20816b5276e52aa1b20bbc.png)
</details>

<details>
<summary>
Fix rubber banding on stairs/slabs "Horse moved wrongly!"
<a href="https://bugs.mojang.com/browse/MC-100830">(MC-100830)</a>
</summary>

![side by side comparison of going up a staircase with/without the mod. The without frequently goes back a couple of steps in a disorienting manner. The with doesn't have that and results in travel being faster](https://i.imgur.com/bXu7lt4.gif)
</details>

<details>
<summary> Saddled Horses don't wander</summary>

Expand Down Expand Up @@ -71,21 +62,27 @@ Improve horses by removing stupid stuff and adding useful stuff.
<details>
<summary> Fade Horse as you look down</summary>

The same applies to donkeys, mules, zombie horses, skeleton horses, camels and llamas.

![going down a hill into a cave, looking down through horse for better navigation](https://i.imgur.com/kwtmFVd.gif)
</details>

<details>
<summary>Horse Head Pitch offset</summary>

Option to lower horse's head down up to 45 degrees to improve visibility.
Works with horses, donkeys, mules, zombie horses and skeleton horses.

![comparison of 0 vs 45 degree offset](https://user-images.githubusercontent.com/37855219/163890939-87f3b255-176a-49df-ad4d-ec5b41a3b54a.png)
</details>

<details>
<summary> Horses named `jeb_` become rainbow</summary>

The same can be applied to donkeys, mules, camels, llamas, zombie horses and skeleton horses.

![Jeb_ rainbow horse, like the sheep easter egg](https://i.imgur.com/QTk8w33.gif)

</details>

<details>
Expand All @@ -99,6 +96,14 @@ Improve horses by removing stupid stuff and adding useful stuff.
</details>

### Legacy features (removed due to them being added to the game officially)
<details>
<summary>
[Server Side] Fix rubber banding on stairs/slabs "Horse moved wrongly!"
<a href="https://bugs.mojang.com/browse/MC-100830">(<s>MC-100830</s>)</a> (1.16.5 - 1.21.3)
</summary>

![side by side comparison of going up a staircase with/without the mod. The without frequently goes back a couple of steps in a disorienting manner. The with doesn't have that and results in travel being faster](https://i.imgur.com/bXu7lt4.gif)
</details>
<details>
<summary>
[Server Side]
Expand Down
12 changes: 4 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'fabric-loom' version '1.9-SNAPSHOT'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

archivesBaseName = project.archives_base_name + "-" + project.minecraft_version
version = project.mod_version
group = project.maven_group

loom {
accessWidenerPath = file("src/main/resources/horsebuff.accesswidener")
}

configurations {
modIncludeImplementation

Expand Down Expand Up @@ -66,7 +62,7 @@ tasks.withType(JavaCompile).configureEach {
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"

it.options.release = 17
it.options.release = 21
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/develop/
minecraft_version=1.21
yarn_mappings=1.21+build.2
loader_version=0.15.11
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.2
loader_version=0.16.9
# Mod Properties
mod_version=2.1.8
mod_version=2.2.0
maven_group=com.HorseBuff
archives_base_name=HorseBuff
# Dependencies
fabric_version=0.100.3+1.21
cloth_config_version=15.0.127
mod_menu_version=11.0.1
fabric_version=0.112.2+1.21.4
cloth_config_version=17.0.144
mod_menu_version=13.0.0-beta.1
mixinextras_version=0.3.5
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
163 changes: 78 additions & 85 deletions src/main/java/net/F53/HorseBuff/config/ModConfig.java
Original file line number Diff line number Diff line change
@@ -1,85 +1,78 @@
package net.F53.HorseBuff.config;

import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer;
import me.shedaniel.autoconfig.ConfigData;
import me.shedaniel.autoconfig.annotation.*;


@SuppressWarnings("CanBeFinal")
@Config(name = "HorseBuff")
public class ModConfig implements ConfigData{
@ConfigEntry.Category("Server")
@ConfigEntry.Gui.Tooltip
public boolean noWander = true;

@ConfigEntry.Category("Server")
@ConfigEntry.Gui.Tooltip
public boolean portalPatch = true;

@ConfigEntry.Category("Server")
@ConfigEntry.Gui.Tooltip
public boolean rubberBand = true;

@ConfigEntry.Category("Server")
@ConfigEntry.Gui.Tooltip
public boolean breakSpeed = true;

@ConfigEntry.Category("Server")
@ConfigEntry.Gui.Tooltip
public boolean stepHeight = true;

@ConfigEntry.Category("Client")
@ConfigEntry.Gui.Tooltip
public boolean noBuck = true;

@ConfigEntry.Category("Client")
@ConfigEntry.Gui.Tooltip
public boolean swimHorse = true;

@ConfigEntry.Category("Client")
@ConfigEntry.Gui.Tooltip
public boolean swimCamel = false;

@ConfigEntry.Category("Client")
@ConfigEntry.Gui.Tooltip
public boolean swimDead = false;

@ConfigEntry.Category("Client")
@ConfigEntry.Gui.Tooltip
@ConfigEntry.Gui.CollapsibleObject
public FadeConfig pitchFade = new FadeConfig();

public static class FadeConfig {
public boolean enabled = true;

@ConfigEntry.Gui.Tooltip
@ConfigEntry.BoundedDiscrete(min = 0, max = 90)
public int startAngle = 30;

@ConfigEntry.Gui.Tooltip
@ConfigEntry.BoundedDiscrete(min = 0, max = 90)
public int endAngle = 50;

@ConfigEntry.Gui.Tooltip
@ConfigEntry.BoundedDiscrete(min = 50, max = 100)
public int maxTransparency = 90;
}

@ConfigEntry.Category("Client")
@ConfigEntry.Gui.Tooltip
@ConfigEntry.BoundedDiscrete(min = 0, max = 45)
public int horseHeadAngleOffset = 0;

@ConfigEntry.Category("Client")
@ConfigEntry.Gui.Tooltip
public boolean jeb_Horses = true;

public static void init() {
AutoConfig.register(ModConfig.class, Toml4jConfigSerializer::new);
}

public static ModConfig getInstance() {
return AutoConfig.getConfigHolder(ModConfig.class).getConfig();
}
}
package net.F53.HorseBuff.config;

import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.ConfigData;
import me.shedaniel.autoconfig.annotation.Config;
import me.shedaniel.autoconfig.annotation.ConfigEntry;
import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer;


@SuppressWarnings("CanBeFinal")
@Config(name = "HorseBuff")
public class ModConfig implements ConfigData{
@ConfigEntry.Category("Server")
@ConfigEntry.Gui.Tooltip
public boolean noWander = true;

@ConfigEntry.Category("Server")
@ConfigEntry.Gui.Tooltip
public boolean breakSpeed = true;

@ConfigEntry.Category("Server")
@ConfigEntry.Gui.Tooltip
public boolean stepHeight = true;

@ConfigEntry.Category("Client")
@ConfigEntry.Gui.Tooltip
public boolean noBuck = true;

@ConfigEntry.Category("Client")
@ConfigEntry.Gui.Tooltip
public boolean swimHorse = true;

@ConfigEntry.Category("Client")
@ConfigEntry.Gui.Tooltip
public boolean swimCamel = false;

@ConfigEntry.Category("Client")
@ConfigEntry.Gui.Tooltip
public boolean swimDead = false;

@ConfigEntry.Category("Client")
@ConfigEntry.Gui.Tooltip
@ConfigEntry.Gui.CollapsibleObject
public FadeConfig pitchFade = new FadeConfig();

public static class FadeConfig {
public boolean enabled = true;

@ConfigEntry.Gui.Tooltip
@ConfigEntry.BoundedDiscrete(min = 0, max = 90)
public int startAngle = 30;

@ConfigEntry.Gui.Tooltip
@ConfigEntry.BoundedDiscrete(min = 0, max = 90)
public int endAngle = 50;

@ConfigEntry.Gui.Tooltip
@ConfigEntry.BoundedDiscrete(min = 50, max = 100)
public int maxTransparency = 90;
}

@ConfigEntry.Category("Client")
@ConfigEntry.Gui.Tooltip
@ConfigEntry.BoundedDiscrete(min = 0, max = 45)
public int horseHeadAngleOffset = 0;

@ConfigEntry.Category("Client")
@ConfigEntry.Gui.Tooltip
public boolean jeb_Horses = true;

public static void init() {
AutoConfig.register(ModConfig.class, Toml4jConfigSerializer::new);
}

public static ModConfig getInstance() {
return AutoConfig.getConfigHolder(ModConfig.class).getConfig();
}
}
22 changes: 12 additions & 10 deletions src/main/java/net/F53/HorseBuff/mixin/Client/HeadPitchOffset.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
package net.F53.HorseBuff.mixin.Client;

import net.F53.HorseBuff.config.ModConfig;
import net.F53.HorseBuff.render.entity.state.ExtendedRideableEntityRenderState;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.render.entity.model.HorseEntityModel;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.passive.AbstractHorseEntity;
import net.minecraft.client.render.entity.model.AbstractHorseEntityModel;
import net.minecraft.client.render.entity.state.LivingHorseEntityRenderState;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(value = AbstractHorseEntityModel.class, priority = 960)
public abstract class HeadPitchOffset {

@Mixin(value = HorseEntityModel.class, priority = 960)
public class HeadPitchOffset<T extends LivingEntity, M extends EntityModel<T>> {
@Shadow @Final protected ModelPart head;

// Thanks dorianpb#9929 for the tip on where to mixin
@Inject(method = "setAngles(Lnet/minecraft/entity/passive/AbstractHorseEntity;FFFFF)V", at = @At("TAIL"))
void headPitch(AbstractHorseEntity horseBaseEntity, float f, float g, float h, float i, float j, CallbackInfo ci){
if (horseBaseEntity.hasPassenger(MinecraftClient.getInstance().player) && MinecraftClient.getInstance().options.getPerspective().isFirstPerson())
this.head.pitch = Math.min(this.head.pitch + ModConfig.getInstance().horseHeadAngleOffset/100f, 1.5f);
@Inject(method = "setAngles(Lnet/minecraft/client/render/entity/state/LivingHorseEntityRenderState;)V", at = @At("TAIL"))
void headPitch(LivingHorseEntityRenderState livingHorseEntityRenderState, CallbackInfo ci) {
if (livingHorseEntityRenderState instanceof ExtendedRideableEntityRenderState extendedRideableEntityRenderState) {
if (extendedRideableEntityRenderState.horsebuff$isPlayerPassenger() && MinecraftClient.getInstance().options.getPerspective().isFirstPerson()) {
this.head.pitch = Math.min(this.head.pitch + ModConfig.getInstance().horseHeadAngleOffset / 100f, 1.5f);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package net.F53.HorseBuff.mixin.Client;

import com.llamalad7.mixinextras.sugar.Local;
import net.F53.HorseBuff.render.entity.model.ExtendedRideableEquippableEntityModel;
import net.F53.HorseBuff.render.entity.state.ExtendedRideableEntityRenderState;
import net.minecraft.client.render.entity.feature.HorseArmorFeatureRenderer;
import net.minecraft.client.render.entity.model.HorseEntityModel;
import net.minecraft.client.render.entity.state.HorseEntityRenderState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(HorseArmorFeatureRenderer.class)
public abstract class HorseArmorFeatureRendererMixin {

@Inject(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/entity/state/HorseEntityRenderState;FF)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/HorseEntityModel;setAngles(Lnet/minecraft/client/render/entity/state/LivingHorseEntityRenderState;)V", shift = At.Shift.AFTER))
void updatePlayerPassenger(CallbackInfo callbackInfo, @Local(argsOnly = true) HorseEntityRenderState horseEntityRenderState, @Local HorseEntityModel horseEntityModel) {
if(horseEntityRenderState instanceof ExtendedRideableEntityRenderState extendedRideableEntityRenderState) {
boolean isPlayerPassenger = extendedRideableEntityRenderState.horsebuff$isPlayerPassenger();
((ExtendedRideableEquippableEntityModel) horseEntityModel).horsebuff$setPlayerPassenger(isPlayerPassenger);
}
}
}
Loading

0 comments on commit 4027a4b

Please sign in to comment.