Advertisement
Guest User

Untitled

a guest
Oct 7th, 2015
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.84 KB | None | 0 0
  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 nbtTagCompound = new NBTTagCompound();
  68. if(nbtTagCompound == null){
  69. itemStack.stackTagCompound = new NBTTagCompound();
  70. nbtTagCompound = itemStack.stackTagCompound;
  71. }
  72.  
  73. int coolDown = nbtTagCompound.getInteger("coolDown");
  74. if(coolDown > 0){
  75. --coolDown;
  76. nbtTagCompound.setInteger("coolDown", coolDown);
  77. }
  78. }
  79.  
  80. if (!world.isRemote && itemStack.getItem() == ModItems.magicalStone){
  81.  
  82. int radius = 3;
  83. int x = (int)entity.posX;
  84. int y = (int)entity.posY;
  85. int z = (int)entity.posZ;
  86.  
  87. List entities = world.getEntitiesWithinAABB(EntityMob.class, entity.boundingBox.expand(x - radius, y - radius, z - radius));
  88.  
  89. for (int j = 0; i < entities.size(); i++){
  90. if (entity instanceof EntityMob){
  91. hasEffect(itemStack);
  92. break;
  93. }
  94. }
  95. }
  96. }
  97.  
  98. @SideOnly(Side.CLIENT)
  99. public void addInformation(ItemStack itemStack, EntityPlayer player, List dataList, boolean bool){
  100. if(itemStack.getItemDamage() < subItems.length){
  101. dataList.add(subItemsDescriptionsFirstLine[itemStack.getItemDamage()]);
  102. dataList.add(subItemsDescriptionsSecondLine[itemStack.getItemDamage()]);
  103. dataList.add(subItemsDescriptionsThirdLine[itemStack.getItemDamage()]);
  104. }
  105.  
  106. NBTTagCompound nbtTagCopund = new NBTTagCompound();
  107. int coolDown = nbtTagCopund.getInteger("coolDown");
  108.  
  109. if(coolDown > 0){
  110. dataList.add(subItemsCoolDownDescriptionsFirstLine[itemStack.getItemDamage()]);
  111. dataList.add(subItemsCoolDownDescriptionsSecondLine[itemStack.getItemDamage()]);
  112. dataList.add(subItemsCoolDownDescriptionsThirdLine[itemStack.getItemDamage()]);
  113. }
  114. }
  115.  
  116. @Override
  117. public boolean itemInteractionForEntity(ItemStack itemStack, EntityPlayer entityplayer, EntityLivingBase entity ){
  118. if(!entity.worldObj.isRemote){
  119. return false;
  120. }
  121.  
  122. NBTTagCompound nbtTagCompound = new NBTTagCompound();
  123. int coolDown = nbtTagCompound.getInteger("coolDown");
  124.  
  125. if(coolDown > 0){
  126. return false;
  127. }
  128. if(coolDown == 0){
  129. if (entity instanceof EntityMob){
  130. if(itemStack.getItemDamage() > 0){
  131. entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY +"Soul Absurbed!"));
  132. itemStack.damageItem(-1, entityplayer);
  133. entity.setHealth(0.0F);
  134. return true;
  135. }else{
  136. entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "The Magical Stone seems to be full?"));
  137. entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "It seems to be useless now."));
  138. entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "I wonder whats inside?"));
  139. return true;
  140. }
  141. }else{
  142.  
  143. entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "Why has this stoped working?"));
  144. }
  145. }
  146. nbtTagCompound.setInteger("coolDown", 180);;
  147. return false;
  148. }
  149.  
  150. @SideOnly(Side.CLIENT)
  151. public boolean hasEffect(ItemStack itemStack)
  152. {
  153. if(itemStack.getItemDamage() > 0){
  154. return false;
  155. }else{
  156. return itemStack.getItemDamage() == 0;
  157. }
  158. }
  159.  
  160. public ItemStack onItemRightClick(ItemStack itemstack, World par2World, EntityPlayer entityplayer)
  161. {
  162. return itemstack;
  163. }
  164.  
  165. @Override
  166. public void registerIcons(IIconRegister reg) {
  167. for (int i = 0; i < subItems.length; i ++) {
  168. this.iconArray[i] = reg.registerIcon(References.RESOURCESPREFIX + ItemStrings.MAGICALSTONE_NAME);
  169. }
  170. }
  171.  
  172. @Override
  173. public void getSubItems(Item item, CreativeTabs tab, List list) {
  174. for (int i = 0; i < subItems.length; i ++) {
  175. list.add(new ItemStack(item, 1, i));
  176. }
  177. }
  178.  
  179. @SideOnly(Side.CLIENT)
  180. public String getUnlocalizedName(ItemStack itemStack){
  181. return super.getUnlocalizedName();
  182. }
  183.  
  184. @SideOnly(Side.CLIENT)
  185. public IIcon getIconFromDamage(int meta){
  186. return this.iconArray[meta];
  187. }
  188.  
  189. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement