Advertisement
Guest User

Untitled

a guest
Oct 7th, 2015
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.58 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.entity.Entity;
  14. import net.minecraft.entity.EntityLivingBase;
  15. import net.minecraft.entity.monster.EntityMob;
  16. import net.minecraft.entity.player.EntityPlayer;
  17. import net.minecraft.item.Item;
  18. import net.minecraft.item.ItemStack;
  19. import net.minecraft.util.AxisAlignedBB;
  20. import net.minecraft.util.ChatComponentText;
  21. import net.minecraft.util.EnumChatFormatting;
  22. import net.minecraft.world.World;
  23.  
  24. public class ItemMagicalStone extends Item{
  25.  
  26. public ItemMagicalStone(String unlocalizedName){
  27. this.setCreativeTab(EotCore.eotTab);
  28. this.setUnlocalizedName(unlocalizedName);
  29. this.setTextureName(References.RESOURCESPREFIX + unlocalizedName);
  30. this.setMaxDamage(16);
  31. this.setMaxStackSize(1);
  32. GameRegistry.registerItem(this, unlocalizedName);
  33. }
  34.  
  35. private int cooldown = 180;
  36.  
  37. @SideOnly(Side.CLIENT)
  38. public void addInformation(ItemStack itemStack, EntityPlayer player, List dataList, boolean bool){
  39. if(itemStack.getItemDamage() > itemStack.getMaxDamage()){
  40. dataList.add("This seems to be pulsing power.");
  41. dataList.add("It only happens whenever i get close to these creatures.");
  42. dataList.add("I wonder if this is linked to them.");
  43. }else{
  44. dataList.add("The Magical Stone seems to be full?");
  45. dataList.add("It seems to be useless now.");
  46. dataList.add("I wonder whats inside?");
  47. if(cooldown < 180){
  48. dataList.add("");
  49. dataList.add("Everytime I use this now it seems to get hotter.");
  50. dataList.add("Maybe I should let it cool off.");
  51. }
  52. }
  53. }
  54.  
  55. @Override
  56. public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer entityplayer, EntityLivingBase entity ){
  57. if(!entity.worldObj.isRemote){
  58. return false;
  59. }
  60. if(cooldown == 180){
  61.  
  62. if (entity instanceof EntityMob){
  63.  
  64. if(itemstack.getItemDamage() > 0){
  65. entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY +"Soul Absurbed!"));
  66. itemstack.damageItem(-1, entityplayer);
  67. entity.setHealth(0.0F);
  68. return true;
  69. } else {
  70. entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "The Magical Stone seems to be full?"));
  71. entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "It seems to be useless now."));
  72. entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "I wonder whats inside?"));
  73. return true;
  74. }
  75.  
  76. }else{
  77. entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "Why has this stoped working?"));
  78. }
  79. }else{
  80. if(cooldown < 180){
  81. return false;
  82. }
  83. }
  84. cooldown = 0;
  85. return false;
  86. //return super.itemInteractionForEntity(itemstack, entityplayer, entity);
  87. }
  88.  
  89. @Override
  90. public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5){
  91. super.onUpdate(stack, world, entity, par4, par5);
  92. if(cooldown < 180){
  93. cooldown++;
  94. }
  95. if (!world.isRemote && stack.getItem() == ModItems.magicalStone){
  96.  
  97. int radius = 3;
  98. int x = (int)entity.posX;
  99. int y = (int)entity.posY;
  100. int z = (int)entity.posZ;
  101.  
  102. List entities = world.getEntitiesWithinAABB(EntityMob.class, entity.boundingBox.expand(x - radius, y - radius, z - radius));
  103.  
  104. for (int i = 0; i < entities.size(); i++){
  105. if (entity instanceof EntityMob){
  106. hasEffect(stack);
  107. break;
  108. }
  109. }
  110. }
  111. }
  112.  
  113. @SideOnly(Side.CLIENT)
  114. public boolean hasEffect(ItemStack itemStack)
  115. {
  116. if(itemStack.getItemDamage() > 0){
  117. return false;
  118. }else{
  119. return itemStack.getItemDamage() == 0;
  120. }
  121. }
  122.  
  123. public ItemStack onItemRightClick(ItemStack itemstack, World par2World, EntityPlayer entityplayer)
  124. {
  125. return itemstack;
  126. }
  127.  
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement