Search in sources :

Example 1 with BowItem

use of net.minecraft.item.BowItem in project NetherEx by LogicTechCorp.

the class RenderEventHandler method onFOVChange.

@SubscribeEvent
public static void onFOVChange(FOVUpdateEvent event) {
    PlayerEntity player = event.getEntity();
    if (player.isPotionActive(NetherExEffects.FROZEN.get())) {
        float fov = 1.0F;
        if (player.abilities.isFlying) {
            fov *= 1.1F;
        }
        if (player.isHandActive() && player.getActiveItemStack().getItem() instanceof BowItem) {
            float useCount = (float) player.getItemInUseMaxCount() / 20.0F;
            if (useCount > 1.0F) {
                useCount = 1.0F;
            } else {
                useCount = useCount * useCount;
            }
            fov *= 1.0F - useCount * 0.15F;
        }
        event.setNewfov(fov);
    }
}
Also used : BowItem(net.minecraft.item.BowItem) PlayerEntity(net.minecraft.entity.player.PlayerEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 BowItem (net.minecraft.item.BowItem)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1