Advertisement
HalestormXV

Untitled

Aug 19th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.60 KB | None | 0 0
  1. package halestormxv.eAngelus.items.cards;
  2.  
  3. import java.util.List;
  4.  
  5. import halestormxv.eAngelus.items.ModItemBowBase;
  6. import halestormxv.eAngelus.items.eAngelusCards;
  7. import halestormxv.eAngelus.main.Reference;
  8. import net.minecraft.enchantment.EnchantmentHelper;
  9. import net.minecraft.entity.Entity;
  10. import net.minecraft.entity.EntityLivingBase;
  11. import net.minecraft.entity.effect.EntityLightningBolt;
  12. import net.minecraft.entity.player.EntityPlayer;
  13. import net.minecraft.entity.projectile.EntityArrow;
  14. import net.minecraft.entity.projectile.EntityTippedArrow;
  15. import net.minecraft.init.Enchantments;
  16. import net.minecraft.init.Items;
  17. import net.minecraft.init.SoundEvents;
  18. import net.minecraft.item.EnumAction;
  19. import net.minecraft.item.Item;
  20. import net.minecraft.item.ItemStack;
  21. import net.minecraft.stats.StatList;
  22. import net.minecraft.util.ActionResult;
  23. import net.minecraft.util.EnumActionResult;
  24. import net.minecraft.util.EnumHand;
  25. import net.minecraft.util.SoundCategory;
  26. import net.minecraft.util.text.TextComponentString;
  27. import net.minecraft.world.World;
  28. import net.minecraftforge.client.event.FOVUpdateEvent;
  29. import net.minecraftforge.common.MinecraftForge;
  30. import net.minecraftforge.event.entity.player.ArrowLooseEvent;
  31. import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
  32.  
  33. public class O_card_Lightning extends eAngelusCards
  34. {
  35.     public O_card_Lightning(String unlocalizedName)
  36.     {
  37.         super(unlocalizedName);
  38.         this.setMaxStackSize(1);
  39.         this.setMaxDamage(-1);
  40.     }
  41.  
  42.     public boolean isDamageable()
  43.     {
  44.         return false;
  45.     }
  46.    
  47.     //=====================DO ALL THE STUFF HERE=====================\\
  48.     @Override
  49.     public int getMaxItemUseDuration(ItemStack stack)
  50.     {
  51.         return CHARGE_UP_DURATION_TICKS + CHARGE_UP_INITIAL_PAUSE_TICKS;
  52.     }
  53.  
  54.     @Override
  55.     public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
  56.     {
  57.         if (playerIn.isSneaking())
  58.         {
  59.             playerIn.setActiveHand(hand); // start the charge up sequence
  60.             return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn);
  61.         }else{  
  62.             playerIn.addChatComponentMessage(new TextComponentString("You need to be sneaking to activate an ORDER."));
  63.             return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
  64.         }
  65.     }
  66.  
  67.     @Override
  68.     public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
  69.     {
  70.         if (!worldIn.isRemote)
  71.         {
  72.             if (entityLiving instanceof EntityPlayer)
  73.             {
  74.                 int j = getMaxItemUseDuration(stack);
  75.                 //int j = 12;
  76.                 EntityPlayer entityPlayer = (EntityPlayer) entityLiving;
  77.                
  78.                 List<EntityLivingBase> targetList = entityPlayer.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, entityPlayer.getEntityBoundingBox().expand(8.0F + j, 8.0F + j, 8.0F + j));
  79.                 for (EntityLivingBase targets : targetList)
  80.                 {
  81.                     if ( targets != null)
  82.                     {
  83.                         if ( targets != entityPlayer )
  84.                         {
  85.                             entityPlayer.worldObj.spawnEntityInWorld(new EntityLightningBolt(worldIn, targets.posX, targets.posY, targets.posZ, true) );
  86.                             targets.clearActivePotions();
  87.                             worldIn.createExplosion(targets, targets.posX, targets.posY, targets.posZ, 3.2F + (j / 2), true);
  88.                             targets.setHealth(targets.getHealth() - j);
  89.                             //world.playSoundAtEntity(targets, RefStrings.MODID + ":leo_gift_execute", 1.4F, 1.0F);
  90.                         }
  91.                     }
  92.                 }
  93.             }
  94.         }
  95.         return stack;
  96.         //      for items with multiple count, decrease stack size and return the itemstack, eg
  97.         //      stack.stackSize--;
  98.         //      return stack;
  99.     }
  100.     //=====================END ALL THE STUFF HERE=====================\\
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement