Posted July 7, 20169 yr Hey ! Recently I've make an item that can store mobs ( a Pokeball actually ) which can be fired with a kind of rocket pokelauncher. I've some problems in here to differentiate my Pokeballs ( Empty or Not ) I find something to differentiate them at the end when it gets consummed : playerIn.inventory.clearMatchingItems(IFItems.Pokeball, 1, 1, null); But I can't find anything like that to differentiate the 2 pokeballs in my rocket pokelauncher. Code of the rocket pokelauncher : public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityPlayer playerIn, int timeLeft) { boolean item = playerIn.inventory.hasItem(IFItems.Pokeball); boolean crea = playerIn.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0; if (item || crea) { int i = this.getMaxItemUseDuration(stack) - timeLeft; net.minecraftforge.event.entity.player.ArrowLooseEvent event = new net.minecraftforge.event.entity.player.ArrowLooseEvent(playerIn, stack, i); if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return; i = event.charge; float f = (float)i / 20.0F; f = (f * f + f * 2.0F) / 3.0F; if ((double)f < 0.1D) { return; } if (f > 1.0F) { f = 1.0F; } EntityPokeball entitypb = new EntityPokeball(worldIn, playerIn, f * 2.0F); worldIn.playSoundAtEntity(playerIn, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); if (crea) { entitypb.canBePickedUp = 0; } else { playerIn.inventory.clearMatchingItems(IFItems.Pokeball, 1, 1, null); } if (!worldIn.isRemote) { worldIn.spawnEntityInWorld(entitypb); } } } Thanks for your help in advance.
July 7, 20169 yr "But I can't find anything like that to differentiate the 2 pokeballs in my rocket pokelauncher." I don't quite understand? ItemStack is ItemStack, if you have its instance you can "differentiate" it anywhere. #clearMatchingItems is an utility method, if you can't use it where you want to use it - simply write your own... 1.7.10 is no longer supported by forge, you are on your own.
July 8, 20169 yr Author Sorry for my stupid question. Thanks for your answer. I did this and it's working so playerIn.inventory.hasItemStack(new ItemStack(IFItems.Pokeball, 1/*amout*/, 1/*metadata*/));
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.