Advertisement
Guest User

Untitled

a guest
Oct 10th, 2015
105
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.mightydanp.eot.item;
  2.  
  3. import java.util.List;
  4.  
  5. import com.mightydanp.eot.EotCore;
  6. import com.mightydanp.eot.lib.ItemStrings;
  7. import com.mightydanp.eot.lib.References;
  8.  
  9. import cpw.mods.fml.common.registry.GameRegistry;
  10. import cpw.mods.fml.relauncher.Side;
  11. import cpw.mods.fml.relauncher.SideOnly;
  12. import net.minecraft.client.renderer.texture.IIconRegister;
  13. import net.minecraft.creativetab.CreativeTabs;
  14. import net.minecraft.entity.Entity;
  15. import net.minecraft.entity.EntityLivingBase;
  16. import net.minecraft.entity.monster.EntityMob;
  17. import net.minecraft.entity.player.EntityPlayer;
  18. import net.minecraft.item.Item;
  19. import net.minecraft.item.ItemStack;
  20. import net.minecraft.nbt.NBTTagCompound;
  21. import net.minecraft.util.AxisAlignedBB;
  22. import net.minecraft.util.ChatComponentText;
  23. import net.minecraft.util.EnumChatFormatting;
  24. import net.minecraft.util.IIcon;
  25. import net.minecraft.world.World;
  26.  
  27. public class ItemMagicalStone extends Item{
  28.  
  29.  
  30. public IIcon[] iconArray = new IIcon[subItems.length];
  31.  
  32. public static String[] subItems = new String[] {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""};
  33.  
  34. public static String emptyFirstLine = "This seems to be pulsing power.";
  35. public static String emptySecondLine = "It only happens whenever i get close to these creatures.";
  36. public static String emptyThirdLine = "I wonder if this is linked to them.";
  37.  
  38. public static String fullFirstLine = "The Magical Stone seems to be full?";
  39. public static String fullSecondLine = "It seems to be useless now.";
  40. public static String fullThirdLine = "I wonder whats inside?";
  41.  
  42. public static String coolDownFirstLine = "";
  43. public static String coolDownSecondLine = "Everytime I use this now it seems to get hotter.";
  44. public static String coolDownThirdLine = "Maybe I should let it cool off.";
  45.  
  46. public static String[] subItemsDescriptionsFirstLine = new String[] {fullFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine};
  47. public static String[] subItemsDescriptionsSecondLine = new String[] {fullSecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine};
  48. public static String[] subItemsDescriptionsThirdLine = new String[] {fullThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine};
  49.  
  50. public static String[] subItemsCoolDownDescriptionsFirstLine = new String[] {coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine};
  51. public static String[] subItemsCoolDownDescriptionsSecondLine = new String[] {coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine};
  52. public static String[] subItemsCoolDownDescriptionsThirdLine = new String[] {coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine};
  53.  
  54. public ItemMagicalStone(String unlocalizedName){
  55. this.setCreativeTab(EotCore.eotTab);
  56. this.setUnlocalizedName(unlocalizedName);
  57. this.setMaxDamage(16);
  58. this.setMaxStackSize(1);
  59. this.setHasSubtypes(true);
  60. }
  61.  
  62. @Override
  63. public void onUpdate(ItemStack itemStack, World world, Entity entity, int i, boolean flag){
  64. super.onUpdate(itemStack, world, entity, i, flag);
  65.  
  66. if (!world.isRemote){
  67. NBTTagCompound nbtDataCompund = itemStack.stackTagCompound;
  68. if (nbtDataCompund == null)
  69. {
  70. itemStack.stackTagCompound = new NBTTagCompound();
  71. nbtDataCompund = itemStack.getTagCompound();
  72. }
  73.  
  74. int coolDown = nbtDataCompund.getInteger("coolDown");
  75. if(coolDown > 0){
  76. --coolDown;
  77. nbtDataCompund.setInteger("coolDown", coolDown);
  78. }
  79. }
  80. }
  81.  
  82. @SideOnly(Side.CLIENT)
  83. public void addInformation(ItemStack itemStack, EntityPlayer player, List dataList, boolean bool){
  84. if(itemStack.getItemDamage() < subItems.length){
  85. dataList.add(subItemsDescriptionsFirstLine[itemStack.getItemDamage()]);
  86. dataList.add(subItemsDescriptionsSecondLine[itemStack.getItemDamage()]);
  87. dataList.add(subItemsDescriptionsThirdLine[itemStack.getItemDamage()]);
  88. }
  89.  
  90. int coolDown = itemStack.stackTagCompound.getInteger("coolDown");
  91.  
  92. if(coolDown > 0){
  93. dataList.add(subItemsCoolDownDescriptionsFirstLine[itemStack.getItemDamage()]);
  94. dataList.add(subItemsCoolDownDescriptionsSecondLine[itemStack.getItemDamage()]);
  95. dataList.add(subItemsCoolDownDescriptionsThirdLine[itemStack.getItemDamage()]);
  96. }
  97. }
  98.  
  99. @Override
  100. public boolean itemInteractionForEntity(ItemStack itemStack, EntityPlayer entityplayer, EntityLivingBase entity ){
  101.  
  102. int coolDown = itemStack.stackTagCompound.getInteger("coolDown");
  103.  
  104. if(coolDown > 0){
  105. return false;
  106. }
  107. if(coolDown == 0){
  108. if (entity instanceof EntityMob){
  109. if(itemStack.getItemDamage() > 0){
  110. entity.setHealth(0.0F);
  111. itemStack.stackTagCompound.setInteger("coolDown", 180);
  112. if(!entity.worldObj.isRemote){
  113. entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY +"Soul Absurbed!"));
  114. }
  115. itemStack.damageItem(-1, entityplayer);
  116. return true;
  117. }else{
  118. if(!entity.worldObj.isRemote){
  119. entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "The Magical Stone seems to be full?"));
  120. entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "It seems to be useless now."));
  121. entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "I wonder whats inside?"));
  122. }
  123. return true;
  124. }
  125. }else{
  126. if(!entity.worldObj.isRemote){
  127. entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "Why has this stoped working?"));
  128. }
  129. }
  130. }
  131. return false;
  132. }
  133.  
  134. @SideOnly(Side.CLIENT)
  135. public boolean hasEffect(ItemStack itemStack)
  136. {
  137. if(itemStack.getItemDamage() > 0){
  138. return false;
  139. }else{
  140. return itemStack.getItemDamage() == 0;
  141. }
  142. }
  143.  
  144. public ItemStack onItemRightClick(ItemStack itemstack, World par2World, EntityPlayer entityplayer)
  145. {
  146. return itemstack;
  147. }
  148.  
  149. @Override
  150. public void registerIcons(IIconRegister reg) {
  151. for (int i = 0; i < subItems.length; i ++) {
  152. this.iconArray[i] = reg.registerIcon(References.RESOURCESPREFIX + ItemStrings.MAGICALSTONE_NAME);
  153. }
  154. }
  155.  
  156. @Override
  157. public void getSubItems(Item item, CreativeTabs tab, List list) {
  158. for (int i = 0; i < subItems.length; i ++) {
  159. list.add(new ItemStack(item, 1, i));
  160. }
  161. }
  162.  
  163. @SideOnly(Side.CLIENT)
  164. public String getUnlocalizedName(ItemStack itemStack){
  165. return super.getUnlocalizedName();
  166. }
  167.  
  168. @SideOnly(Side.CLIENT)
  169. public IIcon getIconFromDamage(int meta){
  170. return this.iconArray[meta];
  171. }
  172.  
  173. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement