Advertisement
HalestormXV

Untitled

Aug 21st, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.87 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.main.Reference;
  8. import halestormxv.eAngelus.main.init.eAngelusItems;
  9. import net.minecraft.creativetab.CreativeTabs;
  10. import net.minecraft.entity.Entity;
  11. import net.minecraft.entity.EntityLivingBase;
  12. import net.minecraft.entity.effect.EntityLightningBolt;
  13. import net.minecraft.entity.passive.EntityTameable;
  14. import net.minecraft.entity.player.EntityPlayer;
  15. import net.minecraft.entity.player.EntityPlayerMP;
  16. import net.minecraft.entity.projectile.EntityLargeFireball;
  17. import net.minecraft.init.Items;
  18. import net.minecraft.init.MobEffects;
  19. import net.minecraft.init.SoundEvents;
  20. import net.minecraft.item.EnumAction;
  21. import net.minecraft.item.EnumRarity;
  22. import net.minecraft.item.Item;
  23. import net.minecraft.item.ItemStack;
  24. import net.minecraft.nbt.NBTTagCompound;
  25. import net.minecraft.potion.Potion;
  26. import net.minecraft.potion.PotionEffect;
  27. import net.minecraft.util.ActionResult;
  28. import net.minecraft.util.EnumActionResult;
  29. import net.minecraft.util.EnumFacing;
  30. import net.minecraft.util.EnumHand;
  31. import net.minecraft.util.SoundCategory;
  32. import net.minecraft.util.math.BlockPos;
  33. import net.minecraft.util.math.Vec3d;
  34. import net.minecraft.util.text.TextComponentString;
  35. import net.minecraft.world.World;
  36. import net.minecraftforge.fml.common.registry.ForgeRegistries;
  37. import net.minecraftforge.fml.relauncher.Side;
  38. import net.minecraftforge.fml.relauncher.SideOnly;
  39.  
  40. public class eAngelusCards extends Item
  41. {
  42.     static public final int CHARGE_UP_INITIAL_PAUSE_TICKS = 10;
  43.     static public final int CHARGE_UP_DURATION_TICKS = 20;
  44.  
  45.     //Offense Card Names
  46.     public static final String[] O_cardNames = new String[] {"cIgnis", "cFortitudo", "cVentus", "cArescet", "cLightning"};
  47.  
  48.     public eAngelusCards(String unlocalizedName)
  49.     {
  50.         this.setUnlocalizedName(unlocalizedName);
  51.         this.setCreativeTab(Reference.eaCreativeTab);
  52.         this.setMaxStackSize(1);
  53.         this.setMaxDamage(-1);
  54.         this.setHasSubtypes(true);
  55.     }
  56.  
  57.     public boolean isDamageable()
  58.     {
  59.         return false;
  60.     }
  61.  
  62.     public EnumAction getItemUseAction(ItemStack itemstack)
  63.     {
  64.         return EnumAction.BLOCK;
  65.     }
  66.  
  67.     @Override
  68.     public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
  69.     {
  70.         if (playerIn.inventory.hasItemStack(new ItemStack(getItemUsedByORDER())))
  71.         {
  72.             if (playerIn.isSneaking())
  73.             {
  74.                 playerIn.setActiveHand(hand); // start the charge up sequence
  75.                 return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn);
  76.             }
  77.             else
  78.             {  
  79.                 playerIn.addChatComponentMessage(new TextComponentString("\u00A74You need to be sneaking to activate an ORDER."));
  80.                 return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
  81.             }
  82.         }
  83.         else
  84.         {
  85.             playerIn.addChatComponentMessage(new TextComponentString("You need \u00A76Mystal Dust \u00A7fto power an ORDER."));
  86.             return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
  87.         }
  88.     }
  89.  
  90.     @Override
  91.     public int getMaxItemUseDuration(ItemStack stack)
  92.     {
  93.         return CHARGE_UP_DURATION_TICKS + CHARGE_UP_INITIAL_PAUSE_TICKS;
  94.     }
  95.  
  96.  
  97.     //===============================HANDLE ALL CARD EFFECTS===============================\\
  98.     @Override
  99.     public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
  100.     {
  101.         switch(stack.getItemDamage())
  102.         {
  103.         case 0:
  104.             if (entityLiving instanceof EntityPlayer)
  105.             {
  106.                 for(int i = 0; i <=3; i++)
  107.                 {
  108.                     Vec3d look = entityLiving.getLookVec();
  109.                     EntityLargeFireball fireball2 = new EntityLargeFireball(worldIn, entityLiving, 1, 1, 1);
  110.                     fireball2.setPosition(entityLiving.posX + look.xCoord * 5 + i, entityLiving.posY + look.yCoord * 5, entityLiving.posZ + look.zCoord * 5 + i + 1);
  111.                     fireball2.accelerationX = look.xCoord * 0.3;
  112.                     fireball2.accelerationY = look.yCoord * 0.3;
  113.                     fireball2.accelerationZ = look.zCoord * 0.3;
  114.                     worldIn.spawnEntityInWorld(fireball2);
  115.                 }
  116.             }
  117.             break;
  118.  
  119.         case 1:
  120.             if (entityLiving instanceof EntityPlayer)
  121.             {
  122.                 EntityPlayer entityPlayer = (EntityPlayer) entityLiving;
  123.                 entityPlayer.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 500, 2));
  124.             }
  125.             break;
  126.  
  127.         case 2:
  128.             if (entityLiving instanceof EntityPlayer)
  129.             {
  130.                 EntityPlayer entityPlayer = (EntityPlayer) entityLiving;
  131.                 entityPlayer.addPotionEffect(new PotionEffect(MobEffects.SPEED, 500, 2));
  132.                 entityPlayer.addPotionEffect(new PotionEffect(MobEffects.JUMP_BOOST, 500, 2));
  133.             }
  134.             break;
  135.  
  136.         case 3:
  137.             if (entityLiving instanceof EntityPlayer)
  138.             {
  139.                 int j = getMaxItemUseDuration(stack) / Math.round(5);
  140.                 EntityPlayer entityPlayer = (EntityPlayer) entityLiving;
  141.  
  142.                 List<EntityLivingBase> targetList = entityPlayer.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, entityPlayer.getEntityBoundingBox().expand(8.0F + j, 8.0F + j, 8.0F + j));
  143.                 for (EntityLivingBase targets : targetList)
  144.                 {
  145.                     if ( targets != null)
  146.                     {
  147.                         if ( targets != entityPlayer )
  148.                         {
  149.                             targets.clearActivePotions();
  150.                             targets.addPotionEffect(new PotionEffect(MobEffects.WITHER, 500, 2 + j));
  151.                             targets.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 500, 2 + j));
  152.                             //world.playSoundAtEntity(targets, RefStrings.MODID + ":leo_gift_execute", 1.4F, 1.0F);
  153.                             System.out.println(j);
  154.                         }
  155.                     }
  156.                 }
  157.             }
  158.             break;
  159.  
  160.         case 4:
  161.             if (entityLiving instanceof EntityPlayer)
  162.             {
  163.                 int j = getMaxItemUseDuration(stack) / Math.round(5);
  164.                 EntityPlayer entityPlayer = (EntityPlayer) entityLiving;
  165.  
  166.                 List<EntityLivingBase> targetList = entityPlayer.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, entityPlayer.getEntityBoundingBox().expand(8.0F + j, 8.0F + j, 8.0F + j));
  167.                 for (EntityLivingBase targets : targetList)
  168.                 {
  169.                     if ( targets != null)
  170.                     {
  171.                         if ( targets != entityPlayer )
  172.                         {
  173.                             entityPlayer.worldObj.spawnEntityInWorld(new EntityLightningBolt(worldIn, targets.posX, targets.posY, targets.posZ, false) );
  174.                             targets.clearActivePotions();
  175.                             worldIn.createExplosion(targets, targets.posX, targets.posY, targets.posZ, 3.2F + (j / 2), true);
  176.                             targets.setHealth(targets.getHealth() - j);
  177.                             //world.playSoundAtEntity(targets, RefStrings.MODID + ":leo_gift_execute", 1.4F, 1.0F);
  178.                             System.out.println(j);
  179.                         }
  180.                     }
  181.                 }
  182.             }
  183.             break;
  184.         }
  185.         this.consumeReagent(stack, worldIn, (EntityPlayer) entityLiving);
  186.         return stack;
  187.         //      for items with multiple count, decrease stack size and return the itemstack, eg
  188.         //      stack.stackSize--;
  189.         //      return stack;
  190.     }
  191.  
  192.     protected void consumeReagent(ItemStack stack, World worldIn, EntityPlayer entityLiving) {
  193.         entityLiving.inventory.clearMatchingItems(getItemUsedByORDER(), -1, 1, null);
  194.     }
  195.  
  196.     protected Item getItemUsedByORDER()
  197.     {
  198.         return eAngelusItems.mystalDust;
  199.     }
  200.  
  201.     //===============================AUTO HANDLE UNLOCALIZED NAMES===============================\\
  202.     @Override
  203.     public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> items)
  204.     {
  205.         for (int i = 0; i < O_cardNames.length; ++i)
  206.         {
  207.             items.add(new ItemStack(item, 1, i));
  208.         }
  209.     }
  210.  
  211.     @Override
  212.     public String getUnlocalizedName(ItemStack stack)
  213.     {
  214.         for (int i = 0; i < O_cardNames .length; ++i)
  215.             if(stack.getItemDamage() == i)
  216.             {
  217.                 return this.getUnlocalizedName() + "." + O_cardNames[i];
  218.             }
  219.         return "Invalid";
  220.     }
  221.     //===============================CLIENT SIDE SNAZZY FLAVOR TEXT AND FUN STUFF===============================\\
  222.     @Override
  223.     @SideOnly(Side.CLIENT)
  224.     public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
  225.     {
  226.         if (stack.getItemDamage() == 0)
  227.         {
  228.             tooltip.add("");
  229.             tooltip.add("\u00A76" + "You fall into my arms.");
  230.             tooltip.add("\u00A76" + "You are the good gift of destruction's path.");
  231.             tooltip.add("\u00A76" + "When life sickens more than disease.");
  232.             tooltip.add("\u00A76" + "And boldness is the root of beauty...");
  233.             tooltip.add("");
  234.             tooltip.add("\u00A7n" + "Calls forth fire supreme.");
  235.         }
  236.         if (stack.getItemDamage() == 1)
  237.         {
  238.             tooltip.add("");
  239.             tooltip.add("\u00A76" + "You have power over your mind.");
  240.             tooltip.add("\u00A76" + "Not over outside events.");
  241.             tooltip.add("\u00A76" + "Realize this and you");
  242.             tooltip.add("\u00A76" + "will find strength..");
  243.             tooltip.add("");
  244.             tooltip.add("\u00A7n" + "Enhances physical strength.");
  245.         }
  246.         if (stack.getItemDamage() == 2)
  247.         {
  248.             tooltip.add("");
  249.             tooltip.add("\u00A76" + "He who does not know how");
  250.             tooltip.add("\u00A76" + "to look back at where he came");
  251.             tooltip.add("\u00A76" + "from will never get to his");
  252.             tooltip.add("\u00A76" + "destination...");
  253.             tooltip.add("");
  254.             tooltip.add("\u00A7n" + "Enhances Movement and Jump.");
  255.         }
  256.         if (stack.getItemDamage() == 3)
  257.         {
  258.             tooltip.add("");
  259.             tooltip.add("\u00A76" + "I like it that order exists somwhere,");
  260.             tooltip.add("\u00A76" + "even if it shatters near me.");
  261.             tooltip.add("\u00A76" + "Order will wither and born");
  262.             tooltip.add("\u00A76" + "will be chaos...");
  263.             tooltip.add("");
  264.             tooltip.add("\u00A7n" + "Inflicts Wither and Weakness around you.");
  265.         }
  266.         if (stack.getItemDamage() == 4)
  267.         {
  268.             tooltip.add("");
  269.             tooltip.add("\u00A76" + "Suddenly there was a great burst of");
  270.             tooltip.add("\u00A76" + "light through the Darkness.");
  271.             tooltip.add("\u00A76" + "The light spread out and where");
  272.             tooltip.add("\u00A76" + "it touched, Darkness disappeared..");
  273.             tooltip.add("");
  274.             tooltip.add("\u00A7n" + "Calls down a storm of lightning.");
  275.         }
  276.     }
  277.  
  278.     @Override
  279.     @SideOnly(Side.CLIENT)
  280.     public EnumRarity getRarity(ItemStack stack)
  281.     {
  282.         return EnumRarity.UNCOMMON;
  283.         /*if (stack.getItemDamage() == 0)
  284.         {
  285.             return EnumRarity.UNCOMMON;
  286.         }else{
  287.             return EnumRarity.COMMON;
  288.         }*/
  289.     }
  290. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement