Search in sources :

Example 1 with EntityCoconutGrenade

use of net.tropicraft.core.common.entity.projectile.EntityCoconutGrenade in project Tropicraft by Tropicraft.

the class ItemCoconutBomb method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack itemstack = player.getHeldItem(hand);
    if (!itemstack.isEmpty()) {
        itemstack.shrink(1);
    }
    world.playSound((EntityPlayer) null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + 1f * 0.5F);
    if (!world.isRemote) {
        if (ArrayUtils.contains(TropicsConfigs.coconutBombWhitelist, player.getGameProfile().getName())) {
            world.spawnEntity(new EntityCoconutGrenade(world, player));
        } else {
            player.sendMessage(new TextComponentTranslation(I18n.translateToLocal("tropicraft.coconutBombWarning")));
        }
    }
    return new ActionResult<>(EnumActionResult.SUCCESS, itemstack);
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) EntityCoconutGrenade(net.tropicraft.core.common.entity.projectile.EntityCoconutGrenade) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemStack (net.minecraft.item.ItemStack)1 ActionResult (net.minecraft.util.ActionResult)1 EnumActionResult (net.minecraft.util.EnumActionResult)1 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)1 EntityCoconutGrenade (net.tropicraft.core.common.entity.projectile.EntityCoconutGrenade)1