Advertisement
HalestormXV

Untitled

Aug 19th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.32 KB | None | 0 0
  1. package halestormxv.eAngelus.items;
  2.  
  3. import java.lang.reflect.InvocationTargetException;
  4. import java.util.List;
  5. import java.util.Random;
  6.  
  7. import halestormxv.eAngelus.items.cards.O_card_Fire;
  8. import halestormxv.eAngelus.items.cards.O_card_Lightning;
  9. import halestormxv.eAngelus.items.cards.O_card_Strength;
  10. import halestormxv.eAngelus.items.cards.O_card_Wind;
  11. import halestormxv.eAngelus.items.cards.O_card_Wither;
  12. import halestormxv.eAngelus.main.Reference;
  13. import net.minecraft.creativetab.CreativeTabs;
  14. import net.minecraft.entity.Entity;
  15. import net.minecraft.entity.EntityLivingBase;
  16. import net.minecraft.entity.effect.EntityLightningBolt;
  17. import net.minecraft.entity.passive.EntityTameable;
  18. import net.minecraft.entity.player.EntityPlayer;
  19. import net.minecraft.entity.player.EntityPlayerMP;
  20. import net.minecraft.init.SoundEvents;
  21. import net.minecraft.item.EnumAction;
  22. import net.minecraft.item.EnumRarity;
  23. import net.minecraft.item.Item;
  24. import net.minecraft.item.ItemStack;
  25. import net.minecraft.nbt.NBTTagCompound;
  26. import net.minecraft.util.ActionResult;
  27. import net.minecraft.util.EnumActionResult;
  28. import net.minecraft.util.EnumFacing;
  29. import net.minecraft.util.EnumHand;
  30. import net.minecraft.util.SoundCategory;
  31. import net.minecraft.util.math.BlockPos;
  32. import net.minecraft.util.text.TextComponentString;
  33. import net.minecraft.world.World;
  34. import net.minecraftforge.fml.relauncher.Side;
  35. import net.minecraftforge.fml.relauncher.SideOnly;
  36.  
  37. public class eAngelusCards extends Item
  38. {
  39.     static public final int CHARGE_UP_INITIAL_PAUSE_TICKS = 10;
  40.     static public final int CHARGE_UP_DURATION_TICKS = 20;
  41.  
  42.     //Offense Card Names
  43.     public static final String[] O_cardNames = new String[] {"cIgnis", "cFortitudo", "cVentus", "cArescet", "cLightning"};
  44.  
  45.  
  46.     public eAngelusCards(String unlocalizedName)
  47.     {
  48.         this.setUnlocalizedName(unlocalizedName);
  49.         this.setCreativeTab(Reference.eaCreativeTab);
  50.         this.setHasSubtypes(true);
  51.     }
  52.  
  53.     public EnumAction getItemUseAction(ItemStack itemstack)
  54.     {
  55.         return EnumAction.BLOCK;
  56.     }
  57.  
  58.     @Override
  59.     public int getMaxItemUseDuration(ItemStack stack)
  60.     {
  61.         return CHARGE_UP_DURATION_TICKS + CHARGE_UP_INITIAL_PAUSE_TICKS;
  62.     }
  63.  
  64.     @Override
  65.     public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
  66.     {
  67.         if (playerIn.isSneaking())
  68.         {
  69.             playerIn.setActiveHand(hand); // start the charge up sequence
  70.             return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn);
  71.         }else{  
  72.             playerIn.addChatComponentMessage(new TextComponentString("You need to be sneaking to activate an ORDER."));
  73.             return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
  74.         }
  75.     }
  76.  
  77.     @Override
  78.     public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
  79.     {
  80.         if (!worldIn.isRemote)
  81.         {
  82.             if (entityLiving instanceof EntityPlayer)
  83.             {
  84.                 int j = getMaxItemUseDuration(stack);
  85.                 EntityPlayer entityPlayer = (EntityPlayer)entityLiving;
  86.                 List<EntityLivingBase> targetList = entityPlayer.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, entityPlayer.getCollisionBoundingBox().expand(8.0F + j, 8.0F + j, 8.0F + j));
  87.                 for (EntityLivingBase targets : targetList)
  88.                 {
  89.                     if ( targets != null)
  90.                     {
  91.                         if ( targets != entityPlayer )
  92.                         {
  93.                             entityPlayer.worldObj.spawnEntityInWorld(new EntityLightningBolt(worldIn, targets.posX, targets.posY, targets.posZ, true) );
  94.                             targets.clearActivePotions();
  95.                             worldIn.createExplosion(targets, targets.posX, targets.posY, targets.posZ, 3.2F + (j / 2), true);
  96.                             targets.setHealth(targets.getHealth() - j);
  97.                             //world.playSoundAtEntity(targets, RefStrings.MODID + ":leo_gift_execute", 1.4F, 1.0F);
  98.                         }
  99.                     }
  100.                 }
  101.             }
  102.         }
  103.         return null;
  104.         //      for items with multiple count, decrease stack size and return the itemstack, eg
  105.         //      stack.stackSize--;
  106.         //      return stack;
  107.     }
  108.  
  109.     //===============================AUTO HANDLE UNLOCALIZED NAMES===============================\\
  110.     @Override
  111.     public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> items)
  112.     {
  113.         for (int i = 0; i < O_cardNames.length; ++i)
  114.         {
  115.             items.add(new ItemStack(item, 1, i));
  116.         }
  117.     }
  118.  
  119.     @Override
  120.     public String getUnlocalizedName(ItemStack stack)
  121.     {
  122.         for (int i = 0; i < O_cardNames .length; ++i)
  123.             if(stack.getItemDamage() == i)
  124.             {
  125.                 return this.getUnlocalizedName() + "." + O_cardNames[i];
  126.             }
  127.         return "Invalid";
  128.     }  
  129.     //===============================CLIENT SIDE SNAZZY FLAVOR TEXT AND FUN STUFF===============================\\
  130.     @Override
  131.     @SideOnly(Side.CLIENT)
  132.     public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
  133.     {
  134.         if (stack.getItemDamage() == 0)
  135.         {
  136.             tooltip.add("");
  137.             tooltip.add("\u00A76" + "You fall into my arms.");
  138.             tooltip.add("\u00A76" + "You are the good gift of destruction's path.");
  139.             tooltip.add("\u00A76" + "When life sickens more than disease.");
  140.             tooltip.add("\u00A76" + "And boldness is the root of beauty...");
  141.             tooltip.add("");
  142.             tooltip.add("\u00A7n" + "Calls forth fire supreme.");
  143.         }
  144.     }
  145.  
  146.     @Override
  147.     @SideOnly(Side.CLIENT)
  148.     public EnumRarity getRarity(ItemStack stack)
  149.     {
  150.         if (stack.getItemDamage() == 0)
  151.         {
  152.             return EnumRarity.UNCOMMON;
  153.         }else{
  154.             return EnumRarity.COMMON;
  155.         }
  156.     }
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement