// Run on add to world (also runs when added by game - ie: when a crop grows to the next stage) public void OnAddAction(Vector3Int position, ushort newType, Players.Player causedBy) { ushort num; // check if the block below is fertile if (World.TryGetTypeAt(position.Add(0, -1, 0), out num) && ItemTypes.IsFertile(num)) { CropManager.trackCrop(position, this); } else { // Tell the user you can't do this Pipliz.Chatting.Chat.Send(causedBy, string.Format("{0} can't grow here! It's not fertile!", ItemTypes.IndexLookup.GetName(newType))); // Get the air block, and replace the new crop with it ushort airBlockID = ItemTypes.IndexLookup.GetIndex("air"); ServerManager.TryChangeBlock(position, airBlockID); // Give the user the block Stockpile s = Stockpile.GetStockPile(causedBy); // Give them an item back? s.Add(newType, 1); // Update it? s.SendUpdate(); } }