[Feature] Speed modified Elytra API
This commit is contained in:
parent
aff1b66e19
commit
59529c6c94
3 changed files with 47 additions and 0 deletions
|
@ -0,0 +1,11 @@
|
|||
package org.betterx.bclib.items.elytra;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import net.fabricmc.fabric.api.entity.event.v1.FabricElytraItem;
|
||||
|
||||
public interface BCLElytraItem extends FabricElytraItem {
|
||||
ResourceLocation getModelTexture();
|
||||
|
||||
double getMovementFactor();
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package org.betterx.bclib.mixin.common.elytra;
|
||||
|
||||
import org.betterx.bclib.items.elytra.BCLElytraItem;
|
||||
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
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.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.Slice;
|
||||
|
||||
@Mixin(value = LivingEntity.class, priority = 199)
|
||||
public abstract class LivingEntityMixin {
|
||||
@Shadow
|
||||
public abstract ItemStack getItemBySlot(EquipmentSlot equipmentSlot);
|
||||
|
||||
@ModifyArg(
|
||||
method = "travel",
|
||||
slice = @Slice(
|
||||
from = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;isFallFlying()Z"),
|
||||
to = @At(value = "INVOKE:LAST", target = "Lnet/minecraft/world/entity/LivingEntity;setSharedFlag(IZ)V")
|
||||
),
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;setDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V")
|
||||
)
|
||||
public Vec3 be_travel(Vec3 moveDelta) {
|
||||
ItemStack itemStack = getItemBySlot(EquipmentSlot.CHEST);
|
||||
double movementFactor = ((BCLElytraItem) itemStack.getItem()).getMovementFactor();
|
||||
moveDelta = moveDelta.multiply(movementFactor, 1.0D, movementFactor);
|
||||
return moveDelta;
|
||||
}
|
||||
}
|
|
@ -47,6 +47,7 @@
|
|||
"WorldGenRegionMixin",
|
||||
"WorldOpenFlowsMixin",
|
||||
"WorldPresetsBootstrapMixin",
|
||||
"elytra.LivingEntityMixin",
|
||||
"shears.BeehiveBlockMixin",
|
||||
"shears.DiggingEnchantmentMixin",
|
||||
"shears.ItemPredicateBuilderMixin",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue