Jump to content

Creating EntityItem with an ItemStack on player position using player's held item makes an un-pickupable item until server restart (FIXED)


Recommended Posts

Posted (edited)
ItemStack stack = new ItemStack();
stack = byPlayer.InventoryManager.ActiveHotbarSlot.Itemstack;
EntityItem item =(EntityItem) sapi.World.SpawnItemEntity(stack, byPlayer.Entity.Pos.XYZ.Add(0, 1, 0));

This creates a copy of whatever is in the player's hand, but once spawned in, it's un-collectable until server restart (after server restart, it returns to normal). I checked .canCollect() and it returns false. Thank you for any help to make this entity collectable.

Edit: also tested without making the entity a EntityItem forcefully, still doesn't work :|

Edited by Christian Lewis
Fixed the issue.
Posted

Fixed: stack was being considered as already picked up, as it wasnt a copy of the item in hand, it was the item held in hand, so the game basically though what was in my hand was on the ground, and it wouldn't be recognized as a pickupable itemstack. This is easily fixed by doing stack.SetFrom(byPlayer.InventoryManager.ActiveHotbarSlot.Itemstack); instead of setting it equal to it.

  • Christian Lewis changed the title to Creating EntityItem with an ItemStack on player position using player's held item makes an un-pickupable item until server restart (FIXED)
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.