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

Okay, so invastagating led me to "how to", but I don't undestand why and where to look for answers:

 

There are 2 events for picking up items, one fired before - Forge (cancellable) one after on actual pickup (FML).

 

What I don't understand is why ItemStack in FML event is not "real" (it can't get full ItemStack data).

 

Forge:

@SubscribeEvent
public void entityPickup(EntityItemPickupEvent event)
{
	ItemStack stack = event.item.getEntityItem();
	if(stack != null)
	{
		System.out.println("EntityItemPickupEvent: " + stack + "   Size: " + stack.stackSize);
	}
}

 

FML:

@SubscribeEvent
public void itemPickup(ItemPickupEvent event)
{
	ItemStack stack = event.pickedUp.getEntityItem();
	if(stack != null)
	{
		System.out.println("ItemPickupEvent: " + stack + "   Size: " + stack.stackSize);
	}
}

(NBT is too lost in FML)

 

[16:17:44] [server thread/INFO] [sTDOUT]: [x.ForgeEvents:entityPickup:38]: EntityItemPickupEvent: 1xitem.stick@0   Size: 1
[16:17:44] [server thread/INFO] [sTDOUT]: [x.FMLEvents:itemPickup:33]: ItemPickupEvent: 0xitem.stick@0   Size: 0

[16:17:57] [server thread/INFO] [sTDOUT]: [x.ForgeEvents:entityPickup:38]: EntityItemPickupEvent: 59xitem.stick@0   Size: 59
[16:17:57] [server thread/INFO] [sTDOUT]: [x.FMLEvents:itemPickup:33]: ItemPickupEvent: 0xitem.stick@0   Size: 0

[16:18:07] [server thread/INFO] [sTDOUT]: [x.ForgeEvents:entityPickup:38]: EntityItemPickupEvent: 12xitem.stick@0   Size: 12
[16:18:07] [server thread/INFO] [sTDOUT]: [x.FMLEvents:itemPickup:33]: ItemPickupEvent: 0xitem.stick@0   Size: 0

 

I was trying to figure it out, but looking at how are they called leaves me with no explanation.

 

Also, why is this passed: (EntityItem#onCollideWithPlayer)

int hook = net.minecraftforge.event.ForgeEventFactory.onItemPickup(this, entityIn, itemstack);

...if the ForgeEventFactory#onItemPickup is not actually using that ItemStack? Asking because this is literally only difference between those two events.

net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerItemPickupEvent(entityIn, this);

 

Asking of pure curiosity.

1.7.10 is no longer supported by forge, you are on your own.

  • Author

Yup, that explains it.

 

vB9B5.jpg

 

This line was long enough for me to miss adding stack to inv.

if (this.delayBeforeCanPickup <= 0 && (this.owner == null || lifespan - this.age <= 200 || this.owner.equals(entityIn.getName())) && (hook == 1 || i <= 0 || entityIn.inventory.addItemStackToInventory(itemstack)))

 

*applauds*

1.7.10 is no longer supported by forge, you are on your own.

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.