Replace version constants with methods to prevent compiler inlining

This commit is contained in:
md_5 2018-12-30 16:00:31 +11:00
parent a5b9c7b3ee
commit 5be2ddcbd5
4 changed files with 9 additions and 6 deletions

View File

@ -40,7 +40,7 @@
+
+ NBTTagCompound savedStack = new NBTTagCompound();
+ this.save(savedStack);
+ savedStack = (NBTTagCompound) MinecraftServer.getServer().dataConverterManager.update(DataConverterTypes.ITEM_STACK, new Dynamic(DynamicOpsNBT.a, savedStack), -1, CraftMagicNumbers.DATA_VERSION).getValue();
+ savedStack = (NBTTagCompound) MinecraftServer.getServer().dataConverterManager.update(DataConverterTypes.ITEM_STACK, new Dynamic(DynamicOpsNBT.a, savedStack), -1, CraftMagicNumbers.INSTANCE.getDataVersion()).getValue();
+ this.load(savedStack);
+ }
+ }

View File

@ -24,7 +24,7 @@
nbttagcompound2.setBoolean("Snapshot", false);
nbttagcompound.set("Version", nbttagcompound2);
nbttagcompound.setInt("DataVersion", 1631);
+ if (org.bukkit.craftbukkit.util.CraftMagicNumbers.DATA_VERSION != 1631) throw new AssertionError(); // CraftBukkit - sentinel
+ if (org.bukkit.craftbukkit.util.CraftMagicNumbers.INSTANCE.getDataVersion() != 1631) throw new AssertionError(); // CraftBukkit - sentinel
nbttagcompound.setLong("RandomSeed", this.e);
nbttagcompound.setString("generatorName", this.f.b());
nbttagcompound.setInt("generatorVersion", this.f.getVersion());

View File

@ -400,7 +400,7 @@ public class CraftLegacy {
stack.setInt("id", material.getId());
stack.setShort("Damage", data);
Dynamic<NBTBase> converted = DataConverterRegistry.a().update(DataConverterTypes.ITEM_STACK, new Dynamic<NBTBase>(DynamicOpsNBT.a, stack), -1, CraftMagicNumbers.DATA_VERSION);
Dynamic<NBTBase> converted = DataConverterRegistry.a().update(DataConverterTypes.ITEM_STACK, new Dynamic<NBTBase>(DynamicOpsNBT.a, stack), -1, CraftMagicNumbers.INSTANCE.getDataVersion());
String newId = converted.getString("id");
// Recover spawn eggs with invalid data

View File

@ -144,7 +144,6 @@ public final class CraftMagicNumbers implements UnsafeValues {
return CraftBlockData.fromData(getBlock(material, data));
}
public static final int DATA_VERSION = 1631;
/**
* This string should be changed if the NMS mappings do.
*
@ -157,12 +156,16 @@ public final class CraftMagicNumbers implements UnsafeValues {
* thing as many common NMS usages. If not, you are encouraged to open a
* feature and/or pull request for consideration, or use a well abstracted
* third-party API such as ProtocolLib.
*
* @return string
*/
public static final String MAPPINGS_VERSION = "00ed8e5c39debc3ed194ad7c5645cc45";
public String getMappingsVersion() {
return "00ed8e5c39debc3ed194ad7c5645cc45";
}
@Override
public int getDataVersion() {
return DATA_VERSION;
return 1631;
}
@Override