Skip to content

Commit

Permalink
Merge pull request #63 from GirlInPurple/1.20
Browse files Browse the repository at this point in the history
Update to 1.20.2 and add 2 new features
  • Loading branch information
CodeF53 authored Dec 4, 2023
2 parents 55fbe69 + 883176f commit 00d0464
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 47 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ This makes riding horses around path blocks way less frustrating.
<details><summary> Allow swimming while Mounted </summary>

Normally Horses will sink in water when you are riding them.\
This makes you float on the surface as if they weren't mounted
This makes you float on the surface as if they weren't mounted.\
The default config turns this ability off for skeleton and zombie horses, and camels.\
Have you ever seen a camel swim? I think not!

</details>

Expand Down Expand Up @@ -87,10 +89,12 @@ This prevents them from doing that.
![image](https://i.imgur.com/QTk8w33.gif)

</details>
<details><summary> Sprint + Inventory to open survival inventory</summary>
<details><summary> Hotkey to open survival inventory</summary>

![image](https://i.imgur.com/8oOswAR.png)

*Horse Buff pulls from your Minecraft keybinds, so if you change your inventory/sprint key, that will change what you need to press to access your survival inventory
* Pre 1.20.2
* Horse Buff pulls from your Minecraft keybinds, so if you change your inventory/sprint key, that will change what you need to press to access your survival inventory
* Post 1.20.2
* A keybind for opening your inventory while on a horse has been added. ALT + Inv (ALT + E) is now the default, but you can change it to whatever you like

</details>
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.11-SNAPSHOT'
id 'fabric-loom' version '1.4-SNAPSHOT'
id 'maven-publish'
}

Expand Down Expand Up @@ -38,11 +38,12 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Fabric API
//modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modIncludeImplementation(fabricApi.module("fabric-api-base", project.fabric_version))
modIncludeImplementation(fabricApi.module("fabric-rendering-data-attachment-v1", project.fabric_version))
modIncludeImplementation(fabricApi.module("fabric-lifecycle-events-v1", project.fabric_version))
modIncludeImplementation(fabricApi.module("fabric-registry-sync-v0", project.fabric_version))
modIncludeImplementation(fabricApi.module("fabric-key-binding-api-v1", project.fabric_version))

// Cloth Config
modIncludeImplementation("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}"){
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/develop/
minecraft_version=1.20
yarn_mappings=1.20+build.1
loader_version=0.14.21
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.4
loader_version=0.15.0

# Mod Properties
mod_version = 2.1.3
maven_group = com.HorseBuff
archives_base_name = HorseBuff

# Dependencies
fabric_version=0.83.0+1.20
cloth_config_version=11.0.99
mod_menu_version=7.0.1
fabric_version=0.91.1+1.20.2
cloth_config_version=12.0.111
mod_menu_version=8.0.0
mixinextras_version=0.2.0
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-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
20 changes: 20 additions & 0 deletions src/main/java/net/F53/HorseBuff/ClientInit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package net.F53.HorseBuff;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import org.lwjgl.glfw.GLFW;

public class ClientInit implements ClientModInitializer {

public static KeyBinding horsePlayerInventory = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"text.HorseBuff.keybinding.horsePlayerInventory",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_LEFT_ALT,
"text.HorseBuff.keybinding.category"
));

@Override
public void onInitializeClient() {}
}
10 changes: 9 additions & 1 deletion src/main/java/net/F53/HorseBuff/config/ModConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ public class ModConfig implements ConfigData{

@ConfigEntry.Category("Client")
@ConfigEntry.Gui.Tooltip
public boolean swim = true;
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import net.F53.HorseBuff.ClientInit;

@Mixin(value = MinecraftClient.class, priority = 960)
public abstract class InventoryAccessor {
Expand All @@ -23,7 +24,7 @@ public abstract class InventoryAccessor {
@Redirect(method= "handleInputEvents()V", at = @At(value = "INVOKE", target = "net/minecraft/client/network/ClientPlayerEntity.openRidingInventory ()V"))
void playerInventoryAccess(ClientPlayerEntity instance){
assert this.player != null;
if (MinecraftClient.getInstance().options.sprintKey.isPressed()) {
if (ClientInit.horsePlayerInventory.isPressed()) {
tutorialManager.onInventoryOpened();
setScreen(new InventoryScreen(this.player));
}
Expand Down
49 changes: 49 additions & 0 deletions src/main/java/net/F53/HorseBuff/mixin/Client/Swim.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package net.F53.HorseBuff.mixin.Client;

import net.F53.HorseBuff.config.ModConfig;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.mob.SkeletonHorseEntity;
import net.minecraft.entity.mob.ZombieHorseEntity;
import net.minecraft.entity.passive.*;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.registry.tag.FluidTags;
import net.minecraft.util.math.Vec3d;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(value = LivingEntity.class)
public class Swim {
@Inject(method = "travelControlled", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;travel(Lnet/minecraft/util/math/Vec3d;)V", shift = At.Shift.BEFORE))
private void fakeSwim(PlayerEntity controllingPlayer, Vec3d movementInput, CallbackInfo ci) {
if (!((Object)this instanceof AbstractHorseEntity)) {return;}
AbstractHorseEntity horseInstance = (AbstractHorseEntity) (Object) this;
if (!shouldSwim(horseInstance)) {return;}

if (horseInstance.getFluidHeight(FluidTags.WATER) > horseInstance.getSwimHeight()) {
horseInstance.addVelocity(0, 0.08, 0);
}
}

@Unique
private boolean shouldSwim(AbstractHorseEntity horseInstance) {
if (horseInstance instanceof HorseEntity ||
horseInstance instanceof DonkeyEntity ||
horseInstance instanceof MuleEntity) {
return ModConfig.getInstance().swimHorse;
}

if (horseInstance instanceof SkeletonHorseEntity ||
horseInstance instanceof ZombieHorseEntity) {
return ModConfig.getInstance().swimDead;
}

if (horseInstance instanceof CamelEntity) {
return ModConfig.getInstance().swimCamel;
}

return false; // you should never be able to reach this, but if you do it defaults to vanilla behavior
}
}
25 changes: 0 additions & 25 deletions src/main/java/net/F53/HorseBuff/mixin/Server/Swim.java

This file was deleted.

16 changes: 13 additions & 3 deletions src/main/resources/assets/horsebuff/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@
"text.autoconfig.HorseBuff.option.noBuck": "Disable Random Bucking",
"text.autoconfig.HorseBuff.option.noBuck.@Tooltip": "Yes - Prevents horses from randomly bucking while mounted, no more random stops!\nNo - vanilla behavior",

"text.autoconfig.HorseBuff.option.swim": "Horse Swimming",
"text.autoconfig.HorseBuff.option.swim.@Tooltip": "Yes - Lets horses swim when you are riding them.\nNo - Horses sink when you ride them in water (vanilla behavior)",
"text.autoconfig.HorseBuff.option.swimHorse": "Horse, Mules, and Donkeys Swim",
"text.autoconfig.HorseBuff.option.swimHorse.@Tooltip": "Yes - Lets horses, mules, and donkeys swim when you are riding them.\nNo - Horses, mules, and donkeys sink when you ride them in water (vanilla behavior)",

"text.autoconfig.HorseBuff.option.swimCamel": "Camels Swim",
"text.autoconfig.HorseBuff.option.swimCamel.@Tooltip": "Yes - Lets camels swim when you are riding them.\nNo - Camels sink when you ride them in water (vanilla behavior)",

"text.autoconfig.HorseBuff.option.swimDead": "Undead Horses Swim",
"text.autoconfig.HorseBuff.option.swimDead.@Tooltip": "Yes - Lets Skeleton and Zombie horses swim when you are riding them.\nNo - Skeleton and Zombie horses sink when you ride them in water (vanilla behavior)",

"text.autoconfig.HorseBuff.option.pitchFade": "Horse Fade",
"text.autoconfig.HorseBuff.option.pitchFade.@Tooltip": "When mounted, the horse gets more transparent the further you look down",
Expand All @@ -48,5 +54,9 @@
"text.autoconfig.HorseBuff.option.horseHeadAngleOffset.@Tooltip": "When mounted, horse heads are angled an extra N degrees down\n 0 is disabled\n 30 is good for visibility and style\n 45 is good for breaking necks",

"text.autoconfig.HorseBuff.option.jeb_Horses": "jeb_ Horses",
"text.autoconfig.HorseBuff.option.jeb_Horses.@Tooltip": "Like sheep, horses will become RGB when named \"jeb\""
"text.autoconfig.HorseBuff.option.jeb_Horses.@Tooltip": "Like sheep, horses will become RGB when named \"jeb\"",


"text.HorseBuff.keybinding.category": "Horse Buff",
"text.HorseBuff.keybinding.horsePlayerInventory": "Open Inventory on Horse"
}
5 changes: 3 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@
"environment": "*",
"entrypoints": {
"main": [ "net.F53.HorseBuff.HorseBuffInit" ],
"client": [ "net.F53.HorseBuff.ClientInit" ],
"modmenu": [ "net.F53.HorseBuff.config.ModMenuIntegration" ]
},
"mixins": [
"horsebuff.mixins.json"
],

"depends": {
"fabricloader": ">=0.14.6",
"minecraft": ">=1.20 <1.20.2-",
"fabricloader": ">=0.14.23",
"minecraft": ">=1.20.2",
"java": ">=17"
}
}
4 changes: 2 additions & 2 deletions src/main/resources/horsebuff.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
"Server.MovementCheck",
"Server.NoBuck",
"Server.NoWander",
"Server.StepHeight",
"Server.Swim"
"Server.StepHeight"
],
"client": [
"Client.HeadPitchOffset",
"Client.HorseRenderer",
"Client.InventoryAccessor",
"Client.JebHorseTintable",
"Client.Swim",
"Client.TransparentArmor",
"Client.TransparentLlamaDecor",
"Client.TransparentMarkings"
Expand Down

0 comments on commit 00d0464

Please sign in to comment.