@Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); ItemStack ammoStack = findAmmo(player); if (player.capabilities.isCreativeMode || !ammoStack.isEmpty()) { world.playSound(null, player.getPosition(), SoundEvents.ENTITY_GHAST_SHOOT, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!world.isRemote) { Vec3d look = player.getLookVec(); double direction = Math.toRadians(player.renderYawOffset); double directionY = Math.toRadians(player.cameraPitch); EntitySmallFireball fireball = new EntitySmallFireball(world, player, 1, 1, 1); fireball.setPosition(player.posX + -Math.sin(direction) * 1, player.posY + Math.cos(directionY) * 1.2D, player.posZ + Math.cos(direction) * 1); fireball.accelerationX = look.x * 0.1; fireball.accelerationY = look.y * 0.1; fireball.accelerationZ = look.z * 0.1; world.spawnEntity(fireball); } } if (!player.capabilities.isCreativeMode && !ammoStack.isEmpty()) { ammoStack.shrink(1); if (ammoStack.getCount() <= 0) player.inventory.deleteStack(ammoStack); stack.damageItem(10, player); } player.swingArm(hand); return new ActionResult(EnumActionResult.SUCCESS, stack); }
@Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); ItemStack ammoStack = findAmmo(player); if (player.capabilities.isCreativeMode || !ammoStack.isEmpty()) { world.playSound(null, player.getPosition(), ModSounds.WEBSLING_THROW, SoundCategory.PLAYERS, 1.0F, 1.0F); if (!world.isRemote) { EntityWebSling web = new EntityWebSling(world, player); web.posY = player.posY + player.height / 2.0F; web.setType(getShootType()); web.shoot(player, player.rotationPitch, player.rotationYaw, 0F, 1.5F, 0F); world.spawnEntity(web); } } if (!player.capabilities.isCreativeMode && !ammoStack.isEmpty()) { ammoStack.shrink(1); if (ammoStack.getCount() <= 0) player.inventory.deleteStack(ammoStack); stack.damageItem(1, player); } player.swingArm(hand); return new ActionResult(EnumActionResult.SUCCESS, stack); }
player.inventory.deleteStack(glas);
fuel.shrink(1); if (fuel.getCount() == 0) player.inventory.deleteStack(fuel);
@Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack stack = playerIn.getHeldItem(hand); if (!stack.isEmpty() && stack.getItem().equals(ModItems.injection) && stack.getMetadata() == ItemInjection.META_GARLIC) { IFactionPlayerHandler handler = VampirismAPI.getFactionPlayerHandler(playerIn); IPlayableFaction faction = handler.getCurrentFaction(); if (handler.canJoin(faction)) { if (worldIn.isRemote) { VampirismMod.proxy.renderScreenFullColor(4, 30, 0xBBBBBBFF); } else { handler.joinFaction(VReference.HUNTER_FACTION); playerIn.addPotionEffect(new PotionEffect(MobEffects.POISON, 200, 1)); } stack.shrink(1); if (stack.isEmpty()) { playerIn.inventory.deleteStack(stack); } } else if (faction != null) { if (!worldIn.isRemote) { playerIn.sendMessage(new TextComponentTranslation("text.vampirism.med_chair_other_faction", new TextComponentTranslation(faction.getUnlocalizedName()))); } } } else { if (worldIn.isRemote) playerIn.sendMessage(new TextComponentTranslation("text.vampirism.need_item_to_use", new TextComponentTranslation((new ItemStack(ModItems.injection, 1, ItemInjection.META_GARLIC)).getUnlocalizedName() + ".name"))); } return true; }
entityplayer.inventory.deleteStack(itemstack);
player.inventory.deleteStack(itemstack);
entityplayer.inventory.deleteStack(itemstack);
player.inventory.deleteStack(arrowStack);
player.inventory.deleteStack(itemstack);
arrowStack.shrink(1); if (arrowStack.isEmpty()) { player.inventory.deleteStack(arrowStack);