2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/EntityPlayer.java
|
|
|
|
+++ b/net/minecraft/server/EntityPlayer.java
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -12,6 +12,20 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
|
|
|
+// CraftBukkit start
|
2017-01-09 23:56:20 +01:00
|
|
|
+import com.google.common.base.Preconditions;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.Bukkit;
|
|
|
|
+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 10:53:36 +02:00
|
|
|
+import org.bukkit.event.player.PlayerChangedMainHandEvent;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
2016-05-27 10:53:36 +02:00
|
|
|
+import org.bukkit.inventory.MainHand;
|
2014-11-25 22:32:16 +01:00
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
|
|
|
public class EntityPlayer extends EntityHuman implements ICrafting {
|
|
|
|
|
2016-11-17 02:41:03 +01:00
|
|
|
private static final Logger bR = LogManager.getLogger();
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -44,6 +58,18 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
public int ping;
|
|
|
|
public boolean viewingCredits;
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01: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;
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
|
|
|
|
super(worldserver, gameprofile);
|
2015-02-26 23:41:06 +01:00
|
|
|
playerinteractmanager.player = this;
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -67,13 +93,18 @@
|
2016-11-17 02:41:03 +01:00
|
|
|
|
|
|
|
this.server = minecraftserver;
|
|
|
|
this.bU = minecraftserver.getPlayerList().a((EntityHuman) this);
|
|
|
|
- this.P = 0.0F;
|
|
|
|
+ this.P = 1.0F; // CraftBukkit - hit when sneaking
|
|
|
|
this.setPositionRotation(blockposition, 0.0F, 0.0F);
|
|
|
|
|
|
|
|
while (!worldserver.getCubes(this, this.getBoundingBox()).isEmpty() && this.locY < 255.0D) {
|
2014-11-25 22:32:16 +01:00
|
|
|
this.setPosition(this.locX, this.locY + 1.0D, this.locZ);
|
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ this.displayName = this.getName();
|
|
|
|
+ // this.canPickUpLoot = true; TODO
|
|
|
|
+ this.maxHealthCache = this.getMaxHealth();
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -86,6 +117,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.getBukkitEntity().readExtraData(nbttagcompound); // CraftBukkit
|
|
|
|
}
|
|
|
|
|
2016-12-20 21:00:00 +01:00
|
|
|
public static void a(DataConverterManager dataconvertermanager) {
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -119,8 +151,33 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
nbttagcompound1.set("Entity", nbttagcompound2);
|
|
|
|
nbttagcompound.set("RootVehicle", nbttagcompound1);
|
|
|
|
}
|
|
|
|
+ this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit
|
2015-02-26 23:41:06 +01:00
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
|
2014-11-25 22:32:16 +01: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);
|
2015-02-26 23:41:06 +01:00
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
public void levelDown(int i) {
|
|
|
|
super.levelDown(i);
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -151,6 +208,11 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2016-11-17 02:41:03 +01:00
|
|
|
public void A_() {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (this.joining) {
|
|
|
|
+ this.joining = false;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
this.playerInteractManager.a();
|
|
|
|
--this.invulnerableTicks;
|
|
|
|
if (this.noDamageTicks > 0) {
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -210,7 +272,7 @@
|
2016-03-05 22:38:01 +01:00
|
|
|
}
|
|
|
|
|
2016-11-17 02:41:03 +01:00
|
|
|
if (this.getHealth() != this.lastHealthSent || this.cc != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.cd) {
|
2016-03-05 22:38:01 +01: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();
|
2016-11-17 02:41:03 +01:00
|
|
|
this.cc = this.foodData.getFoodLevel();
|
|
|
|
this.cd = this.foodData.getSaturationLevel() == 0.0F;
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -231,6 +293,12 @@
|
2016-11-17 02:41:03 +01:00
|
|
|
this.a(IScoreboardCriteria.i, MathHelper.f((float) this.bX));
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
+ // CraftBukkit start - Force max health updates
|
|
|
|
+ if (this.maxHealthCache != this.getMaxHealth()) {
|
|
|
|
+ this.getBukkitEntity().updateScaledHealth();
|
2016-06-09 03:43:49 +02:00
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit end
|
2016-06-09 03:43:49 +02:00
|
|
|
+
|
2016-11-17 02:41:03 +01:00
|
|
|
if (this.getArmorStrength() != this.bY) {
|
|
|
|
this.bY = this.getArmorStrength();
|
|
|
|
this.a(IScoreboardCriteria.j, MathHelper.f((float) this.bY));
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -255,6 +323,16 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
this.o();
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - initialize oldLevel and fire PlayerLevelChangeEvent
|
|
|
|
+ if (this.oldLevel == -1) {
|
|
|
|
+ this.oldLevel = this.expLevel;
|
|
|
|
+ }
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01: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 23:41:06 +01:00
|
|
|
+ // CraftBukkit end
|
2014-11-25 22:32:16 +01:00
|
|
|
} catch (Throwable throwable) {
|
|
|
|
CrashReport crashreport = CrashReport.a(throwable, "Ticking player");
|
|
|
|
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked");
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -265,12 +343,11 @@
|
2016-03-12 07:57:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void a(IScoreboardCriteria iscoreboardcriteria, int i) {
|
|
|
|
- Collection collection = this.getScoreboard().getObjectivesForCriteria(iscoreboardcriteria);
|
|
|
|
+ Collection collection = this.world.getServer().getScoreboardManager().getScoreboardScores(iscoreboardcriteria, this.getName(), new java.util.ArrayList<ScoreboardScore>()); // CraftBukkit - Use our scores instead
|
|
|
|
Iterator iterator = collection.iterator();
|
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
- ScoreboardObjective scoreboardobjective = (ScoreboardObjective) iterator.next();
|
|
|
|
- ScoreboardScore scoreboardscore = this.getScoreboard().getPlayerScoreForObjective(this.getName(), scoreboardobjective);
|
|
|
|
+ ScoreboardScore scoreboardscore = (ScoreboardScore) iterator.next(); // CraftBukkit - Use our scores instead
|
|
|
|
|
|
|
|
scoreboardscore.setScore(i);
|
|
|
|
}
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -319,31 +396,61 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
boolean flag = this.world.getGameRules().getBoolean("showDeathMessages");
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
this.playerConnection.sendPacket(new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, flag));
|
|
|
|
- if (flag) {
|
2016-06-09 03:43:49 +02:00
|
|
|
- ScoreboardTeamBase scoreboardteambase = this.aQ();
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - fire PlayerDeathEvent
|
|
|
|
+ if (this.dead) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
2016-11-17 02:41:03 +01:00
|
|
|
+ java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(this.inventory.getSize());
|
2014-11-25 22:32:16 +01:00
|
|
|
+ boolean keepInventory = this.world.getGameRules().getBoolean("keepInventory");
|
|
|
|
+
|
|
|
|
+ if (!keepInventory) {
|
2016-11-17 02:41:03 +01:00
|
|
|
+ for (ItemStack item : this.inventory.getContents()) {
|
2016-12-20 21:00:00 +01:00
|
|
|
+ if (!item.isEmpty() && !EnchantmentManager.e(item)) { // PAIL: shouldNotDrop (Vanishing enchant)
|
2016-11-17 02:41:03 +01:00
|
|
|
+ loot.add(CraftItemStack.asCraftMirror(item));
|
2016-02-29 22:32:46 +01:00
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
2016-11-17 02:41:03 +01:00
|
|
|
+
|
|
|
|
+ IChatBaseComponent chatmessage = this.getCombatTracker().getDeathMessage();
|
2017-01-09 23:56:20 +01:00
|
|
|
+
|
|
|
|
+ String deathmessage = chatmessage.toPlainText();
|
|
|
|
+ org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage, keepInventory);
|
2016-05-10 13:47:39 +02:00
|
|
|
|
|
|
|
- if (scoreboardteambase != null && scoreboardteambase.getDeathMessageVisibility() != ScoreboardTeamBase.EnumNameTagVisibility.ALWAYS) {
|
|
|
|
- if (scoreboardteambase.getDeathMessageVisibility() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OTHER_TEAMS) {
|
|
|
|
- this.server.getPlayerList().a((EntityHuman) this, this.getCombatTracker().getDeathMessage());
|
|
|
|
- } else if (scoreboardteambase.getDeathMessageVisibility() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OWN_TEAM) {
|
|
|
|
- this.server.getPlayerList().b((EntityHuman) this, this.getCombatTracker().getDeathMessage());
|
2014-11-25 22:32:16 +01:00
|
|
|
+ String deathMessage = event.getDeathMessage();
|
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ if (deathMessage != null && deathMessage.length() > 0 && flag) { // TODO: allow plugins to override?
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (deathMessage.equals(deathmessage)) {
|
2016-06-09 03:43:49 +02:00
|
|
|
+ ScoreboardTeamBase scoreboardteambase = this.aQ();
|
2016-02-29 22:32:46 +01:00
|
|
|
+
|
2016-05-10 13:47:39 +02:00
|
|
|
+ if (scoreboardteambase != null && scoreboardteambase.getDeathMessageVisibility() != ScoreboardTeamBase.EnumNameTagVisibility.ALWAYS) {
|
|
|
|
+ if (scoreboardteambase.getDeathMessageVisibility() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OTHER_TEAMS) {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ this.server.getPlayerList().a((EntityHuman) this, chatmessage);
|
2016-05-10 13:47:39 +02:00
|
|
|
+ } else if (scoreboardteambase.getDeathMessageVisibility() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OWN_TEAM) {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ this.server.getPlayerList().b((EntityHuman) this, chatmessage);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ this.server.getPlayerList().sendMessage(chatmessage);
|
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
} else {
|
2016-02-29 22:32:46 +01:00
|
|
|
- this.server.getPlayerList().sendMessage(this.getCombatTracker().getDeathMessage());
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.server.getPlayerList().sendMessage(org.bukkit.craftbukkit.util.CraftChatMessage.fromString(deathMessage));
|
|
|
|
}
|
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
- if (!this.world.getGameRules().getBoolean("keepInventory") && !this.isSpectator()) {
|
2016-11-17 02:41:03 +01:00
|
|
|
- this.cN();
|
|
|
|
- this.inventory.o();
|
2014-11-25 22:32:16 +01: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 02:41:03 +01:00
|
|
|
+ this.inventory.clear();
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- Collection collection = this.world.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.d);
|
|
|
|
+ this.closeInventory();
|
2015-05-05 22:43:47 +02:00
|
|
|
+ this.setSpectatorTarget(this); // Remove spectated target
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit - Get our scores instead
|
2014-12-10 18:04:45 +01:00
|
|
|
+ Collection collection = this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.d, this.getName(), new java.util.ArrayList<ScoreboardScore>());
|
2014-11-25 22:32:16 +01:00
|
|
|
Iterator iterator = collection.iterator();
|
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
- ScoreboardObjective scoreboardobjective = (ScoreboardObjective) iterator.next();
|
|
|
|
- ScoreboardScore scoreboardscore = this.getScoreboard().getPlayerScoreForObjective(this.getName(), scoreboardobjective);
|
|
|
|
+ ScoreboardScore scoreboardscore = (ScoreboardScore) iterator.next(); // CraftBukkit - Use our scores instead
|
|
|
|
|
|
|
|
scoreboardscore.incrementScore();
|
|
|
|
}
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -402,13 +509,15 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
private boolean canPvP() {
|
2014-11-25 22:32:16 +01:00
|
|
|
- return this.server.getPVP();
|
|
|
|
+ // CraftBukkit - this.server.getPvP() -> this.world.pvpMode
|
|
|
|
+ return this.world.pvpMode;
|
|
|
|
}
|
|
|
|
|
2016-05-10 13:47:39 +02:00
|
|
|
@Nullable
|
2016-02-29 22:32:46 +01:00
|
|
|
public Entity c(int i) {
|
2016-06-09 03:43:49 +02:00
|
|
|
- this.worldChangeInvuln = true;
|
|
|
|
+ // this.worldChangeInvuln = true; // CraftBukkit - Moved down and into PlayerList#changeDimension
|
2016-03-22 18:39:41 +01:00
|
|
|
if (this.dimension == 1 && i == 1) {
|
2016-06-09 03:43:49 +02:00
|
|
|
+ this.worldChangeInvuln = true; // CraftBukkit - Moved down from above
|
2016-03-22 18:39:41 +01:00
|
|
|
this.world.kill(this);
|
|
|
|
if (!this.viewingCredits) {
|
|
|
|
this.viewingCredits = true;
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -429,7 +538,10 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
this.b((Statistic) AchievementList.y);
|
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
- this.server.getPlayerList().a(this, i);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ TeleportCause cause = (this.dimension == 1 || i == 1) ? TeleportCause.END_PORTAL : TeleportCause.NETHER_PORTAL;
|
2016-02-29 22:32:46 +01:00
|
|
|
+ this.server.getPlayerList().changeDimension(this, i, cause); // PAIL: check all this
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit end
|
2016-02-29 22:32:46 +01:00
|
|
|
this.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1032, BlockPosition.ZERO, 0, false));
|
2014-11-25 22:32:16 +01:00
|
|
|
this.lastSentExp = -1;
|
2016-02-29 22:32:46 +01:00
|
|
|
this.lastHealthSent = -1.0F;
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -474,6 +586,7 @@
|
2014-11-25 22:32:16 +01: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()) {
|
2016-02-29 22:32:46 +01:00
|
|
|
this.x().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 2));
|
2015-02-20 05:37:17 +01:00
|
|
|
}
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -552,23 +665,55 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition()));
|
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
- public void nextContainerCounter() {
|
|
|
|
+ public int nextContainerCounter() { // CraftBukkit - void -> int
|
2014-11-25 22:32:16 +01:00
|
|
|
this.containerCounter = this.containerCounter % 100 + 1;
|
|
|
|
+ return containerCounter; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
public void openTileEntity(ITileEntityContainer itileentitycontainer) {
|
2016-02-29 22:32:46 +01:00
|
|
|
- if (itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).b() != null && this.isSpectator()) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - Inventory open hook
|
2016-11-17 02:41:03 +01:00
|
|
|
+ if (false && itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).b() != null && this.isSpectator()) {
|
|
|
|
this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).setChatModifier((new ChatModifier()).setColor(EnumChatFormat.RED)), true);
|
|
|
|
} else {
|
|
|
|
+ boolean cancelled = itileentitycontainer instanceof ILootable && ((ILootable) itileentitycontainer).b() != null && this.isSpectator();
|
|
|
|
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, itileentitycontainer.createContainer(this.inventory, this), cancelled);
|
|
|
|
+ if (container == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
this.nextContainerCounter();
|
|
|
|
this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, itileentitycontainer.getContainerName(), itileentitycontainer.getScoreboardDisplayName()));
|
|
|
|
- this.activeContainer = itileentitycontainer.createContainer(this.inventory, this);
|
|
|
|
+ this.activeContainer = container;
|
|
|
|
+ // CraftBukkit end
|
|
|
|
this.activeContainer.windowId = this.containerCounter;
|
|
|
|
this.activeContainer.addSlotListener(this);
|
2016-02-29 22:32:46 +01:00
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void openContainer(IInventory iinventory) {
|
|
|
|
+ // CraftBukkit start - Inventory open hook
|
2014-12-28 16:14:53 +01:00
|
|
|
+ // Copied from below
|
|
|
|
+ boolean cancelled = false;
|
|
|
|
+ if (iinventory instanceof ITileInventory) {
|
|
|
|
+ ITileInventory itileinventory = (ITileInventory) iinventory;
|
2016-11-17 02:41:03 +01:00
|
|
|
+ cancelled = itileinventory.isLocked() && !this.a(itileinventory.getLock()) && !this.isSpectator();
|
2014-12-28 16:14:53 +01:00
|
|
|
+ }
|
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ Container container;
|
|
|
|
+ if (iinventory instanceof ITileEntityContainer) {
|
2017-01-09 23:56:20 +01:00
|
|
|
+ if (iinventory instanceof TileEntity) {
|
|
|
|
+ Preconditions.checkArgument(((TileEntity) iinventory).getWorld() != null, "Container must have world to be opened");
|
|
|
|
+ }
|
2016-02-29 22:32:46 +01:00
|
|
|
+ container = ((ITileEntityContainer) iinventory).createContainer(this.inventory, this);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ } else {
|
|
|
|
+ container = new ContainerChest(this.inventory, iinventory, this);
|
|
|
|
+ }
|
2014-12-28 16:14:53 +01:00
|
|
|
+ container = CraftEventFactory.callInventoryOpenEvent(this, container, cancelled);
|
|
|
|
+ if (container == null && !cancelled) { // Let pre-cancelled events fall through
|
2014-12-28 17:05:42 +01:00
|
|
|
+ iinventory.closeContainer(this);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2014-12-28 17:05:42 +01:00
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
if (iinventory instanceof ILootable && ((ILootable) iinventory).b() != null && this.isSpectator()) {
|
2016-11-17 02:41:03 +01:00
|
|
|
this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).setChatModifier((new ChatModifier()).setColor(EnumChatFormat.RED)), true);
|
2014-11-25 22:32:16 +01:00
|
|
|
} else {
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -582,18 +727,21 @@
|
2016-11-17 02:41:03 +01:00
|
|
|
if (itileinventory.isLocked() && !this.a(itileinventory.getLock()) && !this.isSpectator()) {
|
2016-02-29 22:32:46 +01:00
|
|
|
this.playerConnection.sendPacket(new PacketPlayOutChat(new ChatMessage("container.isLocked", new Object[] { iinventory.getScoreboardDisplayName()}), (byte) 2));
|
2016-11-17 02:41:03 +01:00
|
|
|
this.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.Y, SoundCategory.BLOCKS, this.locX, this.locY, this.locZ, 1.0F, 1.0F));
|
2016-02-29 22:32:46 +01:00
|
|
|
+ iinventory.closeContainer(this); // CraftBukkit
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-02-29 22:32:46 +01: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);
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -601,8 +749,14 @@
|
2014-11-25 22:32:16 +01: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 23:41:06 +01:00
|
|
|
+ this.activeContainer = container; // CraftBukkit
|
2014-11-25 22:32:16 +01:00
|
|
|
this.activeContainer.windowId = this.containerCounter;
|
|
|
|
this.activeContainer.addSlotListener(this);
|
|
|
|
InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).e();
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -622,13 +776,20 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2016-11-17 02:41:03 +01:00
|
|
|
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - Inventory open hook
|
2016-11-17 02:41:03 +01:00
|
|
|
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHorse(this.inventory, iinventory, entityhorseabstract, this));
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (container == null) {
|
|
|
|
+ iinventory.closeContainer(this);
|
|
|
|
+ return;
|
|
|
|
+ }
|
2015-02-26 23:41:06 +01:00
|
|
|
+ // CraftBukkit end
|
2014-11-25 22:32:16 +01:00
|
|
|
if (this.activeContainer != this.defaultContainer) {
|
|
|
|
this.closeInventory();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.nextContainerCounter();
|
2016-11-17 02:41:03 +01: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-25 22:32:16 +01:00
|
|
|
this.activeContainer.windowId = this.containerCounter;
|
|
|
|
this.activeContainer.addSlotListener(this);
|
|
|
|
}
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -665,6 +826,11 @@
|
2016-11-17 02:41:03 +01:00
|
|
|
public void a(Container container, NonNullList<ItemStack> nonnulllist) {
|
|
|
|
this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, nonnulllist));
|
2014-11-25 22:32:16 +01: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) {
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -679,6 +845,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void closeInventory() {
|
|
|
|
+ CraftEventFactory.handleInventoryCloseEvent(this); // CraftBukkit
|
|
|
|
this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId));
|
2016-02-29 22:32:46 +01:00
|
|
|
this.s();
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -760,7 +927,16 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
public void triggerHealthUpdate() {
|
2016-02-29 22:32:46 +01:00
|
|
|
this.lastHealthSent = -1.0E8F;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ this.lastSentExp = -1; // CraftBukkit - Added to reset
|
2016-11-29 23:16:01 +01:00
|
|
|
+ }
|
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - Support multi-line messages
|
|
|
|
+ public void sendMessage(IChatBaseComponent[] ichatbasecomponent) {
|
|
|
|
+ for (IChatBaseComponent component : ichatbasecomponent) {
|
|
|
|
+ this.sendMessage(component);
|
|
|
|
+ }
|
2016-11-29 23:16:01 +01:00
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit end
|
2016-11-29 23:16:01 +01:00
|
|
|
|
2016-11-17 02:41:03 +01:00
|
|
|
public void a(IChatBaseComponent ichatbasecomponent, boolean flag) {
|
|
|
|
this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, (byte) (flag ? 2 : 0)));
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -821,6 +997,8 @@
|
2014-12-15 15:14:59 +01:00
|
|
|
}
|
|
|
|
|
2016-06-09 03:43:49 +02:00
|
|
|
public void a(EnumGamemode enumgamemode) {
|
|
|
|
+ getBukkitEntity().setGameMode(org.bukkit.GameMode.getByValue(enumgamemode.getId()));
|
2014-12-15 15:14:59 +01:00
|
|
|
+ /* CraftBukkit start - defer to our setGameMode
|
2016-06-09 03:43:49 +02:00
|
|
|
this.playerInteractManager.setGameMode(enumgamemode);
|
|
|
|
this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.getId()));
|
|
|
|
if (enumgamemode == EnumGamemode.SPECTATOR) {
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -831,6 +1009,7 @@
|
2014-12-15 15:14:59 +01:00
|
|
|
|
|
|
|
this.updateAbilities();
|
2016-11-17 02:41:03 +01:00
|
|
|
this.cw();
|
2014-12-15 15:14:59 +01:00
|
|
|
+ // CraftBukkit end */
|
|
|
|
}
|
|
|
|
|
2015-05-05 22:43:47 +02:00
|
|
|
public boolean isSpectator() {
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -846,6 +1025,7 @@
|
2014-12-12 20:27:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(int i, String s) {
|
|
|
|
+ /* CraftBukkit start
|
2016-02-29 22:32:46 +01:00
|
|
|
if ("seed".equals(s) && !this.server.aa()) {
|
2014-12-12 20:27:37 +01:00
|
|
|
return true;
|
|
|
|
} else if (!"tell".equals(s) && !"help".equals(s) && !"me".equals(s) && !"trigger".equals(s)) {
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -859,6 +1039,15 @@
|
2014-12-12 20:27:37 +01:00
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
+ */
|
2015-05-30 01:06:18 +02:00
|
|
|
+ if ("@".equals(s)) {
|
|
|
|
+ return getBukkitEntity().hasPermission("minecraft.command.selector");
|
|
|
|
+ }
|
2016-04-01 23:58:20 +02:00
|
|
|
+ if ("".equals(s)) {
|
|
|
|
+ return getBukkitEntity().isOp();
|
|
|
|
+ }
|
2016-05-26 13:06:28 +02:00
|
|
|
+ return getBukkitEntity().hasPermission("minecraft.command." + s);
|
2014-12-12 20:27:37 +01:00
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
public String A() {
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -870,6 +1059,12 @@
|
2016-05-27 10:53:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(PacketPlayInSettings packetplayinsettings) {
|
|
|
|
+ // CraftBukkit start
|
2016-06-09 03:43:49 +02:00
|
|
|
+ if (getMainHand() != packetplayinsettings.getMainHand()) {
|
2016-05-27 10:53:36 +02:00
|
|
|
+ PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(getBukkitEntity(), getMainHand() == EnumMainHand.LEFT ? MainHand.LEFT : MainHand.RIGHT);
|
|
|
|
+ this.server.server.getPluginManager().callEvent(event);
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
this.locale = packetplayinsettings.a();
|
2016-11-17 02:41:03 +01:00
|
|
|
this.cg = packetplayinsettings.c();
|
|
|
|
this.ch = packetplayinsettings.d();
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -958,7 +1153,7 @@
|
2016-03-02 08:32:06 +01:00
|
|
|
|
2016-05-10 13:47:39 +02:00
|
|
|
@Nullable
|
2016-03-02 08:32:06 +01:00
|
|
|
public IChatBaseComponent getPlayerListName() {
|
|
|
|
- return null;
|
|
|
|
+ return listName; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(EnumHand enumhand) {
|
2017-01-09 23:56:20 +01:00
|
|
|
@@ -975,11 +1170,150 @@
|
2016-03-12 10:57:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void M() {
|
|
|
|
+ if (!CraftEventFactory.callToggleGlideEvent(this, true).isCancelled()) // CraftBukkit
|
2016-02-29 22:32:46 +01:00
|
|
|
this.setFlag(7, true);
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2016-03-12 10:57:32 +01:00
|
|
|
|
|
|
|
public void N() {
|
|
|
|
- this.setFlag(7, true);
|
|
|
|
- this.setFlag(7, false);
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (!CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) {
|
|
|
|
+ this.setFlag(7, true);
|
|
|
|
+ this.setFlag(7, false);
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01: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 23:41:06 +01:00
|
|
|
+
|
2014-12-02 16:13:07 +01:00
|
|
|
+ private float pluginRainPosition;
|
|
|
|
+ private float pluginRainPositionPrevious;
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-12-02 16:13:07 +01: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 23:41:06 +01:00
|
|
|
+ }
|
2014-12-02 16:13:07 +01:00
|
|
|
+ } else {
|
|
|
|
+ // Plugin
|
|
|
|
+ if (pluginRainPositionPrevious != pluginRainPosition) {
|
|
|
|
+ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, pluginRainPosition));
|
2015-02-26 23:41:06 +01:00
|
|
|
+ }
|
2014-12-02 16:13:07 +01: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 23:41:06 +01:00
|
|
|
+
|
2014-12-02 16:13:07 +01: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-25 22:32:16 +01: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 05:00:35 +02: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 02:41:03 +01:00
|
|
|
+ this.playerConnection.syncPosition();
|
2016-10-23 05:00:35 +02:00
|
|
|
+ }
|
|
|
|
+
|
2016-11-29 23:16:01 +01:00
|
|
|
+ @Override
|
|
|
|
+ protected boolean isFrozen() {
|
|
|
|
+ return super.isFrozen() || !getBukkitEntity().isOnline();
|
|
|
|
+ }
|
|
|
|
+
|
2014-11-25 22:32:16 +01: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;
|
|
|
|
+ this.removeAllEffects();
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public CraftPlayer getBukkitEntity() {
|
|
|
|
+ return (CraftPlayer) super.getBukkitEntity();
|
2016-03-12 10:57:32 +01:00
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|