Advertisement
JackPS9

ExampleMod Block

May 21st, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.52 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using System.IO;
  3. using PhentrixGames.NewColonyAPI.Classes;
  4.  
  5. namespace Examaple.Classes
  6. {  
  7.     /// <summary>
  8.     /// PhentrixGames.NewColonyAPI.Classes.Type - is the main class that will allow the items to be created easily.
  9.     /// PhentrixGames.NewColonyAPI.Interfaces.IAutoType - This interface is searched for by the API and adds the items to the game
  10.     /// </summary>
  11.     [TypeAttribute]
  12.     public class ExampleBlock : PhentrixGames.NewColonyAPI.Classes.Type
  13.     {
  14.         //This is the class where you'll put the item together.
  15.         //"ExampleBlock" is what the game will know the item as without localization (aka this.TypeName)
  16.         //The true/false part is if you want to override the recipe function within this class or not. (the recipes can also be made in seperate files)
  17.         public ExampleBlock() : base("ExampleBlock", true)
  18.         {
  19.             //Should the block be solid (player can't walk thru solid blocks)
  20.             this.IsSolid = true;
  21.  
  22.             //This is how to give the item an icon, it requires a full path to the icon.
  23.             //So if your icons are in your mod's folder the code would be...
  24.             this.Icon = Path.Combine(ModEntry.ModGamedataDirectory, "ExampleBlockIcon.png");
  25.             //Note that icons have to be 64x64 pixels
  26.  
  27.             //Can the player break this block (true = yes, false = no)
  28.             this.IsDestructible = true;
  29.  
  30.             //How long does it take to destroy the block in milliseconds.
  31.             this.DestructionTime = 0;
  32.  
  33.             //Can this item be placed in the world?
  34.             this.IsPlaceable = true;
  35.         }
  36.  
  37.         //If you put true in the base you'll need this function.
  38.         //Returning base.AddRecipes() will cause it to error, so you'll have to make the recipe.
  39.         public override List<BaseRecipe> AddRecipes()
  40.         {
  41.             List<BaseRecipe> ret = new List<BaseRecipe>();      //We will need to make a list of BaseRecipe to be able to return
  42.             BaseRecipe rec1 = new BaseRecipe("exampleblockrecipe", true); //BaseRecipe takes a string (ID) and a bool(can the player craft this item)
  43.             InventoryItem result = new InventoryItem("ExampleBlock"); //This is the result of the BaseRecipe (Note you can have NPCs receive more then a single result)
  44.             rec1.Result.Add(result); //We now add the result to the recipe
  45.             InventoryItem requirements = new InventoryItem("logtemperate"); //Now we setup the requirements for the recipe (we'll use a temperate log to make this block)
  46.             rec1.Requirements.Add(requirements); //Adding the requirement to the recipe now
  47.             ret.Add(rec1); //Adding our recipe to our list of recipes
  48.             return ret; //Returning our list of baserecipe
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement