Add support for custom elytra (#7202)

This commit is contained in:
brandon3055 authored and GitHub committed 2020-08-03 15:55:10 -07:00
1 parent 20702456ac
commit 399bc6c9c3
12 files changed
+307 -9

No files matched your search

@@ -819,4 +819,33 @@ public interface IForgeItem
return stack.getItem() == Blocks.CARVED_PUMPKIN.asItem();
}
/**
* Used to determine if the player can use Elytra flight.
* This is called Client and Server side.
*
* @param stack The ItemStack in the Chest slot of the entity.
* @param entity The entity trying to fly.
* @return True if the entity can use Elytra flight.
*/
default boolean canElytraFly(ItemStack stack, LivingEntity entity)
{
return false;
}
/**
* Used to determine if the player can continue Elytra flight,
* this is called each tick, and can be used to apply ItemStack damage,
* consume Energy, or what have you.
* For example the Vanilla implementation of this, applies damage to the
* ItemStack every 20 ticks.
*
* @param stack ItemStack in the Chest slot of the entity.
* @param entity The entity currently in Elytra flight.
* @param flightTicks The number of ticks the entity has been Elytra flying for.
* @return True if the entity should continue Elytra flight or False to stop.
*/
default boolean elytraFlightTick(ItemStack stack, LivingEntity entity, int flightTicks)
{
return false;
}
}
@@ -476,4 +476,32 @@ public interface IForgeItemStack extends ICapabilitySerializable<CompoundNBT>
{
return getStack().getItem().isEnderMask(getStack(), player, endermanEntity);
}
/**
* Used to determine if the player can use Elytra flight.
* This is called Client and Server side.
*
* @param entity The entity trying to fly.
* @return True if the entity can use Elytra flight.
*/
default boolean canElytraFly(LivingEntity entity)
{
return getStack().getItem().canElytraFly(getStack(), entity);
}
/**
* Used to determine if the player can continue Elytra flight,
* this is called each tick, and can be used to apply ItemStack damage,
* consume Energy, or what have you.
* For example the Vanilla implementation of this, applies damage to the
* ItemStack every 20 ticks.
*
* @param entity The entity currently in Elytra flight.
* @param flightTicks The number of ticks the entity has been Elytra flying for.
* @return True if the entity should continue Elytra flight or False to stop.
*/
default boolean elytraFlightTick(LivingEntity entity, int flightTicks)
{
return getStack().getItem().elytraFlightTick(getStack(), entity, flightTicks);
}
}