use of net.minecraftforge.event.entity.item.ItemTossEvent in project MinecraftForge by MinecraftForge.
the class ForgeHooks method onPlayerTossEvent.
@Nullable
public static EntityItem onPlayerTossEvent(@Nonnull EntityPlayer player, @Nonnull ItemStack item, boolean includeName) {
player.captureDrops = true;
EntityItem ret = player.dropItem(item, false, includeName);
player.capturedDrops.clear();
player.captureDrops = false;
if (ret == null) {
return null;
}
ItemTossEvent event = new ItemTossEvent(ret, player);
if (MinecraftForge.EVENT_BUS.post(event)) {
return null;
}
if (!player.world.isRemote) {
player.getEntityWorld().spawnEntity(event.getEntityItem());
}
return event.getEntityItem();
}
Aggregations