Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.52 KB | None | 0 0
  1. package net.minecraft.server;
  2.  
  3. // CraftBukkit start
  4. import org.bukkit.Bukkit;
  5. import org.bukkit.craftbukkit.event.CraftEventFactory;
  6. import org.bukkit.event.player.PlayerTeleportEvent;
  7. import org.bukkit.material.Gate;
  8. import org.bukkit.util.BlockIterator;
  9. import org.bukkit.util.Vector;
  10.  
  11. import com.enhancedspigot.kammy.EnhancedSpigot;
  12.  
  13. public class EntityEnderPearl extends EntityProjectile {
  14.  
  15. private EntityLiving c;
  16.  
  17. public EntityEnderPearl(World world) {
  18. super(world);
  19. this.loadChunks = world.paperSpigotConfig.loadUnloadedEnderPearls; // PaperSpigot
  20. }
  21.  
  22. public EntityEnderPearl(World world, EntityLiving entityliving) {
  23. super(world, entityliving);
  24. this.c = entityliving;
  25. this.loadChunks = world.paperSpigotConfig.loadUnloadedEnderPearls; // PaperSpigot
  26. }
  27.  
  28. protected void a(MovingObjectPosition movingobjectposition) {
  29. EntityLiving entityliving = this.getShooter();
  30. if (!EnhancedSpigot.getInstance().pearlfacegate) {
  31. Block block = this.world.getType(movingobjectposition.a()).getBlock();
  32.  
  33. if (block == Blocks.TRIPWIRE) {
  34. return;
  35. } else if (block == Blocks.FENCE_GATE) {
  36. BlockIterator bi = null;
  37.  
  38. try {
  39. Vector l = new Vector(this.locX, this.locY, this.locZ);
  40. Vector l2 = new Vector(this.locX + this.motX, this.locY + this.motY, this.locZ + this.motZ);
  41. Vector dir = new Vector(l2.getX() - l.getX(), l2.getY() - l.getY(), l2.getZ() - l.getZ())
  42. .normalize();
  43. bi = new BlockIterator(this.world.getWorld(), l, dir, 0, 1);
  44. } catch (IllegalStateException e) {
  45. // Do nothing
  46. }
  47.  
  48. if (bi != null) {
  49. boolean open = true;
  50. while (bi.hasNext()) {
  51. org.bukkit.block.Block b = bi.next();
  52. if (b.getState().getData() instanceof Gate && !((Gate) b.getState().getData()).isOpen()) {
  53. open = false;
  54. break;
  55. }
  56. }
  57. if (open) {
  58. return;
  59. }
  60. }
  61. }
  62. }
  63.  
  64. if (movingobjectposition.entity != null) {
  65. movingobjectposition.entity.damageEntity(DamageSource.projectile(this, entityliving), 0.0F);
  66. }
  67.  
  68. // PaperSpigot start - Remove entities in unloaded chunks
  69. if (this.inUnloadedChunk && world.paperSpigotConfig.removeUnloadedEnderPearls) {
  70. this.die();
  71. }
  72. // PaperSpigot end
  73.  
  74. for (int i = 0; i < 32; ++i) {
  75. this.world.addParticle(EnumParticle.PORTAL, this.locX, this.locY + this.random.nextDouble() * 2.0D,
  76. this.locZ, this.random.nextGaussian(), 0.0D, this.random.nextGaussian(), new int[0]);
  77. }
  78.  
  79. if (!this.world.isClientSide) {
  80. if (entityliving instanceof EntityPlayer) {
  81. EntityPlayer entityplayer = (EntityPlayer) entityliving;
  82.  
  83. if (entityplayer.playerConnection.a().g() && entityplayer.world == this.world
  84. && !entityplayer.isSleeping()) {
  85. // CraftBukkit start - Fire PlayerTeleportEvent
  86. org.bukkit.craftbukkit.entity.CraftPlayer player = entityplayer.getBukkitEntity();
  87. org.bukkit.Location location = getBukkitEntity().getLocation();
  88. location.setPitch(player.getLocation().getPitch());
  89. location.setYaw(player.getLocation().getYaw());
  90.  
  91. PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location,
  92. PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
  93. Bukkit.getPluginManager().callEvent(teleEvent);
  94.  
  95. if (!teleEvent.isCancelled() && !entityplayer.playerConnection.isDisconnected()) {
  96. if (this.random.nextFloat() < 0.05F && this.world.getGameRules().getBoolean("doMobSpawning")) {
  97. EntityEndermite entityendermite = new EntityEndermite(this.world);
  98.  
  99. entityendermite.a(true);
  100. entityendermite.setPositionRotation(entityliving.locX, entityliving.locY, entityliving.locZ,
  101. entityliving.yaw, entityliving.pitch);
  102. this.world.addEntity(entityendermite);
  103. }
  104.  
  105. if (entityliving.au()) {
  106. entityliving.mount((Entity) null);
  107. }
  108.  
  109. entityplayer.playerConnection.teleport(teleEvent.getTo());
  110. entityliving.fallDistance = 0.0F;
  111. CraftEventFactory.entityDamage = this;
  112. entityliving.damageEntity(DamageSource.FALL, 5.0F);
  113. CraftEventFactory.entityDamage = null;
  114. }
  115. // CraftBukkit end
  116. }
  117. } else if (entityliving != null) {
  118. entityliving.enderTeleportTo(this.locX, this.locY, this.locZ);
  119. entityliving.fallDistance = 0.0F;
  120. }
  121.  
  122. this.die();
  123. }
  124.  
  125. }
  126.  
  127. public void t_() {
  128. EntityLiving entityliving = this.getShooter();
  129.  
  130. if (entityliving != null && entityliving instanceof EntityHuman && !entityliving.isAlive()) {
  131. this.die();
  132. } else {
  133. super.t_();
  134. }
  135.  
  136. }
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement