Guest User

Untitled

a guest
Sep 1st, 2016
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.14 KB | None | 0 0
  1. package com.mightydanp.eot.common.item;
  2.  
  3. import java.util.List;
  4.  
  5. import com.mightydanp.eot.api.common.item.IItem;
  6. import com.mightydanp.eot.common.EoT;
  7.  
  8. import net.minecraft.entity.Entity;
  9. import net.minecraft.entity.EntityLivingBase;
  10. import net.minecraft.entity.monster.EntityMob;
  11. import net.minecraft.entity.player.EntityPlayer;
  12. import net.minecraft.item.ItemStack;
  13. import net.minecraft.nbt.NBTTagCompound;
  14. import net.minecraft.util.EnumHand;
  15. import net.minecraft.util.text.TextComponentString;
  16. import net.minecraft.util.text.TextFormatting;
  17. import net.minecraft.world.World;
  18. import net.minecraftforge.fml.relauncher.Side;
  19. import net.minecraftforge.fml.relauncher.SideOnly;
  20.  
  21. /**
  22. * @auther MightyDanp date class created: Jul 22, 2016
  23. */
  24. class ItemMagicalStone extends IItem {
  25.  
  26. public static String emptyFirstLine = "This seems to be pulsing power.";
  27. public static String emptySecondLine = "It only happens whenever i get close to these creatures.";
  28. public static String emptyThirdLine = "I wonder if this is linked to them.";
  29.  
  30. public static String fullFirstLine = "The Magical Stone seems to be full?";
  31. public static String fullSecondLine = "It seems to be useless now.";
  32. public static String fullThirdLine = "I wonder whats inside?";
  33.  
  34. public static String coolDownFirstLine = "";
  35. public static String coolDownSecondLine = "Everytime I use this now it seems to get hotter.";
  36. public static String coolDownThirdLine = "Maybe I should let it cool off.";
  37.  
  38. public static String[] subItemsDescriptionsFirstLine = new String[] { fullFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine, emptyFirstLine };
  39. public static String[] subItemsDescriptionsSecondLine = new String[] { fullSecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine, emptySecondLine };
  40. public static String[] subItemsDescriptionsThirdLine = new String[] { fullThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine, emptyThirdLine };
  41.  
  42. public static String[] subItemsCoolDownDescriptionsFirstLine = new String[] { coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine, coolDownFirstLine };
  43. public static String[] subItemsCoolDownDescriptionsSecondLine = new String[] { coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine, coolDownSecondLine };
  44. public static String[] subItemsCoolDownDescriptionsThirdLine = new String[] { coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine, coolDownThirdLine };
  45.  
  46. public ItemMagicalStone(String unlocalizedName) {
  47. super(unlocalizedName);
  48. this.setCreativeTab(EoT.tabEoT);
  49. this.setMaxDamage(16);
  50. this.setMaxStackSize(1);
  51. this.setHasSubtypes(true);
  52. }
  53.  
  54. @Override
  55. public void onUpdate(ItemStack itemStack, World world, Entity entity, int i, boolean flag) {
  56. super.onUpdate(itemStack, world, entity, i, flag);
  57.  
  58. if (!world.isRemote) {
  59. NBTTagCompound nbtDataCompund;
  60. if (itemStack.hasTagCompound()) {
  61. nbtDataCompund = itemStack.getTagCompound();
  62. } else {
  63. nbtDataCompund = new NBTTagCompound();
  64. }
  65.  
  66. int coolDown = nbtDataCompund.getInteger("coolDown");
  67. if (coolDown > 0) {
  68. --coolDown;
  69. nbtDataCompund.setInteger("coolDown", coolDown);
  70. }
  71. }
  72. }
  73.  
  74. @Override
  75. public boolean itemInteractionForEntity(ItemStack itemStack, EntityPlayer entityPlayer, EntityLivingBase entity, EnumHand hand) {
  76.  
  77. NBTTagCompound nbt;
  78. if (itemStack.hasTagCompound()) {
  79. nbt = itemStack.getTagCompound();
  80. } else {
  81. nbt = new NBTTagCompound();
  82. }
  83. int coolDown = nbt.getInteger("coolDown");
  84.  
  85. if (coolDown > 0) {
  86. return false;
  87. }
  88.  
  89. if (coolDown == 0) {
  90. if (entity instanceof EntityMob) {
  91. if (itemStack.getItemDamage() > 0) {
  92. entity.setHealth(0.0F);
  93. nbt.setInteger("coolDown", 180);
  94. if (!entity.worldObj.isRemote) {
  95. entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "Soul Absurbed!"));
  96. }
  97. itemStack.damageItem(-1, entityPlayer);
  98. return true;
  99. } else {
  100. if (!entity.worldObj.isRemote) {
  101. entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "The Magical Stone seems to be full?"));
  102. entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "It seems to be useless now."));
  103. entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "I wonder whats inside?"));
  104. }
  105. return true;
  106. }
  107. } else if (!entity.worldObj.isRemote) {
  108. entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "Why has this stoped working?"));
  109. }
  110. } else {
  111. entityPlayer.addChatMessage(new TextComponentString(TextFormatting.GRAY + "Why has this stoped working?"));
  112. }
  113. return false;
  114. }
  115.  
  116. @SideOnly(Side.CLIENT)
  117. @Override
  118. public void addInformation(ItemStack itemStack, EntityPlayer player, List dataList, boolean bool) {
  119. if (itemStack.getItemDamage() < 12) {
  120. dataList.add(subItemsDescriptionsFirstLine[itemStack.getItemDamage()]);
  121. dataList.add(subItemsDescriptionsSecondLine[itemStack.getItemDamage()]);
  122. dataList.add(subItemsDescriptionsThirdLine[itemStack.getItemDamage()]);
  123. }
  124.  
  125. NBTTagCompound nbt;
  126. if (itemStack.hasTagCompound()) {
  127. nbt = itemStack.getTagCompound();
  128. } else {
  129. nbt = new NBTTagCompound();
  130. }
  131. int coolDown = nbt.getInteger("coolDown");
  132.  
  133. if (coolDown > 0) {
  134. dataList.add(subItemsCoolDownDescriptionsFirstLine[itemStack.getItemDamage()]);
  135. dataList.add(subItemsCoolDownDescriptionsSecondLine[itemStack.getItemDamage()]);
  136. dataList.add(subItemsCoolDownDescriptionsThirdLine[itemStack.getItemDamage()]);
  137. }
  138. }
  139.  
  140. @SideOnly(Side.CLIENT)
  141. @Override
  142. public boolean hasEffect(ItemStack itemStack) {
  143. if (itemStack.getItemDamage() > 0) {
  144. return false;
  145. } else {
  146. return itemStack.getItemDamage() == 0;
  147. }
  148. }
  149.  
  150. }
Advertisement
Add Comment
Please, Sign In to add comment