Jump to content

Recommended Posts

Posted

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);
	}

}

Posted

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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.