| 
									
										
										
										
											2015-05-25 20:37:24 +10:00
										 |  |  | --- a/net/minecraft/server/EntityPlayer.java
 | 
					
						
							|  |  |  | +++ b/net/minecraft/server/EntityPlayer.java
 | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  | @@ -15,10 +15,28 @@
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |  import org.apache.logging.log4j.LogManager; | 
					
						
							|  |  |  |  import org.apache.logging.log4j.Logger; | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  | +// CraftBukkit start
 | 
					
						
							| 
									
										
										
										
											2017-01-10 09:56:20 +11:00
										 |  |  | +import com.google.common.base.Preconditions;
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +import org.bukkit.Bukkit;
 | 
					
						
							| 
									
										
										
										
											2017-03-31 21:21:11 +11:00
										 |  |  | +import org.bukkit.GameMode;
 | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  | +import org.bukkit.Location;
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +import org.bukkit.WeatherType;
 | 
					
						
							|  |  |  | +import org.bukkit.craftbukkit.CraftWorld;
 | 
					
						
							|  |  |  | +import org.bukkit.craftbukkit.entity.CraftPlayer;
 | 
					
						
							|  |  |  | +import org.bukkit.craftbukkit.event.CraftEventFactory;
 | 
					
						
							|  |  |  | +import org.bukkit.craftbukkit.inventory.CraftItemStack;
 | 
					
						
							|  |  |  | +import org.bukkit.event.inventory.InventoryType;
 | 
					
						
							| 
									
										
										
										
											2016-05-27 18:53:36 +10:00
										 |  |  | +import org.bukkit.event.player.PlayerChangedMainHandEvent;
 | 
					
						
							| 
									
										
										
										
											2017-03-31 21:21:11 +11:00
										 |  |  | +import org.bukkit.event.player.PlayerGameModeChangeEvent;
 | 
					
						
							| 
									
										
										
										
											2017-05-26 23:37:06 +02:00
										 |  |  | +import org.bukkit.event.player.PlayerLocaleChangeEvent;
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
 | 
					
						
							| 
									
										
										
										
											2016-05-27 18:53:36 +10:00
										 |  |  | +import org.bukkit.inventory.MainHand;
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +// CraftBukkit end
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  |  public class EntityPlayer extends EntityHuman implements ICrafting { | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |      private static final Logger cc = LogManager.getLogger(); | 
					
						
							| 
									
										
										
										
											2017-05-30 21:25:59 +10:00
										 |  |  | -    public String locale = "en_US";
 | 
					
						
							|  |  |  | +    public String locale = "en_us"; // CraftBukkit - lowercase
 | 
					
						
							| 
									
										
										
										
											2017-05-26 23:37:06 +02:00
										 |  |  |      public PlayerConnection playerConnection; | 
					
						
							|  |  |  |      public final MinecraftServer server; | 
					
						
							|  |  |  |      public final PlayerInteractManager playerInteractManager; | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -54,6 +72,20 @@
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |      public int ping; | 
					
						
							|  |  |  |      public boolean viewingCredits; | 
					
						
							| 
									
										
										
										
											2015-02-26 22:41:06 +00:00
										 |  |  |   | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +    // CraftBukkit start
 | 
					
						
							|  |  |  | +    public String displayName;
 | 
					
						
							|  |  |  | +    public IChatBaseComponent listName;
 | 
					
						
							|  |  |  | +    public org.bukkit.Location compassTarget;
 | 
					
						
							|  |  |  | +    public int newExp = 0;
 | 
					
						
							|  |  |  | +    public int newLevel = 0;
 | 
					
						
							|  |  |  | +    public int newTotalExp = 0;
 | 
					
						
							|  |  |  | +    public boolean keepLevel = false;
 | 
					
						
							|  |  |  | +    public double maxHealthCache;
 | 
					
						
							|  |  |  | +    public boolean joining = true;
 | 
					
						
							| 
									
										
										
										
											2017-04-27 21:53:31 -07:00
										 |  |  | +    public boolean sentListPacket = false;
 | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | +    public Integer clientViewDistance;
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +    // CraftBukkit end
 | 
					
						
							| 
									
										
										
										
											2015-02-26 22:41:06 +00:00
										 |  |  | +
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |      public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) { | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |          super((World) worldserver, gameprofile); | 
					
						
							| 
									
										
										
										
											2015-02-26 22:41:06 +00:00
										 |  |  |          playerinteractmanager.player = this; | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -64,8 +96,50 @@
 | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  |          this.cf = minecraftserver.getPlayerList().h(this); | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |          this.Q = 1.0F; | 
					
						
							|  |  |  |          this.a(worldserver); | 
					
						
							| 
									
										
										
										
											2018-03-07 21:43:33 +11:00
										 |  |  | +
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +        // CraftBukkit start
 | 
					
						
							|  |  |  | +        this.displayName = this.getName();
 | 
					
						
							| 
									
										
										
										
											2017-06-26 11:21:38 +10:00
										 |  |  | +        this.canPickUpLoot = true;
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +        this.maxHealthCache = this.getMaxHealth();
 | 
					
						
							| 
									
										
										
										
											2018-06-14 19:59:21 +02:00
										 |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  | +    // Yes, this doesn't match Vanilla, but it's the best we can do for now.
 | 
					
						
							|  |  |  | +    // If this is an issue, PRs are welcome
 | 
					
						
							|  |  |  | +    public final BlockPosition getSpawnPoint(WorldServer worldserver) {
 | 
					
						
							|  |  |  | +        BlockPosition blockposition = worldserver.getSpawn();
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +        if (worldserver.worldProvider.g() && worldserver.getWorldData().getGameType() != EnumGamemode.ADVENTURE) {
 | 
					
						
							|  |  |  | +            int i = Math.max(0, this.server.a(worldserver));
 | 
					
						
							|  |  |  | +            int j = MathHelper.floor(worldserver.getWorldBorder().b((double) blockposition.getX(), (double) blockposition.getZ()));
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +            if (j < i) {
 | 
					
						
							|  |  |  | +                i = j;
 | 
					
						
							|  |  |  | +            }
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +            if (j <= 1) {
 | 
					
						
							|  |  |  | +                i = 1;
 | 
					
						
							|  |  |  | +            }
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +            int k = (i * 2 + 1) * (i * 2 + 1);
 | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  | +            int l = this.r(k);
 | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  | +            int i1 = (new Random()).nextInt(k);
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +            for (int j1 = 0; j1 < k; ++j1) {
 | 
					
						
							|  |  |  | +                int k1 = (i1 + l * j1) % k;
 | 
					
						
							|  |  |  | +                int l1 = k1 % (i * 2 + 1);
 | 
					
						
							|  |  |  | +                int i2 = k1 / (i * 2 + 1);
 | 
					
						
							|  |  |  | +                BlockPosition blockposition1 = worldserver.o().a(blockposition.getX() + l1 - i, blockposition.getZ() + i2 - i, false);
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +                if (blockposition1 != null) {
 | 
					
						
							|  |  |  | +                    return blockposition1;
 | 
					
						
							|  |  |  | +                }
 | 
					
						
							|  |  |  | +            }
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							|  |  |  | +
 | 
					
						
							| 
									
										
										
										
											2018-03-07 21:43:33 +11:00
										 |  |  | +        return blockposition;
 | 
					
						
							| 
									
										
										
										
											2018-06-14 19:59:21 +02:00
										 |  |  | +    }
 | 
					
						
							| 
									
										
										
										
											2018-03-07 21:43:33 +11:00
										 |  |  | +    // CraftBukkit end
 | 
					
						
							| 
									
										
										
										
											2018-06-14 19:59:21 +02:00
										 |  |  | +
 | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |      private void a(WorldServer worldserver) { | 
					
						
							|  |  |  |          BlockPosition blockposition = worldserver.getSpawn(); | 
					
						
							| 
									
										
										
										
											2018-06-14 19:59:21 +02:00
										 |  |  |   | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -132,6 +206,7 @@
 | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  |          if (nbttagcompound.hasKeyOfType("recipeBook", 10)) { | 
					
						
							| 
									
										
										
										
											2018-12-13 11:00:00 +11:00
										 |  |  |              this.recipeBook.a(nbttagcompound.getCompound("recipeBook")); | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |          } | 
					
						
							|  |  |  | +        this.getBukkitEntity().readExtraData(nbttagcompound); // CraftBukkit
 | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  |   | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -151,7 +226,20 @@
 | 
					
						
							| 
									
										
										
										
											2018-06-14 19:59:21 +02:00
										 |  |  |          Entity entity = this.getRootVehicle(); | 
					
						
							|  |  |  |          Entity entity1 = this.getVehicle(); | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  | -        if (entity1 != null && entity != this && entity.bR()) {
 | 
					
						
							|  |  |  | +        // CraftBukkit start - handle non-persistent vehicles
 | 
					
						
							|  |  |  | +        boolean persistVehicle = true;
 | 
					
						
							|  |  |  | +        if (entity1 != null) {
 | 
					
						
							|  |  |  | +            Entity vehicle;
 | 
					
						
							|  |  |  | +            for (vehicle = entity1; vehicle != null; vehicle = vehicle.getVehicle()) {
 | 
					
						
							|  |  |  | +                if (!vehicle.persist) {
 | 
					
						
							|  |  |  | +                    persistVehicle = false;
 | 
					
						
							|  |  |  | +                    break;
 | 
					
						
							|  |  |  | +                }
 | 
					
						
							|  |  |  | +            }
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +        if (persistVehicle && entity1 != null && entity != this && entity.bR()) {
 | 
					
						
							|  |  |  | +            // CraftBukkit end
 | 
					
						
							|  |  |  |              NBTTagCompound nbttagcompound2 = new NBTTagCompound(); | 
					
						
							|  |  |  |              NBTTagCompound nbttagcompound3 = new NBTTagCompound(); | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -162,8 +250,34 @@
 | 
					
						
							| 
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 |  |  |          } | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  |   | 
					
						
							| 
									
										
										
										
											2018-12-13 11:00:00 +11:00
										 |  |  |          nbttagcompound.set("recipeBook", this.recipeBook.e()); | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  | +        this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit
 | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +    // CraftBukkit start - World fallback code, either respawn location or global spawn
 | 
					
						
							|  |  |  | +    public void spawnIn(World world) {
 | 
					
						
							|  |  |  | +        super.spawnIn(world);
 | 
					
						
							|  |  |  | +        if (world == null) {
 | 
					
						
							|  |  |  | +            this.dead = false;
 | 
					
						
							|  |  |  | +            BlockPosition position = null;
 | 
					
						
							|  |  |  | +            if (this.spawnWorld != null && !this.spawnWorld.equals("")) {
 | 
					
						
							|  |  |  | +                CraftWorld cworld = (CraftWorld) Bukkit.getServer().getWorld(this.spawnWorld);
 | 
					
						
							|  |  |  | +                if (cworld != null && this.getBed() != null) {
 | 
					
						
							|  |  |  | +                    world = cworld.getHandle();
 | 
					
						
							|  |  |  | +                    position = EntityHuman.getBed(cworld.getHandle(), this.getBed(), false);
 | 
					
						
							|  |  |  | +                }
 | 
					
						
							|  |  |  | +            }
 | 
					
						
							|  |  |  | +            if (world == null || position == null) {
 | 
					
						
							|  |  |  | +                world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle();
 | 
					
						
							|  |  |  | +                position = world.getSpawn();
 | 
					
						
							|  |  |  | +            }
 | 
					
						
							|  |  |  | +            this.world = world;
 | 
					
						
							|  |  |  | +            this.setPosition(position.getX() + 0.5, position.getY(), position.getZ() + 0.5);
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							|  |  |  | +        this.dimension = ((WorldServer) this.world).dimension;
 | 
					
						
							|  |  |  | +        this.playerInteractManager.a((WorldServer) world);
 | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  | +    }
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +    // CraftBukkit end
 | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  | +
 | 
					
						
							|  |  |  |      public void a(int i) { | 
					
						
							|  |  |  |          float f = (float) this.getExpToLevel(); | 
					
						
							|  |  |  |          float f1 = (f - 1.0F) / f; | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -210,6 +324,11 @@
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |      public void tick() { | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +        // CraftBukkit start
 | 
					
						
							|  |  |  | +        if (this.joining) {
 | 
					
						
							|  |  |  | +            this.joining = false;
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							|  |  |  | +        // CraftBukkit end
 | 
					
						
							|  |  |  |          this.playerInteractManager.a(); | 
					
						
							|  |  |  |          --this.invulnerableTicks; | 
					
						
							|  |  |  |          if (this.noDamageTicks > 0) { | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -275,7 +394,7 @@
 | 
					
						
							| 
									
										
										
										
											2016-03-06 08:38:01 +11:00
										 |  |  |              } | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2018-12-13 11:00:00 +11:00
										 |  |  |              if (this.getHealth() != this.lastHealthSent || this.lastFoodSent != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.cp) { | 
					
						
							| 
									
										
										
										
											2016-03-06 08:38:01 +11:00
										 |  |  | -                this.playerConnection.sendPacket(new PacketPlayOutUpdateHealth(this.getHealth(), this.foodData.getFoodLevel(), this.foodData.getSaturationLevel()));
 | 
					
						
							|  |  |  | +                this.playerConnection.sendPacket(new PacketPlayOutUpdateHealth(this.getBukkitEntity().getScaledHealth(), this.foodData.getFoodLevel(), this.foodData.getSaturationLevel())); // CraftBukkit
 | 
					
						
							|  |  |  |                  this.lastHealthSent = this.getHealth(); | 
					
						
							| 
									
										
										
										
											2018-12-13 11:00:00 +11:00
										 |  |  |                  this.lastFoodSent = this.foodData.getFoodLevel(); | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  |                  this.cp = this.foodData.getSaturationLevel() == 0.0F; | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -306,6 +425,12 @@
 | 
					
						
							| 
									
										
										
										
											2018-12-13 11:00:00 +11:00
										 |  |  |                  this.a(IScoreboardCriteria.XP, MathHelper.f((float) this.cm)); | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |              } | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  | +            // CraftBukkit start - Force max health updates
 | 
					
						
							|  |  |  | +            if (this.maxHealthCache != this.getMaxHealth()) {
 | 
					
						
							|  |  |  | +                this.getBukkitEntity().updateScaledHealth();
 | 
					
						
							| 
									
										
										
										
											2016-06-09 11:43:49 +10:00
										 |  |  | +            }
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +            // CraftBukkit end
 | 
					
						
							| 
									
										
										
										
											2016-06-09 11:43:49 +10:00
										 |  |  | +
 | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  |              if (this.expLevel != this.cl) { | 
					
						
							|  |  |  |                  this.cl = this.expLevel; | 
					
						
							| 
									
										
										
										
											2018-12-13 11:00:00 +11:00
										 |  |  |                  this.a(IScoreboardCriteria.LEVEL, MathHelper.f((float) this.cl)); | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -320,6 +445,16 @@
 | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |                  CriterionTriggers.p.a(this); | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |              } | 
					
						
							| 
									
										
										
										
											2015-02-26 22:41:06 +00:00
										 |  |  |   | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +            // CraftBukkit start - initialize oldLevel and fire PlayerLevelChangeEvent
 | 
					
						
							|  |  |  | +            if (this.oldLevel == -1) {
 | 
					
						
							|  |  |  | +                this.oldLevel = this.expLevel;
 | 
					
						
							|  |  |  | +            }
 | 
					
						
							| 
									
										
										
										
											2015-02-26 22:41:06 +00:00
										 |  |  | +
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +            if (this.oldLevel != this.expLevel) {
 | 
					
						
							|  |  |  | +                CraftEventFactory.callPlayerLevelChangeEvent(this.world.getServer().getPlayer((EntityPlayer) this), this.oldLevel, this.expLevel);
 | 
					
						
							|  |  |  | +                this.oldLevel = this.expLevel;
 | 
					
						
							|  |  |  | +            }
 | 
					
						
							| 
									
										
										
										
											2015-02-26 22:41:06 +00:00
										 |  |  | +            // CraftBukkit end
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |          } catch (Throwable throwable) { | 
					
						
							|  |  |  |              CrashReport crashreport = CrashReport.a(throwable, "Ticking player"); | 
					
						
							|  |  |  |              CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked"); | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -330,24 +465,50 @@
 | 
					
						
							| 
									
										
										
										
											2016-03-12 17:57:40 +11:00
										 |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |      private void a(IScoreboardCriteria iscoreboardcriteria, int i) { | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  | -        this.getScoreboard().getObjectivesForCriteria(iscoreboardcriteria, this.getName(), (scoreboardscore) -> {
 | 
					
						
							|  |  |  | +        // CraftBukkit - Use our scores instead
 | 
					
						
							|  |  |  | +        this.world.getServer().getScoreboardManager().getScoreboardScores(iscoreboardcriteria, this.getName(), (scoreboardscore) -> {
 | 
					
						
							| 
									
										
										
										
											2016-03-12 17:57:40 +11:00
										 |  |  |              scoreboardscore.setScore(i); | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |          }); | 
					
						
							|  |  |  |      } | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |   | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  |      public void die(DamageSource damagesource) { | 
					
						
							|  |  |  |          boolean flag = this.world.getGameRules().getBoolean("showDeathMessages"); | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +        // CraftBukkit start - fire PlayerDeathEvent
 | 
					
						
							|  |  |  | +        if (this.dead) {
 | 
					
						
							|  |  |  | +            return;
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							| 
									
										
										
										
											2016-11-17 12:41:03 +11:00
										 |  |  | +        java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(this.inventory.getSize());
 | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  | +        boolean keepInventory = this.world.getGameRules().getBoolean("keepInventory") || this.isSpectator();
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +
 | 
					
						
							|  |  |  | +        if (!keepInventory) {
 | 
					
						
							| 
									
										
										
										
											2016-11-17 12:41:03 +11:00
										 |  |  | +            for (ItemStack item : this.inventory.getContents()) {
 | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  | +                if (!item.isEmpty() && !EnchantmentManager.shouldNotDrop(item)) {
 | 
					
						
							| 
									
										
										
										
											2016-11-17 12:41:03 +11:00
										 |  |  | +                    loot.add(CraftItemStack.asCraftMirror(item));
 | 
					
						
							| 
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 |  |  | +                }
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +            }
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  |   | 
					
						
							|  |  |  | -        if (flag) {
 | 
					
						
							|  |  |  | -            IChatBaseComponent ichatbasecomponent = this.getCombatTracker().getDeathMessage();
 | 
					
						
							|  |  |  | +        IChatBaseComponent defaultMessage = this.getCombatTracker().getDeathMessage();
 | 
					
						
							| 
									
										
										
										
											2018-06-14 19:59:21 +02:00
										 |  |  | +
 | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  | +        String deathmessage = defaultMessage.getString();
 | 
					
						
							| 
									
										
										
										
											2018-06-14 19:59:21 +02:00
										 |  |  | +        org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage, keepInventory);
 | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  | +
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +        String deathMessage = event.getDeathMessage();
 | 
					
						
							|  |  |  | +
 | 
					
						
							| 
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 |  |  | +        if (deathMessage != null && deathMessage.length() > 0 && flag) { // TODO: allow plugins to override?
 | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  | +            IChatBaseComponent ichatbasecomponent;
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +            if (deathMessage.equals(deathmessage)) {
 | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  | +                ichatbasecomponent = this.getCombatTracker().getDeathMessage();
 | 
					
						
							|  |  |  | +            } else {
 | 
					
						
							|  |  |  | +                ichatbasecomponent = org.bukkit.craftbukkit.util.CraftChatMessage.fromStringOrNull(deathMessage);
 | 
					
						
							|  |  |  | +            }
 | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |              this.playerConnection.a((Packet) (new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, ichatbasecomponent)), (future) -> { | 
					
						
							|  |  |  |                  if (!future.isSuccess()) { | 
					
						
							|  |  |  | -                    boolean flag = true;
 | 
					
						
							|  |  |  |                      String s = ichatbasecomponent.a(256); | 
					
						
							|  |  |  |                      ChatMessage chatmessage = new ChatMessage("death.attack.message_too_long", new Object[] { (new ChatComponentText(s)).a(EnumChatFormat.YELLOW)}); | 
					
						
							|  |  |  |                      IChatBaseComponent ichatbasecomponent1 = (new ChatMessage("death.attack.even_more_magic", new Object[] { this.getScoreboardDisplayName()})).a((chatmodifier) -> { | 
					
						
							|  |  |  | -                        chatmodifier.setChatHoverable(new ChatHoverable(ChatHoverable.EnumHoverAction.SHOW_TEXT, ichatbasecomponent));
 | 
					
						
							|  |  |  | +                        chatmodifier.setChatHoverable(new ChatHoverable(ChatHoverable.EnumHoverAction.SHOW_TEXT, chatmessage));
 | 
					
						
							|  |  |  |                      }); | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |                      this.playerConnection.sendPacket(new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, ichatbasecomponent1)); | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -370,12 +531,17 @@
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |          } | 
					
						
							| 
									
										
										
										
											2015-02-26 22:41:06 +00:00
										 |  |  |   | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  |          this.releaseShoulderEntities(); | 
					
						
							| 
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 |  |  | -        if (!this.world.getGameRules().getBoolean("keepInventory") && !this.isSpectator()) {
 | 
					
						
							| 
									
										
										
										
											2018-12-13 11:00:00 +11:00
										 |  |  | -            this.removeCursedItems();
 | 
					
						
							|  |  |  | -            this.inventory.dropContents();
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +        // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory.
 | 
					
						
							|  |  |  | +        if (!event.getKeepInventory()) {
 | 
					
						
							| 
									
										
										
										
											2016-11-17 12:41:03 +11:00
										 |  |  | +            this.inventory.clear();
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |          } | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2018-12-13 11:00:00 +11:00
										 |  |  | -        this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.DEATH_COUNT, this.getName(), ScoreboardScore::incrementScore);
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +        this.closeInventory();
 | 
					
						
							| 
									
										
										
										
											2015-05-05 21:43:47 +01:00
										 |  |  | +        this.setSpectatorTarget(this); // Remove spectated target
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +        // CraftBukkit end
 | 
					
						
							| 
									
										
										
										
											2015-02-26 22:41:06 +00:00
										 |  |  | +
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +        // CraftBukkit - Get our scores instead
 | 
					
						
							| 
									
										
										
										
											2018-12-13 11:00:00 +11:00
										 |  |  | +        this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.DEATH_COUNT, this.getName(), ScoreboardScore::incrementScore);
 | 
					
						
							| 
									
										
										
										
											2018-07-22 12:00:00 +10:00
										 |  |  |          EntityLiving entityliving = this.cv(); | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |   | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |          if (entityliving != null) { | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -398,10 +564,12 @@
 | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |              String s = this.getName(); | 
					
						
							|  |  |  |              String s1 = entity.getName(); | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |   | 
					
						
							| 
									
										
										
										
											2018-12-13 11:00:00 +11:00
										 |  |  | -            this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.TOTAL_KILL_COUNT, s, ScoreboardScore::incrementScore);
 | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  | +            // CraftBukkit - Get our scores instead
 | 
					
						
							| 
									
										
										
										
											2018-12-13 11:00:00 +11:00
										 |  |  | +            this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.TOTAL_KILL_COUNT, s, ScoreboardScore::incrementScore);
 | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  |              if (entity instanceof EntityHuman) { | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |                  this.a(StatisticList.PLAYER_KILLS); | 
					
						
							| 
									
										
										
										
											2018-12-13 11:00:00 +11:00
										 |  |  | -                this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.PLAYER_KILL_COUNT, s, ScoreboardScore::incrementScore);
 | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  | +                // CraftBukkit - Get our scores instead
 | 
					
						
							| 
									
										
										
										
											2018-12-13 11:00:00 +11:00
										 |  |  | +                this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.PLAYER_KILL_COUNT, s, ScoreboardScore::incrementScore);
 | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  |              } else { | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |                  this.a(StatisticList.MOB_KILLS); | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  |              } | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -419,7 +587,8 @@
 | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |              int i = scoreboardteam.getColor().b(); | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  |   | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |              if (i >= 0 && i < aiscoreboardcriteria.length) { | 
					
						
							|  |  |  | -                this.getScoreboard().getObjectivesForCriteria(aiscoreboardcriteria[i], s, ScoreboardScore::incrementScore);
 | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  | +                // CraftBukkit - Get our scores instead
 | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  | +                this.world.getServer().getScoreboardManager().getScoreboardScores(aiscoreboardcriteria[i], s, ScoreboardScore::incrementScore);
 | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  |              } | 
					
						
							|  |  |  |          } | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -461,12 +630,14 @@
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 |  |  |      private boolean canPvP() { | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | -        return this.server.getPVP();
 | 
					
						
							|  |  |  | +        // CraftBukkit - this.server.getPvP() -> this.world.pvpMode
 | 
					
						
							|  |  |  | +        return this.world.pvpMode;
 | 
					
						
							|  |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2016-05-10 21:47:39 +10:00
										 |  |  |      @Nullable | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  |      public Entity a(DimensionManager dimensionmanager) { | 
					
						
							| 
									
										
										
										
											2016-06-09 11:43:49 +10:00
										 |  |  | -        this.worldChangeInvuln = true;
 | 
					
						
							| 
									
										
										
										
											2017-03-30 21:53:23 +11:00
										 |  |  | +        if (this.isSleeping()) return this; // CraftBukkit - SPIGOT-3154
 | 
					
						
							| 
									
										
										
										
											2016-06-09 11:43:49 +10:00
										 |  |  | +        // this.worldChangeInvuln = true; // CraftBukkit - Moved down and into PlayerList#changeDimension
 | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  |          if (this.dimension == DimensionManager.OVERWORLD && dimensionmanager == DimensionManager.NETHER) { | 
					
						
							|  |  |  |              this.cC = new Vec3D(this.locX, this.locY, this.locZ); | 
					
						
							|  |  |  |          } else if (this.dimension != DimensionManager.NETHER && dimensionmanager != DimensionManager.OVERWORLD) { | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -474,6 +645,7 @@
 | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  |          } | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  |          if (this.dimension == DimensionManager.THE_END && dimensionmanager == DimensionManager.THE_END) { | 
					
						
							| 
									
										
										
										
											2016-06-09 11:43:49 +10:00
										 |  |  | +            this.worldChangeInvuln = true; // CraftBukkit - Moved down from above
 | 
					
						
							| 
									
										
										
										
											2016-03-22 12:39:41 -05:00
										 |  |  |              this.world.kill(this); | 
					
						
							|  |  |  |              if (!this.viewingCredits) { | 
					
						
							|  |  |  |                  this.viewingCredits = true; | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -487,7 +659,10 @@
 | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  |                  dimensionmanager = DimensionManager.THE_END; | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |              } | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  | -            this.server.getPlayerList().a(this, dimensionmanager);
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +            // CraftBukkit start
 | 
					
						
							| 
									
										
										
										
											2018-09-07 07:14:59 +10:00
										 |  |  | +            TeleportCause cause = (this.dimension == DimensionManager.THE_END || dimensionmanager == DimensionManager.THE_END) ? TeleportCause.END_PORTAL : TeleportCause.NETHER_PORTAL;
 | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  | +            this.server.getPlayerList().changeDimension(this, dimensionmanager, cause); // PAIL: check all this
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +            // CraftBukkit end
 | 
					
						
							| 
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 |  |  |              this.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1032, BlockPosition.ZERO, 0, false)); | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |              this.lastSentExp = -1; | 
					
						
							| 
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 |  |  |              this.lastHealthSent = -1.0F; | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -533,6 +708,7 @@
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |      public void a(boolean flag, boolean flag1, boolean flag2) { | 
					
						
							|  |  |  | +        if (!this.sleeping) return; // CraftBukkit - Can't leave bed if not in one!
 | 
					
						
							|  |  |  |          if (this.isSleeping()) { | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |              this.getWorldServer().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 2)); | 
					
						
							| 
									
										
										
										
											2015-02-20 15:37:17 +11:00
										 |  |  |          } | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -611,23 +787,55 @@
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |          this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition())); | 
					
						
							|  |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 |  |  | -    public void nextContainerCounter() {
 | 
					
						
							|  |  |  | +    public int nextContainerCounter() { // CraftBukkit - void -> int
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |          this.containerCounter = this.containerCounter % 100 + 1; | 
					
						
							|  |  |  | +        return containerCounter; // CraftBukkit
 | 
					
						
							|  |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |      public void openTileEntity(ITileEntityContainer itileentitycontainer) { | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  | -        if (itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).getLootTable() != null && this.isSpectator()) {
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +        // CraftBukkit start - Inventory open hook
 | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  | +        if (false && itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).getLootTable() != null && this.isSpectator()) {
 | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |              this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).a(EnumChatFormat.RED), true); | 
					
						
							| 
									
										
										
										
											2016-11-17 12:41:03 +11:00
										 |  |  |          } else { | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  | +            boolean cancelled = itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).getLootTable()!= null && this.isSpectator();
 | 
					
						
							| 
									
										
										
										
											2016-11-17 12:41:03 +11:00
										 |  |  | +            Container container = CraftEventFactory.callInventoryOpenEvent(this, itileentitycontainer.createContainer(this.inventory, this), cancelled);
 | 
					
						
							|  |  |  | +            if (container == null) {
 | 
					
						
							|  |  |  | +                return;
 | 
					
						
							|  |  |  | +            }
 | 
					
						
							|  |  |  |              this.nextContainerCounter(); | 
					
						
							| 
									
										
										
										
											2017-01-27 11:42:21 +11:00
										 |  |  | +            this.activeContainer = container;
 | 
					
						
							| 
									
										
										
										
											2016-11-17 12:41:03 +11:00
										 |  |  |              this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, itileentitycontainer.getContainerName(), itileentitycontainer.getScoreboardDisplayName())); | 
					
						
							|  |  |  | -            this.activeContainer = itileentitycontainer.createContainer(this.inventory, this);
 | 
					
						
							|  |  |  | +            // CraftBukkit end
 | 
					
						
							|  |  |  |              this.activeContainer.windowId = this.containerCounter; | 
					
						
							|  |  |  |              this.activeContainer.addSlotListener(this); | 
					
						
							| 
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 |  |  |          } | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |      public void openContainer(IInventory iinventory) { | 
					
						
							|  |  |  | +        // CraftBukkit start - Inventory open hook
 | 
					
						
							| 
									
										
										
										
											2014-12-28 15:14:53 +00:00
										 |  |  | +        // Copied from below
 | 
					
						
							|  |  |  | +        boolean cancelled = false;
 | 
					
						
							|  |  |  | +        if (iinventory instanceof ITileInventory) {
 | 
					
						
							|  |  |  | +            ITileInventory itileinventory = (ITileInventory) iinventory;
 | 
					
						
							| 
									
										
										
										
											2016-11-17 12:41:03 +11:00
										 |  |  | +            cancelled = itileinventory.isLocked() && !this.a(itileinventory.getLock()) && !this.isSpectator();
 | 
					
						
							| 
									
										
										
										
											2014-12-28 15:14:53 +00:00
										 |  |  | +        }
 | 
					
						
							|  |  |  | +
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +        Container container;
 | 
					
						
							|  |  |  | +        if (iinventory instanceof ITileEntityContainer) {
 | 
					
						
							| 
									
										
										
										
											2017-01-10 09:56:20 +11:00
										 |  |  | +            if (iinventory instanceof TileEntity) {
 | 
					
						
							|  |  |  | +                Preconditions.checkArgument(((TileEntity) iinventory).getWorld() != null, "Container must have world to be opened");
 | 
					
						
							|  |  |  | +            }
 | 
					
						
							| 
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 |  |  | +            container = ((ITileEntityContainer) iinventory).createContainer(this.inventory, this);
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +        } else {
 | 
					
						
							|  |  |  | +            container = new ContainerChest(this.inventory, iinventory, this);
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							| 
									
										
										
										
											2014-12-28 15:14:53 +00:00
										 |  |  | +        container = CraftEventFactory.callInventoryOpenEvent(this, container, cancelled);
 | 
					
						
							|  |  |  | +        if (container == null && !cancelled) { // Let pre-cancelled events fall through
 | 
					
						
							| 
									
										
										
										
											2014-12-28 16:05:42 +00:00
										 |  |  | +            iinventory.closeContainer(this);
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +            return;
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							|  |  |  | +        // CraftBukkit end
 | 
					
						
							| 
									
										
										
										
											2014-12-28 16:05:42 +00:00
										 |  |  | +
 | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  |          if (iinventory instanceof ILootable && ((ILootable) iinventory).getLootTable() != null && this.isSpectator()) { | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |              this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).a(EnumChatFormat.RED), true); | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |          } else { | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -641,18 +849,21 @@
 | 
					
						
							| 
									
										
										
										
											2016-11-17 12:41:03 +11:00
										 |  |  |                  if (itileinventory.isLocked() && !this.a(itileinventory.getLock()) && !this.isSpectator()) { | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  |                      this.playerConnection.sendPacket(new PacketPlayOutChat(new ChatMessage("container.isLocked", new Object[] { iinventory.getScoreboardDisplayName()}), ChatMessageType.GAME_INFO)); | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |                      this.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, this.locX, this.locY, this.locZ, 1.0F, 1.0F)); | 
					
						
							| 
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 |  |  | +                    iinventory.closeContainer(this); // CraftBukkit
 | 
					
						
							|  |  |  |                      return; | 
					
						
							|  |  |  |                  } | 
					
						
							|  |  |  |              } | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |   | 
					
						
							| 
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 |  |  |              this.nextContainerCounter(); | 
					
						
							|  |  |  | +            // CraftBukkit start
 | 
					
						
							|  |  |  |              if (iinventory instanceof ITileEntityContainer) { | 
					
						
							|  |  |  | +                this.activeContainer = container;
 | 
					
						
							|  |  |  |                  this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, ((ITileEntityContainer) iinventory).getContainerName(), iinventory.getScoreboardDisplayName(), iinventory.getSize())); | 
					
						
							|  |  |  | -                this.activeContainer = ((ITileEntityContainer) iinventory).createContainer(this.inventory, this);
 | 
					
						
							|  |  |  |              } else { | 
					
						
							|  |  |  | +                this.activeContainer = container;
 | 
					
						
							|  |  |  |                  this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, "minecraft:container", iinventory.getScoreboardDisplayName(), iinventory.getSize())); | 
					
						
							|  |  |  | -                this.activeContainer = new ContainerChest(this.inventory, iinventory, this);
 | 
					
						
							|  |  |  |              } | 
					
						
							|  |  |  | +            // CraftBukkit end
 | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |              this.activeContainer.windowId = this.containerCounter; | 
					
						
							|  |  |  |              this.activeContainer.addSlotListener(this); | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -660,8 +871,14 @@
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |      public void openTrade(IMerchant imerchant) { | 
					
						
							|  |  |  | +        // CraftBukkit start - Inventory open hook
 | 
					
						
							|  |  |  | +        Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerMerchant(this.inventory, imerchant, this.world));
 | 
					
						
							|  |  |  | +        if (container == null) {
 | 
					
						
							|  |  |  | +            return;
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							|  |  |  | +        // CraftBukkit end
 | 
					
						
							|  |  |  |          this.nextContainerCounter(); | 
					
						
							|  |  |  | -        this.activeContainer = new ContainerMerchant(this.inventory, imerchant, this.world);
 | 
					
						
							| 
									
										
										
										
											2015-02-26 22:41:06 +00:00
										 |  |  | +        this.activeContainer = container; // CraftBukkit
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |          this.activeContainer.windowId = this.containerCounter; | 
					
						
							|  |  |  |          this.activeContainer.addSlotListener(this); | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |          InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).d(); | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -681,13 +898,20 @@
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2016-11-17 12:41:03 +11:00
										 |  |  |      public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +        // CraftBukkit start - Inventory open hook
 | 
					
						
							| 
									
										
										
										
											2016-11-17 12:41:03 +11:00
										 |  |  | +        Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHorse(this.inventory, iinventory, entityhorseabstract, this));
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +        if (container == null) {
 | 
					
						
							|  |  |  | +            iinventory.closeContainer(this);
 | 
					
						
							|  |  |  | +            return;
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							| 
									
										
										
										
											2015-02-26 22:41:06 +00:00
										 |  |  | +        // CraftBukkit end
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |          if (this.activeContainer != this.defaultContainer) { | 
					
						
							|  |  |  |              this.closeInventory(); | 
					
						
							|  |  |  |          } | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |          this.nextContainerCounter(); | 
					
						
							| 
									
										
										
										
											2016-11-17 12:41:03 +11:00
										 |  |  |          this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, "EntityHorse", iinventory.getScoreboardDisplayName(), iinventory.getSize(), entityhorseabstract.getId())); | 
					
						
							|  |  |  | -        this.activeContainer = new ContainerHorse(this.inventory, iinventory, entityhorseabstract, this);
 | 
					
						
							|  |  |  | +        this.activeContainer = container; // CraftBukkit
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |          this.activeContainer.windowId = this.containerCounter; | 
					
						
							|  |  |  |          this.activeContainer.addSlotListener(this); | 
					
						
							|  |  |  |      } | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -728,6 +952,11 @@
 | 
					
						
							| 
									
										
										
										
											2016-11-17 12:41:03 +11:00
										 |  |  |      public void a(Container container, NonNullList<ItemStack> nonnulllist) { | 
					
						
							|  |  |  |          this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, nonnulllist)); | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |          this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried())); | 
					
						
							|  |  |  | +        // CraftBukkit start - Send a Set Slot to update the crafting result slot
 | 
					
						
							|  |  |  | +        if (java.util.EnumSet.of(InventoryType.CRAFTING,InventoryType.WORKBENCH).contains(container.getBukkitView().getType())) {
 | 
					
						
							|  |  |  | +            this.playerConnection.sendPacket(new PacketPlayOutSetSlot(container.windowId, 0, container.getSlot(0).getItem()));
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							|  |  |  | +        // CraftBukkit end
 | 
					
						
							|  |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |      public void setContainerData(Container container, int i, int j) { | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -742,6 +971,7 @@
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |      public void closeInventory() { | 
					
						
							|  |  |  | +        CraftEventFactory.handleInventoryCloseEvent(this); // CraftBukkit
 | 
					
						
							|  |  |  |          this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId)); | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |          this.m(); | 
					
						
							|  |  |  |      } | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -775,14 +1005,14 @@
 | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |   | 
					
						
							|  |  |  |      public void a(Statistic<?> statistic, int i) { | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  |          this.cg.b(this, statistic, i); | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  | -        this.getScoreboard().getObjectivesForCriteria(statistic, this.getName(), (scoreboardscore) -> {
 | 
					
						
							|  |  |  | +        this.world.getServer().getScoreboardManager().getScoreboardScores(statistic, this.getName(), (scoreboardscore) -> { // CraftBukkit - Get our scores instead
 | 
					
						
							|  |  |  |              scoreboardscore.addScore(i); | 
					
						
							|  |  |  |          }); | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |      public void a(Statistic<?> statistic) { | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  |          this.cg.setStatistic(this, statistic, 0); | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  | -        this.getScoreboard().getObjectivesForCriteria(statistic, this.getName(), ScoreboardScore::c);
 | 
					
						
							|  |  |  | +        this.world.getServer().getScoreboardManager().getScoreboardScores(statistic, this.getName(), ScoreboardScore::c); // CraftBukkit - Get our scores instead
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |      } | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  |   | 
					
						
							| 
									
										
										
										
											2018-10-23 06:00:00 +11:00
										 |  |  |      public int discoverRecipes(Collection<IRecipe> collection) { | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -830,8 +1060,17 @@
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |   | 
					
						
							|  |  |  |      public void triggerHealthUpdate() { | 
					
						
							| 
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 |  |  |          this.lastHealthSent = -1.0E8F; | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +        this.lastSentExp = -1; // CraftBukkit - Added to reset
 | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +    // CraftBukkit start - Support multi-line messages
 | 
					
						
							|  |  |  | +    public void sendMessage(IChatBaseComponent[] ichatbasecomponent) {
 | 
					
						
							|  |  |  | +        for (IChatBaseComponent component : ichatbasecomponent) {
 | 
					
						
							|  |  |  | +            this.sendMessage(component);
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  | +    }
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +    // CraftBukkit end
 | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  | +
 | 
					
						
							| 
									
										
										
										
											2016-11-17 12:41:03 +11:00
										 |  |  |      public void a(IChatBaseComponent ichatbasecomponent, boolean flag) { | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  |          this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, flag ? ChatMessageType.GAME_INFO : ChatMessageType.CHAT)); | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |      } | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -882,7 +1121,7 @@
 | 
					
						
							| 
									
										
										
										
											2017-05-15 18:11:48 +10:00
										 |  |  |          this.lastSentExp = -1; | 
					
						
							|  |  |  |          this.lastHealthSent = -1.0F; | 
					
						
							| 
									
										
										
										
											2018-12-13 11:00:00 +11:00
										 |  |  |          this.lastFoodSent = -1; | 
					
						
							|  |  |  | -        this.recipeBook.a((RecipeBook) entityplayer.recipeBook);
 | 
					
						
							|  |  |  | +        // this.recipeBook.a((RecipeBook) entityplayer.recipeBook); // CraftBukkit
 | 
					
						
							| 
									
										
										
										
											2017-05-15 18:11:48 +10:00
										 |  |  |          this.removeQueue.addAll(entityplayer.removeQueue); | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  |          this.cx = entityplayer.cx; | 
					
						
							|  |  |  |          this.cC = entityplayer.cC; | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -941,6 +1180,18 @@
 | 
					
						
							| 
									
										
										
										
											2014-12-15 14:14:59 +00:00
										 |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2016-06-09 11:43:49 +10:00
										 |  |  |      public void a(EnumGamemode enumgamemode) { | 
					
						
							| 
									
										
										
										
											2017-03-31 21:21:11 +11:00
										 |  |  | +        // CraftBukkit start
 | 
					
						
							|  |  |  | +        if (enumgamemode == this.playerInteractManager.getGameMode()) {
 | 
					
						
							|  |  |  | +            return;
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +        PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(getBukkitEntity(), GameMode.getByValue(enumgamemode.getId()));
 | 
					
						
							|  |  |  | +        world.getServer().getPluginManager().callEvent(event);
 | 
					
						
							|  |  |  | +        if (event.isCancelled()) {
 | 
					
						
							|  |  |  | +            return;
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							|  |  |  | +        // CraftBukkit end
 | 
					
						
							|  |  |  | +
 | 
					
						
							| 
									
										
										
										
											2016-06-09 11:43:49 +10:00
										 |  |  |          this.playerInteractManager.setGameMode(enumgamemode); | 
					
						
							|  |  |  |          this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.getId())); | 
					
						
							|  |  |  |          if (enumgamemode == EnumGamemode.SPECTATOR) { | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -988,6 +1239,17 @@
 | 
					
						
							| 
									
										
										
										
											2016-05-27 18:53:36 +10:00
										 |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |      public void a(PacketPlayInSettings packetplayinsettings) { | 
					
						
							|  |  |  | +        // CraftBukkit start
 | 
					
						
							| 
									
										
										
										
											2016-06-09 11:43:49 +10:00
										 |  |  | +        if (getMainHand() != packetplayinsettings.getMainHand()) {
 | 
					
						
							| 
									
										
										
										
											2016-05-27 18:53:36 +10:00
										 |  |  | +            PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(getBukkitEntity(), getMainHand() == EnumMainHand.LEFT ? MainHand.LEFT : MainHand.RIGHT);
 | 
					
						
							|  |  |  | +            this.server.server.getPluginManager().callEvent(event);
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							| 
									
										
										
										
											2018-07-17 06:21:43 +10:00
										 |  |  | +        if (!this.locale.equals(packetplayinsettings.b())) {
 | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  | +            PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(getBukkitEntity(), packetplayinsettings.b());
 | 
					
						
							| 
									
										
										
										
											2017-05-26 23:37:06 +02:00
										 |  |  | +            this.server.server.getPluginManager().callEvent(event);
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							| 
									
										
										
										
											2018-12-06 10:00:00 +11:00
										 |  |  | +        this.clientViewDistance = packetplayinsettings.viewDistance;
 | 
					
						
							| 
									
										
										
										
											2016-05-27 18:53:36 +10:00
										 |  |  | +        // CraftBukkit end
 | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |          this.locale = packetplayinsettings.b(); | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  |          this.cs = packetplayinsettings.d(); | 
					
						
							|  |  |  |          this.ct = packetplayinsettings.e(); | 
					
						
							| 
									
										
										
										
											2018-12-06 10:00:00 +11:00
										 |  |  | @@ -1023,13 +1285,13 @@
 | 
					
						
							|  |  |  |          if (entity instanceof EntityHuman) { | 
					
						
							|  |  |  |              this.playerConnection.sendPacket(new PacketPlayOutEntityDestroy(new int[] { entity.getId()})); | 
					
						
							|  |  |  |          } else { | 
					
						
							|  |  |  | -            this.removeQueue.add(entity.getId());
 | 
					
						
							|  |  |  | +            this.removeQueue.add((Integer) entity.getId()); // CraftBukkit - decompile error
 | 
					
						
							|  |  |  |          } | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |      public void d(Entity entity) { | 
					
						
							|  |  |  | -        this.removeQueue.remove(entity.getId());
 | 
					
						
							|  |  |  | +        this.removeQueue.remove((Integer) entity.getId()); // CraftBukkit - decompile error
 | 
					
						
							|  |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |      protected void C() { | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -1053,7 +1315,7 @@
 | 
					
						
							| 
									
										
										
										
											2018-12-13 11:00:00 +11:00
										 |  |  |          this.spectatedEntity = (Entity) (entity == null ? this : entity); | 
					
						
							|  |  |  |          if (entity1 != this.spectatedEntity) { | 
					
						
							|  |  |  |              this.playerConnection.sendPacket(new PacketPlayOutCamera(this.spectatedEntity)); | 
					
						
							|  |  |  | -            this.enderTeleportTo(this.spectatedEntity.locX, this.spectatedEntity.locY, this.spectatedEntity.locZ);
 | 
					
						
							|  |  |  | +            this.playerConnection.a(this.spectatedEntity.locX, this.spectatedEntity.locY, this.spectatedEntity.locZ, this.yaw, this.pitch, TeleportCause.SPECTATE); // CraftBukkit
 | 
					
						
							| 
									
										
										
										
											2017-03-24 15:08:19 +11:00
										 |  |  |          } | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |      } | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -1080,7 +1342,7 @@
 | 
					
						
							| 
									
										
										
										
											2016-03-02 18:32:06 +11:00
										 |  |  |   | 
					
						
							| 
									
										
										
										
											2016-05-10 21:47:39 +10:00
										 |  |  |      @Nullable | 
					
						
							| 
									
										
										
										
											2016-03-02 18:32:06 +11:00
										 |  |  |      public IChatBaseComponent getPlayerListName() { | 
					
						
							|  |  |  | -        return null;
 | 
					
						
							|  |  |  | +        return listName; // CraftBukkit
 | 
					
						
							|  |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |      public void a(EnumHand enumhand) { | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -1097,12 +1359,17 @@
 | 
					
						
							| 
									
										
										
										
											2016-03-12 20:57:32 +11:00
										 |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |      public void J() { | 
					
						
							| 
									
										
										
										
											2016-03-12 20:57:32 +11:00
										 |  |  | +        if (!CraftEventFactory.callToggleGlideEvent(this, true).isCancelled()) // CraftBukkit
 | 
					
						
							| 
									
										
										
										
											2016-03-01 08:32:46 +11:00
										 |  |  |          this.setFlag(7, true); | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  |      } | 
					
						
							| 
									
										
										
										
											2016-03-12 20:57:32 +11:00
										 |  |  |   | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |      public void K() { | 
					
						
							| 
									
										
										
										
											2016-03-12 20:57:32 +11:00
										 |  |  | +        // CraftBukkit start
 | 
					
						
							|  |  |  | +        if (!CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) {
 | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  |          this.setFlag(7, true); | 
					
						
							|  |  |  |          this.setFlag(7, false); | 
					
						
							| 
									
										
										
										
											2016-03-12 20:57:32 +11:00
										 |  |  | +        }
 | 
					
						
							|  |  |  | +        // CraftBukkit end
 | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  |      } | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |      public AdvancementDataPlayer getAdvancementData() { | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -1114,9 +1381,16 @@
 | 
					
						
							| 
									
										
										
										
											2018-08-26 12:00:00 +10:00
										 |  |  |          return this.cC; | 
					
						
							| 
									
										
										
										
											2017-05-14 12:00:00 +10:00
										 |  |  |      } | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |   | 
					
						
							|  |  |  | +    // CraftBukkit start
 | 
					
						
							|  |  |  |      public void a(WorldServer worldserver, double d0, double d1, double d2, float f, float f1) { | 
					
						
							|  |  |  | +        this.a(worldserver, d0, d1, d2, f, f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN);
 | 
					
						
							|  |  |  | +    }
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +    public void a(WorldServer worldserver, double d0, double d1, double d2, float f, float f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) {
 | 
					
						
							|  |  |  | +        // CraftBukkit end
 | 
					
						
							|  |  |  |          this.setSpectatorTarget(this); | 
					
						
							|  |  |  |          this.stopRiding(); | 
					
						
							|  |  |  | +        /* CraftBukkit start - replace with bukkit handling for multi-world
 | 
					
						
							|  |  |  |          if (worldserver == this.world) { | 
					
						
							|  |  |  |              this.playerConnection.a(d0, d1, d2, f, f1); | 
					
						
							|  |  |  |          } else { | 
					
						
							| 
									
										
										
										
											2018-11-02 21:24:14 +11:00
										 |  |  | @@ -1141,6 +1415,149 @@
 | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |              this.server.getPlayerList().b(this, worldserver); | 
					
						
							|  |  |  |              this.server.getPlayerList().updateClient(this); | 
					
						
							|  |  |  |          } | 
					
						
							|  |  |  | +        */
 | 
					
						
							|  |  |  | +        this.getBukkitEntity().teleport(new Location(worldserver.getWorld(), d0, d1, d2, f, f1), cause);
 | 
					
						
							|  |  |  | +        // CraftBukkit end
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +    }
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +
 | 
					
						
							|  |  |  | +    // CraftBukkit start - Add per-player time and weather.
 | 
					
						
							|  |  |  | +    public long timeOffset = 0;
 | 
					
						
							|  |  |  | +    public boolean relativeTime = true;
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +    public long getPlayerTime() {
 | 
					
						
							|  |  |  | +        if (this.relativeTime) {
 | 
					
						
							|  |  |  | +            // Adds timeOffset to the current server time.
 | 
					
						
							|  |  |  | +            return this.world.getDayTime() + this.timeOffset;
 | 
					
						
							|  |  |  | +        } else {
 | 
					
						
							|  |  |  | +            // Adds timeOffset to the beginning of this day.
 | 
					
						
							|  |  |  | +            return this.world.getDayTime() - (this.world.getDayTime() % 24000) + this.timeOffset;
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							|  |  |  | +    }
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +    public WeatherType weather = null;
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +    public WeatherType getPlayerWeather() {
 | 
					
						
							|  |  |  | +        return this.weather;
 | 
					
						
							|  |  |  | +    }
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +    public void setPlayerWeather(WeatherType type, boolean plugin) {
 | 
					
						
							|  |  |  | +        if (!plugin && this.weather != null) {
 | 
					
						
							|  |  |  | +            return;
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +        if (plugin) {
 | 
					
						
							|  |  |  | +            this.weather = type;
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +        if (type == WeatherType.DOWNFALL) {
 | 
					
						
							|  |  |  | +            this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(2, 0));
 | 
					
						
							|  |  |  | +        } else {
 | 
					
						
							|  |  |  | +            this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0));
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							|  |  |  | +    }
 | 
					
						
							| 
									
										
										
										
											2015-02-26 22:41:06 +00:00
										 |  |  | +
 | 
					
						
							| 
									
										
										
										
											2014-12-02 15:13:07 +00:00
										 |  |  | +    private float pluginRainPosition;
 | 
					
						
							|  |  |  | +    private float pluginRainPositionPrevious;
 | 
					
						
							| 
									
										
										
										
											2015-02-26 22:41:06 +00:00
										 |  |  | +
 | 
					
						
							| 
									
										
										
										
											2014-12-02 15:13:07 +00:00
										 |  |  | +    public void updateWeather(float oldRain, float newRain, float oldThunder, float newThunder) {
 | 
					
						
							|  |  |  | +        if (this.weather == null) {
 | 
					
						
							|  |  |  | +            // Vanilla
 | 
					
						
							|  |  |  | +            if (oldRain != newRain) {
 | 
					
						
							|  |  |  | +                this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, newRain));
 | 
					
						
							| 
									
										
										
										
											2015-02-26 22:41:06 +00:00
										 |  |  | +            }
 | 
					
						
							| 
									
										
										
										
											2014-12-02 15:13:07 +00:00
										 |  |  | +        } else {
 | 
					
						
							|  |  |  | +            // Plugin
 | 
					
						
							|  |  |  | +            if (pluginRainPositionPrevious != pluginRainPosition) {
 | 
					
						
							|  |  |  | +                this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, pluginRainPosition));
 | 
					
						
							| 
									
										
										
										
											2015-02-26 22:41:06 +00:00
										 |  |  | +            }
 | 
					
						
							| 
									
										
										
										
											2014-12-02 15:13:07 +00:00
										 |  |  | +        }
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +        if (oldThunder != newThunder) {
 | 
					
						
							|  |  |  | +            if (weather == WeatherType.DOWNFALL || weather == null) {
 | 
					
						
							|  |  |  | +                this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, newThunder));
 | 
					
						
							|  |  |  | +            } else {
 | 
					
						
							|  |  |  | +                this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, 0));
 | 
					
						
							|  |  |  | +            }
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							|  |  |  | +    }
 | 
					
						
							| 
									
										
										
										
											2015-02-26 22:41:06 +00:00
										 |  |  | +
 | 
					
						
							| 
									
										
										
										
											2014-12-02 15:13:07 +00:00
										 |  |  | +    public void tickWeather() {
 | 
					
						
							|  |  |  | +        if (this.weather == null) return;
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +        pluginRainPositionPrevious = pluginRainPosition;
 | 
					
						
							|  |  |  | +        if (weather == WeatherType.DOWNFALL) {
 | 
					
						
							|  |  |  | +            pluginRainPosition += 0.01;
 | 
					
						
							|  |  |  | +        } else {
 | 
					
						
							|  |  |  | +            pluginRainPosition -= 0.01;
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +        pluginRainPosition = MathHelper.a(pluginRainPosition, 0.0F, 1.0F);
 | 
					
						
							|  |  |  | +    }
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +
 | 
					
						
							|  |  |  | +    public void resetPlayerWeather() {
 | 
					
						
							|  |  |  | +        this.weather = null;
 | 
					
						
							|  |  |  | +        this.setPlayerWeather(this.world.getWorldData().hasStorm() ? WeatherType.DOWNFALL : WeatherType.CLEAR, false);
 | 
					
						
							|  |  |  | +    }
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +    @Override
 | 
					
						
							|  |  |  | +    public String toString() {
 | 
					
						
							|  |  |  | +        return super.toString() + "(" + this.getName() + " at " + this.locX + "," + this.locY + "," + this.locZ + ")";
 | 
					
						
							|  |  |  | +    }
 | 
					
						
							|  |  |  | +
 | 
					
						
							| 
									
										
										
										
											2016-10-23 14:00:35 +11:00
										 |  |  | +    // SPIGOT-1903, MC-98153
 | 
					
						
							|  |  |  | +    public void forceSetPositionRotation(double x, double y, double z, float yaw, float pitch) {
 | 
					
						
							|  |  |  | +        this.setPositionRotation(x, y, z, yaw, pitch);
 | 
					
						
							| 
									
										
										
										
											2016-11-17 12:41:03 +11:00
										 |  |  | +        this.playerConnection.syncPosition();
 | 
					
						
							| 
									
										
										
										
											2016-10-23 14:00:35 +11:00
										 |  |  | +    }
 | 
					
						
							|  |  |  | +
 | 
					
						
							| 
									
										
										
										
											2016-11-30 09:16:01 +11:00
										 |  |  | +    @Override
 | 
					
						
							|  |  |  | +    protected boolean isFrozen() {
 | 
					
						
							|  |  |  | +        return super.isFrozen() || !getBukkitEntity().isOnline();
 | 
					
						
							|  |  |  | +    }
 | 
					
						
							|  |  |  | +
 | 
					
						
							| 
									
										
										
										
											2017-08-05 09:15:52 +10:00
										 |  |  | +    @Override
 | 
					
						
							|  |  |  | +    public Scoreboard getScoreboard() {
 | 
					
						
							|  |  |  | +        return getBukkitEntity().getScoreboard().getHandle();
 | 
					
						
							|  |  |  | +    }
 | 
					
						
							|  |  |  | +
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +    public void reset() {
 | 
					
						
							|  |  |  | +        float exp = 0;
 | 
					
						
							|  |  |  | +        boolean keepInventory = this.world.getGameRules().getBoolean("keepInventory");
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +        if (this.keepLevel || keepInventory) {
 | 
					
						
							|  |  |  | +            exp = this.exp;
 | 
					
						
							|  |  |  | +            this.newTotalExp = this.expTotal;
 | 
					
						
							|  |  |  | +            this.newLevel = this.expLevel;
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							|  |  |  | +
 | 
					
						
							|  |  |  | +        this.setHealth(this.getMaxHealth());
 | 
					
						
							|  |  |  | +        this.fireTicks = 0;
 | 
					
						
							|  |  |  | +        this.fallDistance = 0;
 | 
					
						
							|  |  |  | +        this.foodData = new FoodMetaData(this);
 | 
					
						
							|  |  |  | +        this.expLevel = this.newLevel;
 | 
					
						
							|  |  |  | +        this.expTotal = this.newTotalExp;
 | 
					
						
							|  |  |  | +        this.exp = 0;
 | 
					
						
							|  |  |  | +        this.deathTicks = 0;
 | 
					
						
							| 
									
										
										
										
											2017-11-17 11:03:30 +11:00
										 |  |  | +        this.setArrowCount(0);
 | 
					
						
							| 
									
										
										
										
											2018-07-20 16:04:37 +10:00
										 |  |  | +        this.removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DEATH);
 | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +        this.updateEffects = true;
 | 
					
						
							|  |  |  | +        this.activeContainer = this.defaultContainer;
 | 
					
						
							|  |  |  | +        this.killer = null;
 | 
					
						
							|  |  |  | +        this.lastDamager = null;
 | 
					
						
							|  |  |  | +        this.combatTracker = new CombatTracker(this);
 | 
					
						
							|  |  |  | +        this.lastSentExp = -1;
 | 
					
						
							|  |  |  | +        if (this.keepLevel || keepInventory) {
 | 
					
						
							|  |  |  | +            this.exp = exp;
 | 
					
						
							|  |  |  | +        } else {
 | 
					
						
							|  |  |  | +            this.giveExp(this.newExp);
 | 
					
						
							|  |  |  | +        }
 | 
					
						
							|  |  |  | +        this.keepLevel = false;
 | 
					
						
							|  |  |  | +    }
 | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |   | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +    @Override
 | 
					
						
							|  |  |  | +    public CraftPlayer getBukkitEntity() {
 | 
					
						
							|  |  |  | +        return (CraftPlayer) super.getBukkitEntity();
 | 
					
						
							| 
									
										
										
										
											2018-07-15 10:00:00 +10:00
										 |  |  |      } | 
					
						
							| 
									
										
										
										
											2014-11-26 08:32:16 +11:00
										 |  |  | +    // CraftBukkit end
 | 
					
						
							|  |  |  |  } |