Archiviert
13
0

Fix players not being able to pickup items due to default values.

The old flag for picking up loot was default to false, making existing players not able to pickup items. We now use this flag for Players, which gives us the problem we had in 48b46f83.

To fix this, we add an incremental flag that will be cross-examined to check if the data was saved before or after the flag level was introduced.

Addresses BUKKIT-3143
Dieser Commit ist enthalten in:
feildmaster 2012-12-11 05:32:05 -06:00
Ursprung 39fdb56200
Commit 4e91fbd0db
2 geänderte Dateien mit 16 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -29,6 +29,13 @@ import org.bukkit.plugin.PluginManager;
public abstract class Entity { public abstract class Entity {
// CraftBukkit start
private static final int CURRENT_LEVEL = 1;
static boolean isLevelAtLeast(NBTTagCompound tag, int level) {
return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
}
// CraftBukkit end
private static int entityCount = 0; private static int entityCount = 0;
public int id; public int id;
public double l; public double l;
@ -1087,6 +1094,7 @@ public abstract class Entity {
nbttagcompound.setLong("WorldUUIDMost", this.world.getDataManager().getUUID().getMostSignificantBits()); nbttagcompound.setLong("WorldUUIDMost", this.world.getDataManager().getUUID().getMostSignificantBits());
nbttagcompound.setLong("UUIDLeast", this.uniqueId.getLeastSignificantBits()); nbttagcompound.setLong("UUIDLeast", this.uniqueId.getLeastSignificantBits());
nbttagcompound.setLong("UUIDMost", this.uniqueId.getMostSignificantBits()); nbttagcompound.setLong("UUIDMost", this.uniqueId.getMostSignificantBits());
nbttagcompound.setInt("Bukkit.updateLevel", CURRENT_LEVEL);
// CraftBukkit end // CraftBukkit end
this.b(nbttagcompound); this.b(nbttagcompound);
} catch (Throwable throwable) { } catch (Throwable throwable) {

Datei anzeigen

@ -1087,7 +1087,6 @@ public abstract class EntityLiving extends Entity {
nbttagcompound.setShort("AttackTime", (short) this.attackTicks); nbttagcompound.setShort("AttackTime", (short) this.attackTicks);
nbttagcompound.setBoolean("CanPickUpLoot", this.canPickUpLoot); nbttagcompound.setBoolean("CanPickUpLoot", this.canPickUpLoot);
nbttagcompound.setBoolean("PersistenceRequired", this.persistent); nbttagcompound.setBoolean("PersistenceRequired", this.persistent);
nbttagcompound.setBoolean("Bukkit.PersistenceUpdated", true); // CraftBukkit
NBTTagList nbttaglist = new NBTTagList(); NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.equipment.length; ++i) { for (int i = 0; i < this.equipment.length; ++i) {
@ -1134,13 +1133,15 @@ public abstract class EntityLiving extends Entity {
this.hurtTicks = nbttagcompound.getShort("HurtTime"); this.hurtTicks = nbttagcompound.getShort("HurtTime");
this.deathTicks = nbttagcompound.getShort("DeathTime"); this.deathTicks = nbttagcompound.getShort("DeathTime");
this.attackTicks = nbttagcompound.getShort("AttackTime"); this.attackTicks = nbttagcompound.getShort("AttackTime");
this.canPickUpLoot = nbttagcompound.getBoolean("CanPickUpLoot"); // CraftBukkit start - if looting or persistence is false only use it if it was set after we started using it
// CraftBukkit start - if persistence is false only use it if it was set after we started using it boolean data = nbttagcompound.getBoolean("CanPickUpLoot");
boolean data = nbttagcompound.getBoolean("PersistenceRequired"); if (isLevelAtLeast(nbttagcompound, 1) || data) {
if (nbttagcompound.hasKey("Bukkit.PersistenceUpdated") || data) { this.canPickUpLoot = data;
}
data = nbttagcompound.getBoolean("PersistenceRequired");
if (isLevelAtLeast(nbttagcompound, 1) || data) {
this.persistent = data; this.persistent = data;
} else {
this.persistent = !this.bj();
} }
// CraftBukkit end // CraftBukkit end