Posted December 13, 201311 yr Hi, I'm using the dropFewItems method and Im making it have a 1/2 chance of the coal dropping with 1-3 pieces However, if it has looting, then amountToDrop gets timed by the lootenchantment. Which is the part which isn't working. The loot enchantment. I looked at the call of the method and lootEnchantLevel is just set to 0. How does it get the actual looting enchantment level. Code: /** * Drop 0-2 items of this living's type. @param par1 - Whether this entity has recently been hit by a player. @param * par2 - Level of Looting used to kill this mob. */ @Override protected void dropFewItems(boolean hitByPlayer, int lootEnchantLevel) { super.dropFewItems(hitByPlayer, lootEnchantLevel); int ranNum, amountToDrop; ranNum = this.rand.nextInt(2); amountToDrop = this.rand.nextInt(3 + 1); if(! (this.isBurning())) { if(lootEnchantLevel == 0) { if(ranNum == 1) { this.dropItem(Item.coal.itemID, amountToDrop); } } else { this.dropItem(Item.coal.itemID, amountToDrop * lootEnchantLevel); } this.dropItem(Item.spiderEye.itemID, 1); } }
December 14, 201311 yr Hi Why do you think the lootEnchantLevel is always set to 0? For example in EntityLivingBase.onDeath: public void onDeath(DamageSource par1DamageSource) { if (ForgeHooks.onLivingDeath(this, par1DamageSource)) return; Entity entity = par1DamageSource.getEntity(); // .. etc ... int i = 0; if (entity instanceof EntityPlayer) { i = EnchantmentHelper.getLootingModifier((EntityLivingBase)entity); } // .. etc ... this.dropFewItems(this.recentlyHit > 0, i); -TGG
December 14, 201311 yr Author @TGG I didn't notice that before, anyway, I managed to solve it on my own with some logic and thinking. Thanks anyway.
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.