Advertisement
Guest User

Untitled

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