Posted November 20, 201311 yr I've made an enchantment that has a chance to smelt blocks when mined, however, I have run into a snag: adding drops is no problem, but removing them is. Here is my code: @ForgeSubscribe public void onHarvestBlocks(BlockEvent.HarvestDropsEvent event) { EntityPlayer player = event.harvester; ItemStack heldItem = player.inventory.getCurrentItem(); Block block = event.block; flameTouchAmount = EnchantmentHelper.getEnchantmentLevel(ArcaneEnchantments.flameTouch.effectId, heldItem); if(heldItem == null) { return; } else if(flameTouchAmount > 0) { isFlameTouched = true; } if(isFlameTouched = true) { if(player.worldObj.rand.nextInt(2) == 0) { // So I was going to use FurnaceRecipes, but then I decided against it because this way gives me more flexibility if(block == Block.oreIron) { event.drops.add(new ItemStack(Item.ingotIron, 1)); event.drops.remove(15); } if(block == Block.oreGold) { event.drops.add(new ItemStack(Item.ingotGold, 1)); event.drops.remove(Block.oreGold); } } } } The "event.drops.remove" has two options: an item index or an Object. I have tried various ways for each but either they do not work, or they crash the game because of an ArrayList error. If anyone point me in the right direction, that would be fantastic. I hope you have a great day, and thank you for taking the time to read this post/help me out.
November 20, 201311 yr Author So would for(int size = 0; size < event.drops.size(); size++) { ItemStack stack = event.drops.get(size).getEntityItem(); } be somewhere along those lines? Correct me if I'm wrong, but the int size is grabbing the ItemStack ArrayList size and then getting an EntityItem instance of it. So how would that assist me in removing the drop as an item index? Thanks.
November 20, 201311 yr Author Now that I have Eclipse reopened, they must've changed it to "getItem()" but you're right, it isn't needed. I will update this post once I try your suggestion. Thanks.
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.