Advertisement
Guest User

LootGenHandler.java

a guest
Nov 25th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.35 KB | None | 0 0
  1. package com.boxtop.epicloot;
  2.  
  3. import net.minecraft.src.EnumToolMaterial;
  4. import net.minecraft.src.ItemStack;
  5. import net.minecraft.src.NBTTagCompound;
  6. import net.minecraft.src.NBTTagList;
  7. import net.minecraft.src.NBTTagString;
  8. import net.minecraftforge.common.EnumHelper;
  9.  
  10. import java.util.Random;
  11.  
  12. public class LootGenHandler {
  13.  
  14. private static final int MAX_USES = 300;
  15. private static final int MAX_DAMAGE = 6;
  16. private static final int TOTAL_SWORD_IMAGES = 47;
  17.  
  18. private static Random rndgen = new Random();
  19.  
  20. public static String GenerateName()
  21. {
  22.     return (ItemNamer.GenerateFullName());
  23. }
  24.  
  25. public static int GenerateDamageValue()
  26. {
  27.     int dmg = rndgen.nextInt(MAX_DAMAGE);
  28.     return dmg;
  29. }
  30.  
  31. public static int GenerateMaxUses()
  32. {
  33.     int durb = rndgen.nextInt(MAX_USES) + 1;
  34.     return durb;
  35. }
  36.  
  37. public static int GenUsesBasedOnDamage(int dmgVal)
  38. {
  39.     return 0;
  40. }
  41.  
  42. public static int getRandomSwordImgID()
  43. {
  44.     int imgid = rndgen.nextInt(TOTAL_SWORD_IMAGES);
  45.     return imgid;
  46. }
  47.  
  48. //this function is not used currently
  49. public static ItemStack SetToolDamage(ItemStack itemstack, int dmgVal)
  50. {
  51.     NBTTagCompound tag = itemstack.stackTagCompound;
  52.  
  53.     if (tag == null)
  54.     {
  55.         tag = new NBTTagCompound();
  56.         itemstack.stackTagCompound = tag;
  57.     }
  58.  
  59.  
  60.     itemstack.stackTagCompound.setInteger("maxdamage", dmgVal);
  61.     return itemstack;
  62. }
  63.  
  64. //this function is not used currently
  65. public static int GetToolDamage(ItemStack itemstack)
  66. {
  67.     NBTTagCompound tag = itemstack.stackTagCompound;
  68.  
  69.     if (tag == null)
  70.     {
  71.         tag = new NBTTagCompound();
  72.         itemstack.stackTagCompound = tag;
  73.     }
  74.  
  75.     if (itemstack.stackTagCompound.hasKey("maxdamage"))
  76.     {
  77.         return itemstack.stackTagCompound.getInteger("maxdamage");
  78.     }
  79.     else
  80.     {
  81.         return 0;
  82.     }
  83.  
  84. }
  85.  
  86. //this function is not used currently
  87. public static ItemStack SetToolUses(ItemStack itemstack, int useVal)
  88. {
  89.     NBTTagCompound tag = itemstack.stackTagCompound;
  90.  
  91.     if (tag == null)
  92.     {
  93.         tag = new NBTTagCompound();
  94.         itemstack.stackTagCompound = tag;
  95.     }
  96.  
  97.  
  98.     itemstack.stackTagCompound.setInteger("maxuses", useVal);
  99.     return itemstack;
  100. }
  101.  
  102. //this function is not used currently
  103. public static int GetToolUses(ItemStack itemstack)
  104. {
  105.     NBTTagCompound tag = itemstack.stackTagCompound;
  106.  
  107.     if (tag == null)
  108.     {
  109.         tag = new NBTTagCompound();
  110.         itemstack.stackTagCompound = tag;
  111.     }
  112.  
  113.     if (itemstack.stackTagCompound.hasKey("maxuses"))
  114.     {
  115.         return itemstack.stackTagCompound.getInteger("maxuses");
  116.     }
  117.     else
  118.     {
  119.         return 0;
  120.     }
  121. }
  122.  
  123. public static ItemStack setIconIndex(ItemStack itemstack, int iconindex)
  124. {
  125.     NBTTagCompound tag = itemstack.stackTagCompound;
  126.  
  127.     if (tag == null)
  128.     {
  129.         tag = new NBTTagCompound();
  130.         itemstack.stackTagCompound = tag;
  131.     }
  132.  
  133.  
  134.     itemstack.stackTagCompound.setInteger("iconindex", iconindex);
  135.  
  136.     return itemstack;
  137. }
  138.  
  139. public static int getIconIndex(ItemStack itemstack)
  140. {
  141.     NBTTagCompound tag = itemstack.stackTagCompound;
  142.  
  143.     if (tag == null)
  144.     {
  145.         tag = new NBTTagCompound();
  146.         itemstack.stackTagCompound = tag;
  147.     }
  148.  
  149.     if (itemstack.stackTagCompound.hasKey("iconindex"))
  150.     {
  151.         return itemstack.stackTagCompound.getInteger("iconindex");
  152.     }
  153.     else
  154.     {
  155.         return 0;
  156.     }
  157. }
  158.  
  159. public static EnumToolMaterial GenToolMaterialEnum(int uses, int damage)
  160. {
  161.     EnumToolMaterial myMat = EnumHelper.addToolMaterial("mymat",
  162.                                 0,
  163.                                 uses,
  164.                                 4.0F,
  165.                                 damage,
  166.                                 0);
  167.  
  168.     return myMat;
  169. }
  170. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement