Search in sources :

Example 1 with ItemBowCavenic

use of cavern.item.ItemBowCavenic in project Cavern2 by kegare.

the class ClientEventHooks method onFOVUpdate.

@SubscribeEvent
public void onFOVUpdate(FOVUpdateEvent event) {
    EntityPlayer player = event.getEntity();
    if (!player.isHandActive()) {
        return;
    }
    ItemStack using = player.getActiveItemStack();
    if (using.isEmpty()) {
        return;
    }
    if (using.getItem() instanceof ItemBowIce) {
        float f = player.getItemInUseMaxCount() / 8.0F;
        if (f > 1.0F) {
            f = 1.0F;
        } else {
            f *= f;
        }
        event.setNewfov(event.getFov() * (1.0F - f * 0.15F));
    }
    if (using.getItem() instanceof ItemBowCavenic) {
        ItemBowCavenic.BowMode mode = ItemBowCavenic.BowMode.byItemStack(using);
        float zoom = mode.getZoomScale();
        if (zoom <= 0.0F) {
            return;
        }
        float f = player.getItemInUseMaxCount() / mode.getPullingSpeed();
        if (f > 1.0F) {
            f = 1.0F;
        } else {
            f *= f;
        }
        event.setNewfov(event.getFov() * (1.0F - f * zoom));
    }
}
Also used : ItemBowIce(cavern.item.ItemBowIce) ItemBowCavenic(cavern.item.ItemBowCavenic) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

ItemBowCavenic (cavern.item.ItemBowCavenic)1 ItemBowIce (cavern.item.ItemBowIce)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1