Search in sources :

Example 1 with EntityEnderPearcel

use of com.miningmark48.pearcelmod.entity.EntityEnderPearcel in project Pearcel-Mod by MiningMark48.

the class ItemEnderPearcel method onItemRightClick.

@Override
public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
    float velocity = ConfigurationHandler.enderPearcelVelocity;
    if (!player.isCreative()) {
        if (hasEnoughEnergy(stack, ConfigurationHandler.rfPerUse_enderPearcel, player)) {
            useEnergy(stack, ConfigurationHandler.rfPerUse_enderPearcel, false, player);
        } else {
            stack.damageItem(1, player);
        }
    }
    if (ConfigurationHandler.doEnderPearcelCooldown) {
        player.getCooldownTracker().setCooldown(this, ConfigurationHandler.enderPearcelCooldownTime * 20);
    }
    world.playSound(player, player.getPosition(), SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 0.5F, 0.4F);
    if (!world.isRemote) {
        EntityEnderPearcel pearl = new EntityEnderPearcel(world, player);
        pearl.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0F, velocity, 0.0F);
        world.spawnEntity(pearl);
    }
    return new ActionResult(EnumActionResult.SUCCESS, stack);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) EntityEnderPearcel(com.miningmark48.pearcelmod.entity.EntityEnderPearcel)

Aggregations

EntityEnderPearcel (com.miningmark48.pearcelmod.entity.EntityEnderPearcel)1 ActionResult (net.minecraft.util.ActionResult)1 EnumActionResult (net.minecraft.util.EnumActionResult)1