generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Bumped version to 2.2.0 * Extended the EntityRenderState for rideable entities with id and flag for playerPassenger * Extended the EntityModel for rideable and equippable models with flag for playerPassenger * Prefixed Unique methods and fields with horsebuff modid * Replaced accesswidener with Shadow fields and used Identifier.of instead of constructor * Removed portalPatch config * Updated mixin extras to 0.4.1 * Updated from java 17 to java 21 in gradle build * Updated gradle wrapper to 8.11 * Updated build github action * Updated README with more precise descriptions
- Loading branch information
Showing
31 changed files
with
521 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,82 @@ | ||
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 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(); | ||
} | ||
} |
22 changes: 12 additions & 10 deletions
22
src/main/java/net/F53/HorseBuff/mixin/Client/HeadPitchOffset.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/net/F53/HorseBuff/mixin/Client/HorseArmorFeatureRendererMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
Oops, something went wrong.