Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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

}

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

  • 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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.