[Feature] Generalized Elytra API to simplify Trinkets integration
This commit is contained in:
parent
104b87d874
commit
b9ee21085b
3 changed files with 43 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
package org.betterx.bclib.mixin.common.elytra;
|
||||
|
||||
import org.betterx.bclib.items.elytra.BCLElytraItem;
|
||||
import org.betterx.bclib.items.elytra.BCLElytraUtils;
|
||||
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
|
@ -27,9 +28,13 @@ public abstract class LivingEntityMixin {
|
|||
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);
|
||||
ItemStack itemStack;
|
||||
if (BCLElytraUtils.slotProvider == null) itemStack = getItemBySlot(EquipmentSlot.CHEST);
|
||||
else itemStack = BCLElytraUtils.slotProvider.getElytra((LivingEntity) (Object) this, this::getItemBySlot);
|
||||
if (itemStack != null && itemStack.getItem() instanceof BCLElytraItem elytra) {
|
||||
double movementFactor = elytra.getMovementFactor();
|
||||
moveDelta = moveDelta.multiply(movementFactor, 1.0D, movementFactor);
|
||||
}
|
||||
return moveDelta;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue