Advertisement
alexbegt

Untitled

Jun 20th, 2013
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.43 KB | None | 0 0
  1. package net.aetherteam.aether;
  2.  
  3. import cpw.mods.fml.common.FMLCommonHandler;
  4. import cpw.mods.fml.common.network.PacketDispatcher;
  5. import java.io.File;
  6. import java.io.FileInputStream;
  7. import java.io.IOException;
  8. import java.io.PrintStream;
  9. import java.util.ArrayList;
  10. import java.util.Arrays;
  11. import java.util.Collections;
  12. import java.util.HashMap;
  13. import java.util.List;
  14. import net.aetherteam.aether.blocks.AetherBlocks;
  15. import net.aetherteam.aether.containers.ContainerPlayerAether;
  16. import net.aetherteam.aether.containers.InventoryAether;
  17. import net.aetherteam.aether.data.PlayerClientInfo;
  18. import net.aetherteam.aether.dungeons.Dungeon;
  19. import net.aetherteam.aether.dungeons.DungeonHandler;
  20. import net.aetherteam.aether.entities.EntityAetherLightning;
  21. import net.aetherteam.aether.entities.mounts_old.RidingHandler;
  22. import net.aetherteam.aether.interfaces.IAetherAccessory;
  23. import net.aetherteam.aether.interfaces.IAetherBoss;
  24. import net.aetherteam.aether.items.AetherItems;
  25. import net.aetherteam.aether.items.ItemAccessory;
  26. import net.aetherteam.aether.packets.AetherPacketHandler;
  27. import net.aetherteam.aether.party.Party;
  28. import net.aetherteam.aether.party.PartyController;
  29. import net.aetherteam.aether.party.members.PartyMember;
  30. import net.minecraft.block.Block;
  31. import net.minecraft.enchantment.EnchantmentHelper;
  32. import net.minecraft.entity.Entity;
  33. import net.minecraft.entity.EntityLiving;
  34. import net.minecraft.entity.effect.EntityLightningBolt;
  35. import net.minecraft.entity.player.EntityPlayer;
  36. import net.minecraft.entity.player.EntityPlayerMP;
  37. import net.minecraft.entity.player.InventoryPlayer;
  38. import net.minecraft.entity.player.PlayerCapabilities;
  39. import net.minecraft.inventory.ContainerPlayer;
  40. import net.minecraft.item.Item;
  41. import net.minecraft.item.ItemInWorldManager;
  42. import net.minecraft.item.ItemStack;
  43. import net.minecraft.nbt.CompressedStreamTools;
  44. import net.minecraft.nbt.NBTTagCompound;
  45. import net.minecraft.nbt.NBTTagList;
  46. import net.minecraft.network.NetServerHandler;
  47. import net.minecraft.network.packet.Packet43Experience;
  48. import net.minecraft.potion.Potion;
  49. import net.minecraft.potion.PotionEffect;
  50. import net.minecraft.server.MinecraftServer;
  51. import net.minecraft.server.management.ServerConfigurationManager;
  52. import net.minecraft.src.ServerPlayerAPI;
  53. import net.minecraft.src.ServerPlayerBase;
  54. import net.minecraft.util.AxisAlignedBB;
  55. import net.minecraft.util.DamageSource;
  56. import net.minecraft.util.FoodStats;
  57. import net.minecraft.util.MathHelper;
  58. import net.minecraft.util.MovingObjectPosition;
  59. import net.minecraft.world.World;
  60. import net.minecraft.world.storage.SaveHandler;
  61. import net.minecraftforge.common.ForgeHooks;
  62. import net.minecraftforge.event.ForgeEventFactory;
  63.  
  64. public class PlayerBaseAetherServer extends ServerPlayerBase
  65. {
  66. public AetherCommonPlayerHandler playerHandler = new AetherCommonPlayerHandler(this);
  67. public int maxHealth;
  68. public int foodTimer;
  69. public boolean hasDefeatedSunSpirit;
  70. public int generalcooldown = 0;
  71. public int generalcooldownmax = 0;
  72. public String cooldownName = "Hammer of Notch";
  73. public InventoryAether inv;
  74. public float prevStepHeight = 0.5F;
  75. private boolean jumpBoosted;
  76. private int flightCount = 0;
  77. private int maxFlightCount = 52;
  78. private double flightMod = 1.0D;
  79. private double maxFlightMod = 15.0D;
  80. public ArrayList mountInput = new ArrayList();
  81. private float sinage;
  82. private int coinAmount;
  83. public static boolean keepInventory = false;
  84. private float zLevel = -90.0F;
  85. public List extendedReachItems;
  86.  
  87. public PlayerBaseAetherServer(ServerPlayerAPI var1)
  88. {
  89. super(var1);
  90. this.extendedReachItems = Arrays.asList(new Item[] { AetherItems.ValkyrieShovel, AetherItems.ValkyriePickaxe, AetherItems.ValkyrieAxe });
  91. this.maxHealth = 20;
  92. this.inv = new InventoryAether(this.player);
  93.  
  94. if (!this.player.capabilities.isCreativeMode)
  95. {
  96. System.out.println(this.player.username);
  97. this.player.inventoryContainer = new ContainerPlayerAether(this.player.inventory, this.inv, !this.player.worldObj.isRemote, this.player, this.playerHandler);
  98. this.player.openContainer = this.player.inventoryContainer;
  99. }
  100. else
  101. {
  102. this.player.inventoryContainer = new ContainerPlayer(this.player.inventory, true, this.player);
  103. this.player.openContainer = this.player.inventoryContainer;
  104. }
  105. }
  106.  
  107. public boolean attackEntityFrom(DamageSource var1, int var2)
  108. {
  109. if ((var1.getEntity() instanceof EntityPlayer))
  110. {
  111. EntityPlayer var3 = (EntityPlayer)var1.getEntity();
  112. Party var4 = PartyController.instance().getParty(var3);
  113. Party var5 = PartyController.instance().getParty(PartyController.instance().getMember(this.player.username));
  114.  
  115. if ((var4 != null) && (var5 != null) && (var4.getName().toLowerCase().equalsIgnoreCase(var5.getName())))
  116. {
  117. return false;
  118. }
  119. }
  120.  
  121. return super.attackEntityFrom(var1, var2);
  122. }
  123.  
  124. public EntityPlayer getPlayer()
  125. {
  126. return this.player;
  127. }
  128.  
  129. public int getCoins()
  130. {
  131. return this.coinAmount;
  132. }
  133.  
  134. public void addCoins(int var1)
  135. {
  136. this.coinAmount += var1;
  137.  
  138. if (!this.player.worldObj.isRemote)
  139. {
  140. this.player.playerNetServerHandler.sendPacketToPlayer(AetherPacketHandler.sendCoinChange(false, true, this.coinAmount, Collections.singleton(this.player.username)));
  141. }
  142. }
  143.  
  144. public void removeCoins(int var1)
  145. {
  146. this.coinAmount -= var1;
  147.  
  148. if (!this.player.worldObj.isRemote)
  149. {
  150. this.player.playerNetServerHandler.sendPacketToPlayer(AetherPacketHandler.sendCoinChange(false, true, this.coinAmount, Collections.singleton(this.player.username)));
  151. }
  152. }
  153.  
  154. public boolean isOnLadder()
  155. {
  156. return (wearingAccessory(AetherItems.SwettyPendant.itemID)) && (isBesideClimbableBlock()) ? true : super.isOnLadder();
  157. }
  158.  
  159. public boolean isBesideClimbableBlock()
  160. {
  161. return this.player.isCollidedHorizontally;
  162. }
  163.  
  164. public void onStruckByLightning(EntityLightningBolt var1)
  165. {
  166. if ((!(var1 instanceof EntityAetherLightning)) || (((EntityAetherLightning)var1).playerUsing != this.player))
  167. {
  168. super.onStruckByLightning(var1);
  169. }
  170. }
  171.  
  172. public void beforeOnLivingUpdate()
  173. {
  174. this.playerHandler.beforeOnLivingUpdate();
  175.  
  176. if ((this.playerHandler.riddenBy != null) && (this.playerHandler.riddenBy.shouldBeSitting()))
  177. {
  178. if (this.playerHandler.riddenBy.animateSitting())
  179. {
  180. this.player.superSetFlag(2, true);
  181. this.player.shouldRiderSit();
  182. }
  183.  
  184. if (this.playerHandler.riddenBy.sprinting())
  185. {
  186. this.player.superSetFlag(3, true);
  187. }
  188. }
  189. }
  190.  
  191. public void afterAttackTargetEntityWithCurrentItem(Entity var1)
  192. {
  193. if (((var1 instanceof EntityLiving)) && (((EntityLiving)var1).deathTime <= 0) && (!var1.isEntityAlive()) && (this.player.getCurrentEquippedItem() != null) && (this.player.getCurrentEquippedItem().itemID == AetherItems.SkyrootSword.itemID) && ((var1 instanceof EntityLiving)));
  194. }
  195.  
  196. public void beforeOnUpdate()
  197. {
  198. if (isAboveBlock(AetherBlocks.Aercloud.blockID))
  199. {
  200. this.player.fallDistance = 0.0F;
  201. }
  202. }
  203.  
  204. public void onDeath(DamageSource var1)
  205. {
  206. float var2 = this.player.experience;
  207. int var3 = this.player.experienceTotal;
  208. int var4 = this.player.experienceLevel;
  209. super.onDeath(var1);
  210. PartyMember var5 = PartyController.instance().getMember(this.player);
  211. int var6 = MathHelper.floor_double(this.player.posX);
  212. int var7 = MathHelper.floor_double(this.player.posY);
  213. int var8 = MathHelper.floor_double(this.player.posZ);
  214. Dungeon var9 = DungeonHandler.instance().getInstanceAt(var6, var7, var8);
  215. System.out.println("Hooking into player death!");
  216.  
  217. if ((var5 != null) && (var9 != null))
  218. {
  219. System.out.println("Hooking into player death, preventing! ONE");
  220. Party var10 = PartyController.instance().getParty(var5);
  221.  
  222. if ((var10 != null) && (var9.isActive()) && (var9.isQueuedParty(var10)))
  223. {
  224. System.out.println("Hooking into player death, preventing! TWO");
  225. this.player.isDead = false;
  226. this.player.setEntityHealth(this.maxHealth);
  227. this.player.setFoodStatsField(new FoodStats());
  228. this.player.playerNetServerHandler.sendPacketToPlayer(new Packet43Experience(var2, var3, var4));
  229. this.player.setPositionAndUpdate((float)(var9.getControllerX() + 0.5D), (float)(var9.getControllerY() + 1.0D), (float)(var9.getControllerZ() + 0.5D));
  230. this.player.playerNetServerHandler.sendPacketToPlayer(AetherPacketHandler.sendDungeonRespawn(var9, var10));
  231. return;
  232. }
  233. }
  234. }
  235.  
  236. public void knockBack(Entity var1, int var2, double var3, double var5)
  237. {
  238. if (!wearingObsidianArmour())
  239. {
  240. super.knockBack(var1, var2, var3, var5);
  241. }
  242. }
  243.  
  244. public boolean isAboveBlock(int var1)
  245. {
  246. int var2 = MathHelper.floor_double(this.player.posX);
  247. int var3 = MathHelper.floor_double(this.player.boundingBox.minY);
  248. int var4 = MathHelper.floor_double(this.player.posZ);
  249. return (this.player.worldObj.getBlockId(MathHelper.floor_double(this.player.boundingBox.minX), var3 - 1, MathHelper.floor_double(this.player.boundingBox.minZ)) == var1) || (this.player.worldObj.getBlockId(MathHelper.floor_double(this.player.boundingBox.maxX), var3 - 1, MathHelper.floor_double(this.player.boundingBox.minZ)) == var1) || (this.player.worldObj.getBlockId(MathHelper.floor_double(this.player.boundingBox.maxX), var3 - 1, MathHelper.floor_double(this.player.boundingBox.maxZ)) == var1) || (this.player.worldObj.getBlockId(MathHelper.floor_double(this.player.boundingBox.minX), var3 - 1, MathHelper.floor_double(this.player.boundingBox.maxZ)) == var1);
  250. }
  251.  
  252. public boolean setGeneralCooldown(int var1, String var2)
  253. {
  254. if (this.generalcooldown == 0)
  255. {
  256. this.generalcooldown = var1;
  257. this.generalcooldownmax = var1;
  258. this.cooldownName = var2;
  259.  
  260. if (!this.player.worldObj.isRemote)
  261. {
  262. this.player.playerNetServerHandler.sendPacketToPlayer(AetherPacketHandler.sendCooldown(false, true, this.generalcooldown, this.generalcooldownmax, this.cooldownName, Collections.singleton(this.player.username)));
  263. }
  264.  
  265. return true;
  266. }
  267.  
  268. return false;
  269. }
  270.  
  271. public void afterOnUpdate()
  272. {
  273. processAbilities();
  274.  
  275. if (Aether.proxy.getClientExtraHearts().get(this.player.username) != null)
  276. {
  277. this.maxHealth = ((Integer)Aether.proxy.getClientExtraHearts().get(this.player.username)).intValue();
  278. }
  279.  
  280. if (this.generalcooldown > 0)
  281. {
  282. this.generalcooldown -= 1;
  283. }
  284.  
  285. PotionEffect var1 = this.player.getActivePotionEffect(Potion.regeneration);
  286.  
  287. if ((var1 != null) && (var1.getDuration() > 0) && (Potion.potionTypes[var1.getPotionID()].isReady(var1.getDuration(), var1.getAmplifier())) && (this.player.getHealth() >= 20) && (this.player.getHealth() < this.maxHealth))
  288. {
  289. this.player.heal(1);
  290. }
  291.  
  292. if ((this.player.getFoodStats().getFoodLevel() >= 18) && (this.player.getHealth() >= 20) && (this.player.getHealth() < this.maxHealth))
  293. {
  294. this.foodTimer += 1;
  295.  
  296. if (this.foodTimer >= 80)
  297. {
  298. this.foodTimer = 0;
  299. this.player.heal(1);
  300. }
  301. }
  302. else
  303. {
  304. this.foodTimer = 0;
  305. }
  306.  
  307. if ((this.player.worldObj.difficultySetting == 0) && (this.player.getHealth() >= 20) && (this.player.getHealth() < this.maxHealth) && (this.player.ticksExisted % 20 == 0))
  308. {
  309. this.player.heal(1);
  310. }
  311.  
  312. if (this.playerHandler.getCurrentBoss() != null)
  313. {
  314. Entity boss = this.playerHandler.getCurrentBoss().getBossEntity();
  315. if (Math.sqrt(Math.pow(boss.posX - this.player.posX, 2.0D) + Math.pow(boss.posY - this.player.posY, 2.0D) + Math.pow(boss.posZ - this.player.posZ, 2.0D)) > 50.0D)
  316. {
  317. this.playerHandler.setCurrentBoss(null);
  318. }
  319. }
  320.  
  321. ItemStack var5 = this.player.getCurrentEquippedItem();
  322.  
  323. if ((var5 != null) && (var5.getItem() != null) && (this.extendedReachItems.contains(var5.getItem())))
  324. {
  325. this.player.theItemInWorldManager.setBlockReachDistance(10.0D);
  326. }
  327. else
  328. {
  329. this.player.theItemInWorldManager.setBlockReachDistance(5.0D);
  330. }
  331.  
  332. if ((this.player.dimension == 3) && (this.player.posY < -2.0D))
  333. {
  334. Aether.teleportPlayerToAether(this.player, true);
  335. }
  336.  
  337. this.playerHandler.afterOnUpdate();
  338. float var3 = this.player.getMoveForwardField();
  339. float var4 = this.player.getMoveStrafingField();
  340.  
  341. if ((this.player.ridingEntity != null) && ((var4 != 0.0F) || (var3 != 0.0F)))
  342. {
  343. this.player.setMoveForwardField(0.0F);
  344. this.player.setMoveStrafingField(0.0F);
  345. }
  346.  
  347. if (clientInfoChanged())
  348. {
  349. updatePlayerClientInfo();
  350. }
  351. }
  352.  
  353. public boolean clientInfoChanged()
  354. {
  355. PlayerClientInfo var1 = (PlayerClientInfo)Aether.proxy.getPlayerClientInfo().get(this.player.username);
  356. return var1 != null;
  357. }
  358.  
  359. public void processAbilities()
  360. {
  361. if (!this.player.onGround)
  362. {
  363. this.sinage += 0.75F;
  364. }
  365. else
  366. {
  367. this.sinage += 0.15F;
  368. }
  369.  
  370. if (this.sinage > 6.283186F)
  371. {
  372. this.sinage -= 6.283186F;
  373. }
  374.  
  375. if ((wearingAccessory(AetherItems.SwettyPendant.itemID)) && (isBesideClimbableBlock()))
  376. {
  377. if ((!this.player.onGround) && (this.player.motionY < 0.0D) && (!this.player.isInWater()) && (!this.player.isSneaking()))
  378. {
  379. this.player.motionY *= 0.6D;
  380. }
  381.  
  382. this.player.fallDistance = -1.0F;
  383. }
  384.  
  385. if (this.player.ticksExisted % 400 == 0)
  386. {
  387. if ((this.inv.slots[0] != null) && (this.inv.slots[0].itemID == AetherItems.ZanitePendant.itemID))
  388. {
  389. this.inv.slots[0].damageItem(1, this.player);
  390.  
  391. if (this.inv.slots[0].stackSize < 1)
  392. {
  393. this.inv.slots[0] = null;
  394. }
  395. }
  396.  
  397. if ((this.inv.slots[4] != null) && (this.inv.slots[4].itemID == AetherItems.ZaniteRing.itemID))
  398. {
  399. this.inv.slots[4].damageItem(1, this.player);
  400.  
  401. if (this.inv.slots[4].stackSize < 1)
  402. {
  403. this.inv.slots[4] = null;
  404. }
  405. }
  406.  
  407. if ((this.inv.slots[5] != null) && (this.inv.slots[5].itemID == AetherItems.ZaniteRing.itemID))
  408. {
  409. this.inv.slots[5].damageItem(1, this.player);
  410.  
  411. if (this.inv.slots[5].stackSize < 1)
  412. {
  413. this.inv.slots[5] = null;
  414. }
  415. }
  416. }
  417.  
  418. if (wearingPhoenixArmour())
  419. {
  420. this.player.extinguish();
  421. this.player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 10, 4));
  422. }
  423.  
  424. if (wearingGravititeArmour())
  425. {
  426. if ((this.player.isJumping) && (!this.jumpBoosted) && (this.player.isSneaking()))
  427. {
  428. this.player.motionY = 1.0D;
  429. this.jumpBoosted = true;
  430. }
  431.  
  432. this.player.fallDistance = -1.0F;
  433. }
  434.  
  435. if (wearingObsidianArmour())
  436. {
  437. this.player.addPotionEffect(new PotionEffect(Potion.resistance.id, 10, 3));
  438. this.player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 10, 1));
  439. }
  440.  
  441. if (wearingValkyrieArmour())
  442. {
  443. if (this.player.isJumping)
  444. {
  445. if (this.flightMod >= this.maxFlightMod)
  446. {
  447. this.flightMod = this.maxFlightMod;
  448. }
  449.  
  450. if (this.flightCount > 2)
  451. {
  452. if (this.flightCount < this.maxFlightCount)
  453. {
  454. this.flightMod += 0.25D;
  455. this.player.motionY = (0.025D * this.flightMod);
  456. this.flightCount += 1;
  457. }
  458. }
  459. else
  460. {
  461. this.flightCount += 1;
  462. }
  463. }
  464. else
  465. {
  466. this.flightMod = 1.0D;
  467. }
  468.  
  469. this.player.fallDistance = -1.0F;
  470. }
  471.  
  472. if (this.player.onGround)
  473. {
  474. this.flightCount = 0;
  475. this.flightMod = 1.0D;
  476. }
  477.  
  478. if ((!this.player.isJumping) && (this.player.onGround))
  479. {
  480. this.jumpBoosted = false;
  481. }
  482.  
  483. for (int var1 = 0; var1 < 8; var1++)
  484. {
  485. if ((this.inv.slots[var1] != null) && ((this.inv.slots[var1].getItem() instanceof IAetherAccessory)))
  486. {
  487. ((ItemAccessory)this.inv.slots[var1].getItem()).activateServerPassive(this.player, this);
  488. }
  489. }
  490.  
  491. if (!wearingAccessory(AetherItems.AgilityCape.itemID))
  492. {
  493. this.player.stepHeight = this.prevStepHeight;
  494. }
  495. }
  496.  
  497. public void jump()
  498. {
  499. if (this.playerHandler.jump())
  500. {
  501. super.jump();
  502. }
  503. }
  504.  
  505. public float getSpeedModifier()
  506. {
  507. float var1 = this.playerHandler.getSpeedModifier();
  508. return var1 == -1.0F ? var1 : super.getSpeedModifier();
  509. }
  510.  
  511. public AetherCommonPlayerHandler getPlayerHandler()
  512. {
  513. return this.playerHandler;
  514. }
  515.  
  516. public void heal(int var1)
  517. {
  518. if (this.player.getHealth() > 0)
  519. {
  520. this.player.setEntityHealth(this.player.getHealth() + var1);
  521.  
  522. if (this.player.getHealth() > this.maxHealth)
  523. {
  524. this.player.setEntityHealth(this.maxHealth);
  525. }
  526.  
  527. updatePlayerClientInfo();
  528. }
  529. }
  530.  
  531. public void updatePlayerClientInfo()
  532. {
  533. if (!this.player.worldObj.isRemote)
  534. {
  535. MinecraftServer var1 = FMLCommonHandler.instance().getMinecraftServerInstance();
  536. ServerConfigurationManager var2 = var1.getConfigurationManager();
  537. PlayerClientInfo var3 = new PlayerClientInfo(this.player.getHealth(), this.maxHealth, this.player.getFoodStats().getFoodLevel(), this.player.getTotalArmorValue(), getCoins());
  538. Aether.proxy.getPlayerClientInfo().put(this.player.username, var3);
  539. PartyMember var4 = PartyController.instance().getMember(this.player.username);
  540. Party var5 = PartyController.instance().getParty(var4);
  541.  
  542. for (int var6 = 0; var6 < var2.playerEntityList.size(); var6++)
  543. {
  544. EntityPlayerMP var7 = (EntityPlayerMP)var2.playerEntityList.get(var6);
  545. PartyMember var8 = PartyController.instance().getMember(var7);
  546. var7.playerNetServerHandler.sendPacketToPlayer(AetherPacketHandler.sendPlayerClientInfo(false, true, this.player.username, var3));
  547. }
  548.  
  549. this.player.playerNetServerHandler.sendPacketToPlayer(AetherPacketHandler.sendPlayerClientInfo(false, true, this.player.username, var3));
  550. }
  551. }
  552.  
  553. public void increaseMaxHP(int var1)
  554. {
  555. if (this.maxHealth <= 40 - var1)
  556. {
  557. if (!this.player.worldObj.isRemote)
  558. {
  559. PacketDispatcher.sendPacketToAllPlayers(AetherPacketHandler.sendHeartChange(false, true, this.maxHealth + var1, Collections.singleton(this.player.username)));
  560. }
  561.  
  562. this.maxHealth += var1;
  563. this.player.setEntityHealth(this.player.getHealth() + var1);
  564. }
  565. }
  566.  
  567. public void beforeWriteEntityToNBT(NBTTagCompound var1)
  568. {
  569. var1.setInteger("MaxHealth", this.maxHealth);
  570. var1.setTag("AetherInventory", this.inv.writeToNBT(new NBTTagList()));
  571. var1.setBoolean("HasDefeatedSunSpirit", this.hasDefeatedSunSpirit);
  572. var1.setBoolean("inAether", this.player.dimension == 3);
  573. var1.setInteger("GeneralCooldown", this.generalcooldown);
  574. var1.setInteger("GeneralCooldownMax", this.generalcooldownmax);
  575. var1.setString("CooldownName", this.cooldownName);
  576. var1.setInteger("Coins", this.coinAmount);
  577. }
  578.  
  579. public void beforeReadEntityFromNBT(NBTTagCompound var1)
  580. {
  581. if (!this.player.worldObj.isRemote)
  582. {
  583. File var2 = new File(((SaveHandler)this.player.worldObj.getSaveHandler()).getWorldDirectoryName(), "aether.dat");
  584.  
  585. if (var2.exists())
  586. {
  587. new NBTTagCompound();
  588. try
  589. {
  590. NBTTagCompound var3 = CompressedStreamTools.readCompressed(new FileInputStream(var2));
  591. this.maxHealth = var3.getInteger("MaxHealth");
  592. NBTTagList var4 = var3.getTagList("Inventory");
  593.  
  594. if (this.player.dimension == 3)
  595. {
  596. this.player.dimension = 3;
  597. }
  598.  
  599. this.inv.readFromNBT(var4);
  600. var2.delete();
  601. }
  602. catch (IOException var5)
  603. {
  604. }
  605.  
  606. }
  607. else
  608. {
  609. System.out.println("Failed to read player data. Making new");
  610. this.maxHealth = var1.getInteger("MaxHealth");
  611. NBTTagList var6 = var1.getTagList("AetherInventory");
  612. this.hasDefeatedSunSpirit = var1.getBoolean("HasDefeatedSunSpirit");
  613.  
  614. if (var1.getBoolean("inAether"))
  615. {
  616. this.player.dimension = 3;
  617. }
  618.  
  619. this.generalcooldown = var1.getInteger("GeneralCooldown");
  620. this.generalcooldownmax = var1.getInteger("GeneralCooldownMax");
  621. this.cooldownName = var1.getString("CooldownName");
  622. this.coinAmount = var1.getInteger("Coins");
  623. this.inv.readFromNBT(var6);
  624. }
  625. }
  626. }
  627.  
  628. public void onDefeatSunSpirit()
  629. {
  630. setHasDefeatedSunSpirit(true);
  631. }
  632.  
  633. public void setHasDefeatedSunSpirit(boolean var1)
  634. {
  635. this.hasDefeatedSunSpirit = var1;
  636. }
  637.  
  638. public boolean getHasDefeatedSunSpirit()
  639. {
  640. return this.hasDefeatedSunSpirit;
  641. }
  642.  
  643. public float getCurrentPlayerStrVsBlock(Block var1, boolean var2)
  644. {
  645. ItemStack var3 = this.player.inventory.getCurrentItem();
  646. float var4 = var3 == null ? 1.0F : var3.getItem().getStrVsBlock(var3, var1, 0);
  647.  
  648. if ((this.inv.slots[0] != null) && (this.inv.slots[0].itemID == AetherItems.ZanitePendant.itemID))
  649. {
  650. var4 *= (1.0F + this.inv.slots[0].getItemDamage() / (this.inv.slots[0].getMaxDamage() * 3.0F));
  651. }
  652.  
  653. if ((this.inv.slots[4] != null) && (this.inv.slots[4].itemID == AetherItems.ZaniteRing.itemID))
  654. {
  655. var4 *= (1.0F + this.inv.slots[4].getItemDamage() / (this.inv.slots[4].getMaxDamage() * 3.0F));
  656. }
  657.  
  658. if ((this.inv.slots[5] != null) && (this.inv.slots[5].itemID == AetherItems.ZaniteRing.itemID))
  659. {
  660. var4 *= (1.0F + this.inv.slots[5].getItemDamage() / (this.inv.slots[5].getMaxDamage() * 3.0F));
  661. }
  662.  
  663. if (!wearingNeptuneArmour())
  664. {
  665. return var4 == -1.0F ? super.getCurrentPlayerStrVsBlock(var1, var2) : var4;
  666. }
  667.  
  668. if (var4 > 1.0F)
  669. {
  670. int var5 = EnchantmentHelper.getEfficiencyModifier(this.player);
  671. ItemStack var6 = this.player.inventory.getCurrentItem();
  672.  
  673. if ((var5 > 0) && (var6 != null))
  674. {
  675. float var7 = var5 * var5 + 1;
  676. boolean var8 = ForgeHooks.canToolHarvestBlock(var1, 0, var6);
  677.  
  678. if ((!var8) && (var4 <= 1.0F))
  679. {
  680. var4 += var7 * 0.08F;
  681. }
  682. else
  683. {
  684. var4 += var7;
  685. }
  686. }
  687. }
  688.  
  689. if (this.player.isPotionActive(Potion.digSpeed))
  690. {
  691. var4 *= (1.0F + (this.player.getActivePotionEffect(Potion.digSpeed).getAmplifier() + 1) * 0.2F);
  692. }
  693.  
  694. if (this.player.isPotionActive(Potion.digSlowdown))
  695. {
  696. var4 *= (1.0F - (this.player.getActivePotionEffect(Potion.digSlowdown).getAmplifier() + 1) * 0.2F);
  697. }
  698.  
  699. var4 = ForgeEventFactory.getBreakSpeed(this.player, var1, 0, var4);
  700. return var4 < 0.0F ? 0.0F : var4;
  701. }
  702.  
  703. public boolean isInWater()
  704. {
  705. return wearingNeptuneArmour() ? false : super.isInWater();
  706. }
  707.  
  708. public MovingObjectPosition rayTrace(double var1, float var3)
  709. {
  710. ItemStack var4 = this.player.getCurrentEquippedItem();
  711.  
  712. if ((var4 != null) && (var4.getItem() != null) && (this.extendedReachItems.contains(var4.getItem())))
  713. {
  714. var1 = 10.0D;
  715. }
  716.  
  717. return this.player.superRayTrace(var1, var3);
  718. }
  719.  
  720. public int getAccessoryCount(int var1)
  721. {
  722. int var2 = 0;
  723.  
  724. for (int var3 = 0; var3 < 8; var3++)
  725. {
  726. if ((this.inv.slots[var3] != null) && (this.inv.slots[var3].itemID == var1))
  727. {
  728. var2++;
  729. }
  730. }
  731.  
  732. return var2;
  733. }
  734.  
  735. public boolean wearingAccessory(int var1)
  736. {
  737. for (int var2 = 0; var2 < 8; var2++)
  738. {
  739. if ((this.inv.slots[var2] != null) && (this.inv.slots[var2].itemID == var1))
  740. {
  741. return true;
  742. }
  743. }
  744.  
  745. return false;
  746. }
  747.  
  748. public void setSlotStack(int var1, ItemStack var2)
  749. {
  750. this.inv.slots[var1] = var2;
  751. }
  752.  
  753. public ItemStack getSlotStack(int var1)
  754. {
  755. ItemStack var2 = null;
  756.  
  757. for (int var3 = 0; var3 < 8; var3++)
  758. {
  759. if ((this.inv.slots[var3] != null) && (this.inv.slots[var3].itemID == var1))
  760. {
  761. var2 = this.inv.slots[var3];
  762. return var2;
  763. }
  764. }
  765.  
  766. return var2;
  767. }
  768.  
  769. public int getSlotIndex(int var1)
  770. {
  771. for (int var2 = 0; var2 < 8; var2++)
  772. {
  773. if ((this.inv.slots[var2] != null) && (this.inv.slots[var2].itemID == var1))
  774. {
  775. return var2;
  776. }
  777. }
  778.  
  779. return 0;
  780. }
  781.  
  782. public boolean wearingArmour(int var1)
  783. {
  784. for (int var2 = 0; var2 < 4; var2++)
  785. {
  786. if ((this.player.inventory.armorInventory[var2] != null) && (this.player.inventory.armorInventory[var2].itemID == var1))
  787. {
  788. return true;
  789. }
  790. }
  791.  
  792. return false;
  793. }
  794.  
  795. public float getSinage()
  796. {
  797. return this.sinage;
  798. }
  799.  
  800. public boolean wearingNeptuneArmour()
  801. {
  802. return (wearingArmour(AetherItems.NeptuneHelmet.itemID)) && (wearingArmour(AetherItems.NeptuneChestplate.itemID)) && (wearingArmour(AetherItems.NeptuneLeggings.itemID)) && (wearingArmour(AetherItems.NeptuneBoots.itemID)) && (wearingAccessory(AetherItems.NeptuneGloves.itemID));
  803. }
  804.  
  805. public boolean wearingValkyrieArmour()
  806. {
  807. return (wearingArmour(AetherItems.ValkyrieHelmet.itemID)) && (wearingArmour(AetherItems.ValkyrieChestplate.itemID)) && (wearingArmour(AetherItems.ValkyrieLeggings.itemID)) && (wearingArmour(AetherItems.ValkyrieBoots.itemID)) && (wearingAccessory(AetherItems.ValkyrieGloves.itemID));
  808. }
  809.  
  810. public boolean wearingObsidianArmour()
  811. {
  812. return (wearingArmour(AetherItems.ObsidianHelmet.itemID)) && (wearingArmour(AetherItems.ObsidianChestplate.itemID)) && (wearingArmour(AetherItems.ObsidianLeggings.itemID)) && (wearingArmour(AetherItems.ObsidianBoots.itemID)) && (wearingAccessory(AetherItems.ObsidianGloves.itemID));
  813. }
  814.  
  815. public boolean wearingPhoenixArmour()
  816. {
  817. return (wearingArmour(AetherItems.PhoenixHelmet.itemID)) && (wearingArmour(AetherItems.PhoenixChestplate.itemID)) && (wearingArmour(AetherItems.PhoenixLeggings.itemID)) && (wearingArmour(AetherItems.PhoenixBoots.itemID)) && (wearingAccessory(AetherItems.PhoenixGloves.itemID));
  818. }
  819.  
  820. public boolean wearingGravititeArmour()
  821. {
  822. return (wearingArmour(AetherItems.GravititeHelmet.itemID)) && (wearingArmour(AetherItems.GravititeChestplate.itemID)) && (wearingArmour(AetherItems.GravititeLeggings.itemID)) && (wearingArmour(AetherItems.GravititeBoots.itemID)) && (wearingAccessory(AetherItems.GravititeGloves.itemID));
  823. }
  824.  
  825. public void setCoinAmount(int var1)
  826. {
  827. this.coinAmount = var1;
  828.  
  829. if (!this.player.worldObj.isRemote)
  830. {
  831. this.player.playerNetServerHandler.sendPacketToPlayer(AetherPacketHandler.sendCoinChange(false, true, this.coinAmount, Collections.singleton(this.player.username)));
  832. }
  833. }
  834.  
  835. private boolean inPortal;
  836. private int timeInPortal;
  837. private boolean idleInPortal;
  838. private int timeUntilPortal;
  839.  
  840. public boolean isInPortal()
  841. {
  842. return this.inPortal;
  843. }
  844.  
  845. public void setInPortal()
  846. {
  847. int posX = MathHelper.floor_double(this.player.posX);
  848. int posY = MathHelper.floor_double(this.player.posY);
  849. int posZ = MathHelper.floor_double(this.player.posZ);
  850.  
  851. if (this.timeUntilPortal > 0)
  852. {
  853. this.timeUntilPortal = 900;
  854. }
  855. else
  856. {
  857. double d0 = this.player.prevPosX - this.player.posX;
  858. double d1 = this.player.prevPosZ - this.player.posZ;
  859.  
  860. this.inPortal = true;
  861. }
  862. }
  863.  
  864. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement