public virtual void onItemSpawn(ItemEvent ev) { }
public static int NewItem(int X, int Y, int Width, int Height, int Type, int Stack = 1, bool noBroadcast = false) { int result; if (WorldGen.gen) { result = 0; } else { int num = 200; Main.item[200] = new Item(); if (Main.netMode != 1) { for (int i = 0; i < 200; i++) { if (!Main.item[i].active) { num = i; break; } } } ItemEvent itemEvent = new ItemEvent(Main.item[num]); PluginManager.callHook(Hook.ITEM_SPAWN, itemEvent); if (!itemEvent.getState()) { Main.item[num].active = false; result = -1; } else { if (num == 200 && Main.netMode != 1) { int num2 = 0; for (int i = 0; i < 200; i++) { if (Main.item[i].spawnTime > num2) { num2 = Main.item[i].spawnTime; num = i; } } } Main.item[num] = new Item(); Main.item[num].SetDefaults(Type); Main.item[num].position.X = (float)(X + Width / 2 - Main.item[num].width / 2); Main.item[num].position.Y = (float)(Y + Height / 2 - Main.item[num].height / 2); Main.item[num].wet = Collision.WetCollision(Main.item[num].position, Main.item[num].width, Main.item[num].height); Main.item[num].velocity.X = (float)Main.rand.Next(-20, 21) * 0.1f; Main.item[num].velocity.Y = (float)Main.rand.Next(-30, -10) * 0.1f; Main.item[num].active = true; Main.item[num].spawnTime = 0; Main.item[num].stack = Stack; if (Main.netMode == 2 && !noBroadcast) { NetMessage.SendData(21, -1, -1, "", num, 0f, 0f, 0f); Main.item[num].FindOwner(num); } else { if (Main.netMode == 0) { Main.item[num].owner = Main.myPlayer; } } result = num; } } return result; }