Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.11 KB | None | 0 0
  1.  
  2.   @SubscribeEvent
  3.   public void livingTick(LivingEvent.LivingUpdateEvent event)
  4.   {
  5.     if ((!event.entity.worldObj.isRemote) && ((event.entity instanceof EntityPlayer)))
  6.     {
  7.       EntityPlayer player = (EntityPlayer)event.entity;
  8.       if ((this.isDirty) || (player.ticksExisted % 40 == 0))
  9.       {
  10.         int max = 0;
  11.         int charged = 0;
  12.         int kinetic = 0;
  13.         int healing = 0;
  14.         int emergency = 0;
  15.         this.isDirty = false;
  16.         for (int a = 0; a < 4; a++) {
  17.           if ((player.inventory.armorItemInSlot(a) != null) && ((player.inventory.armorItemInSlot(a).getItem() instanceof IRunicArmor)))
  18.           {
  19.             int amount = getFinalCharge(player.inventory.armorItemInSlot(a));
  20.             max += amount;
  21.           }
  22.         }
  23.         IInventory baubles = BaublesApi.getBaubles(player);
  24.         for (int a = 0; a < 4; a++) {
  25.           if ((baubles.getStackInSlot(a) != null) && ((baubles.getStackInSlot(a).getItem() instanceof IRunicArmor)))
  26.           {
  27.             int amount = getFinalCharge(baubles.getStackInSlot(a));
  28.             if ((baubles.getStackInSlot(a).getItem() instanceof ItemRingRunic)) {
  29.               switch (baubles.getStackInSlot(a).getItemDamage())
  30.               {
  31.               case 2:
  32.                 charged++; break;
  33.               case 3:
  34.                 healing++;
  35.               }
  36.             } else if (((baubles.getStackInSlot(a).getItem() instanceof ItemAmuletRunic)) && (baubles.getStackInSlot(a).getItemDamage() == 1)) {
  37.               emergency++;
  38.             } else if (((baubles.getStackInSlot(a).getItem() instanceof ItemGirdleRunic)) && (baubles.getStackInSlot(a).getItemDamage() == 1)) {
  39.               kinetic++;
  40.             }
  41.             max += amount;
  42.           }
  43.         }
  44.         if (max > 0)
  45.         {
  46.           this.runicInfo.put(Integer.valueOf(player.getEntityId()), new Integer[] { Integer.valueOf(max), Integer.valueOf(charged), Integer.valueOf(kinetic), Integer.valueOf(healing), Integer.valueOf(emergency) });
  47.           if (this.runicCharge.containsKey(Integer.valueOf(player.getEntityId())))
  48.           {
  49.             int charge = ((Integer)this.runicCharge.get(Integer.valueOf(player.getEntityId()))).intValue();
  50.             if (charge > max)
  51.             {
  52.               this.runicCharge.put(Integer.valueOf(player.getEntityId()), Integer.valueOf(max));
  53.               PacketHandler.INSTANCE.sendTo(new PacketRunicCharge(player, Short.valueOf((short)max), max), (EntityPlayerMP)player);
  54.             }
  55.           }
  56.         }
  57.         else
  58.         {
  59.           this.runicInfo.remove(Integer.valueOf(player.getEntityId()));
  60.           this.runicCharge.put(Integer.valueOf(player.getEntityId()), Integer.valueOf(0));
  61.           PacketHandler.INSTANCE.sendTo(new PacketRunicCharge(player, Short.valueOf((short)0), 0), (EntityPlayerMP)player);
  62.         }
  63.       }
  64.       if (this.rechargeDelay > 0)
  65.       {
  66.         this.rechargeDelay -= 1;
  67.       }
  68.       else if (this.runicInfo.containsKey(Integer.valueOf(player.getEntityId())))
  69.       {
  70.         if (!this.lastCharge.containsKey(Integer.valueOf(player.getEntityId()))) {
  71.           this.lastCharge.put(Integer.valueOf(player.getEntityId()), Integer.valueOf(-1));
  72.         }
  73.         if (!this.runicCharge.containsKey(Integer.valueOf(player.getEntityId()))) {
  74.           this.runicCharge.put(Integer.valueOf(player.getEntityId()), Integer.valueOf(0));
  75.         }
  76.         if (!this.nextCycle.containsKey(Integer.valueOf(player.getEntityId()))) {
  77.           this.nextCycle.put(Integer.valueOf(player.getEntityId()), Long.valueOf(0L));
  78.         }
  79.         long time = System.currentTimeMillis();
  80.        
  81.         int charge = ((Integer)this.runicCharge.get(Integer.valueOf(player.getEntityId()))).intValue();
  82.         if (charge > ((Integer[])this.runicInfo.get(Integer.valueOf(player.getEntityId())))[0].intValue())
  83.         {
  84.           charge = ((Integer[])this.runicInfo.get(Integer.valueOf(player.getEntityId())))[0].intValue();
  85.         }
  86.         else if ((charge < ((Integer[])this.runicInfo.get(Integer.valueOf(player.getEntityId())))[0].intValue()) && (((Long)this.nextCycle.get(Integer.valueOf(player.getEntityId()))).longValue() < time) && (WandManager.consumeVisFromInventory(player, new AspectList().add(Aspect.AIR, Config.shieldCost).add(Aspect.EARTH, Config.shieldCost))))
  87.         {
  88.           long interval = Config.shieldRecharge - ((Integer[])this.runicInfo.get(Integer.valueOf(player.getEntityId())))[1].intValue() * 500;
  89.           this.nextCycle.put(Integer.valueOf(player.getEntityId()), Long.valueOf(time + interval));
  90.           charge++;
  91.           this.runicCharge.put(Integer.valueOf(player.getEntityId()), Integer.valueOf(charge));
  92.         }
  93.         if (((Integer)this.lastCharge.get(Integer.valueOf(player.getEntityId()))).intValue() != charge)
  94.         {
  95.           PacketHandler.INSTANCE.sendTo(new PacketRunicCharge(player, Short.valueOf((short)charge), ((Integer[])this.runicInfo.get(Integer.valueOf(player.getEntityId())))[0].intValue()), (EntityPlayerMP)player);
  96.           this.lastCharge.put(Integer.valueOf(player.getEntityId()), Integer.valueOf(charge));
  97.         }
  98.       }
  99.     }
  100.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement