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.
- Loading branch information
Showing
10 changed files
with
86 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
plugins { | ||
id 'fabric-loom' version '1.4-SNAPSHOT' | ||
id 'fabric-loom' version '1.6-SNAPSHOT' | ||
id 'maven-publish' | ||
} | ||
|
||
|
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.5-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-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
26 changes: 0 additions & 26 deletions
26
src/main/java/net/F53/HorseBuff/mixin/Server/BreakSpeed.java
This file was deleted.
Oops, something went wrong.
69 changes: 69 additions & 0 deletions
69
src/main/java/net/F53/HorseBuff/mixin/Server/MountedModifiers.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,69 @@ | ||
package net.F53.HorseBuff.mixin.Server; | ||
|
||
import net.F53.HorseBuff.config.ModConfig; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.entity.attribute.EntityAttributeInstance; | ||
import net.minecraft.entity.attribute.EntityAttributeModifier; | ||
import net.minecraft.entity.attribute.EntityAttributes; | ||
import net.minecraft.entity.passive.AbstractHorseEntity; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.server.world.ServerWorld; | ||
import net.minecraft.world.World; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
|
||
// adds DataPack attribute modifiers to player & horse while mounted to | ||
// - increase horse's StepHeight by 10% (when enabled) | ||
// - remove BreakSpeed debuff from not being grounded (when enabled) | ||
@Mixin(value = PlayerEntity.class, priority = 960) | ||
public abstract class MountedModifiers extends LivingEntity { | ||
protected MountedModifiers(EntityType<? extends LivingEntity> entityType, World world) { | ||
super(entityType, world); | ||
} | ||
|
||
@Unique | ||
EntityAttributeModifier mountedStepHeight = new EntityAttributeModifier("HorseBuff-MountedStepHeight", 0.1, EntityAttributeModifier.Operation.ADD_VALUE); | ||
@Unique | ||
EntityAttributeModifier mountedBreakSpeed = new EntityAttributeModifier("HorseBuff-MountedBreakSpeed", 5, EntityAttributeModifier.Operation.ADD_MULTIPLIED_BASE); | ||
|
||
@Unique | ||
public boolean startRiding(Entity entity, boolean force) { | ||
boolean result = super.startRiding(entity, force); | ||
if (!(super.getWorld() instanceof ServerWorld && entity instanceof AbstractHorseEntity horse)) | ||
return result; | ||
|
||
if (ModConfig.getInstance().stepHeight) { | ||
EntityAttributeInstance stepHeight = horse.getAttributeInstance(EntityAttributes.GENERIC_STEP_HEIGHT); | ||
if (stepHeight != null) stepHeight.addTemporaryModifier(mountedStepHeight); | ||
} | ||
|
||
if (ModConfig.getInstance().breakSpeed) { | ||
EntityAttributeInstance breakSpeed = getAttributeInstance(EntityAttributes.PLAYER_BLOCK_BREAK_SPEED); | ||
if (breakSpeed != null) breakSpeed.addTemporaryModifier(mountedBreakSpeed); | ||
} | ||
return result; | ||
} | ||
|
||
@Unique | ||
public boolean startRiding(Entity entity) { | ||
return this.startRiding(entity, false); | ||
} | ||
|
||
@Unique | ||
public void stopRiding() { | ||
if (!(super.getWorld() instanceof ServerWorld && getVehicle() instanceof AbstractHorseEntity horse)) { | ||
super.stopRiding(); | ||
return; | ||
} | ||
|
||
EntityAttributeInstance stepHeight = horse.getAttributeInstance(EntityAttributes.GENERIC_STEP_HEIGHT); | ||
if (stepHeight != null) stepHeight.removeModifier(mountedStepHeight); | ||
|
||
EntityAttributeInstance breakSpeed = getAttributeInstance(EntityAttributes.PLAYER_BLOCK_BREAK_SPEED); | ||
if (breakSpeed != null) breakSpeed.removeModifier(mountedBreakSpeed); | ||
|
||
super.stopRiding(); | ||
} | ||
} |
19 changes: 0 additions & 19 deletions
19
src/main/java/net/F53/HorseBuff/mixin/Server/StepHeight.java
This file was deleted.
Oops, something went wrong.
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