Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 04:20:08 +01:00
SPIGOT-4028: Improve legacy ItemStack conversion
Dieser Commit ist enthalten in:
Ursprung
de019a35f0
Commit
f18d78282d
@ -30,7 +30,7 @@
|
||||
+ if (MinecraftServer.getServer() != null) {
|
||||
+ NBTTagCompound savedStack = new NBTTagCompound();
|
||||
+ this.save(savedStack);
|
||||
+ MinecraftServer.getServer().dataConverterManager.update(DataConverterTypes.ITEM_STACK, new Dynamic(DynamicOpsNBT.a, savedStack), -1, CraftMagicNumbers.DATA_VERSION);
|
||||
+ // MinecraftServer.getServer().dataConverterManager.update(DataConverterTypes.ITEM_STACK, new Dynamic(DynamicOpsNBT.a, savedStack), -1, CraftMagicNumbers.DATA_VERSION); // This changed late in development and hasn't been doing anything. Needs to be fixed.
|
||||
+ this.load(savedStack);
|
||||
+ }
|
||||
+ }
|
||||
|
@ -63,7 +63,7 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta {
|
||||
|
||||
if (tag.hasKey(ENTITY_TAG.NBT)) {
|
||||
entityTag = tag.getCompound(ENTITY_TAG.NBT);
|
||||
MinecraftServer.getServer().dataConverterManager.update(DataConverterTypes.ENTITY, new Dynamic(DynamicOpsNBT.a, entityTag), -1, CraftMagicNumbers.DATA_VERSION);
|
||||
entityTag = (NBTTagCompound) MinecraftServer.getServer().dataConverterManager.update(DataConverterTypes.ENTITY, new Dynamic(DynamicOpsNBT.a, entityTag), -1, CraftMagicNumbers.DATA_VERSION).getValue();
|
||||
|
||||
if (entityTag.hasKey(ENTITY_ID.NBT)) {
|
||||
this.spawnedType = EntityType.fromName(new MinecraftKey(entityTag.getString(ENTITY_ID.NBT)).getKey());
|
||||
|
@ -40,7 +40,7 @@ import org.bukkit.material.MaterialData;
|
||||
@Deprecated
|
||||
public class CraftLegacy {
|
||||
|
||||
private static final Map<EntityType, Material> SPAWN_EGGS = new HashMap<>();
|
||||
private static final Map<Byte, Material> SPAWN_EGGS = new HashMap<>();
|
||||
private static final Set<String> whitelistedStates = new HashSet<>(Arrays.asList("explode", "check_decay", "decayable"));
|
||||
private static final Map<MaterialData, Item> materialToItem = new HashMap<>();
|
||||
private static final Map<Item, MaterialData> itemToMaterial = new HashMap<>();
|
||||
@ -231,34 +231,36 @@ public class CraftLegacy {
|
||||
}
|
||||
|
||||
static {
|
||||
SPAWN_EGGS.put(EntityType.BAT, Material.BAT_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.BLAZE, Material.BLAZE_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.CAVE_SPIDER, Material.CAVE_SPIDER_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.CHICKEN, Material.CHICKEN_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.COW, Material.COW_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.CREEPER, Material.CREEPER_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.ENDERMAN, Material.ENDERMAN_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.ENDERMITE, Material.ENDERMITE_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.GHAST, Material.GHAST_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.GUARDIAN, Material.GUARDIAN_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.HORSE, Material.HORSE_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.MAGMA_CUBE, Material.MAGMA_CUBE_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.MUSHROOM_COW, Material.MOOSHROOM_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.OCELOT, Material.OCELOT_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.PIG, Material.PIG_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.RABBIT, Material.RABBIT_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.SHEEP, Material.SHEEP_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.SHULKER, Material.SHULKER_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.SILVERFISH, Material.SILVERFISH_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.SKELETON, Material.SKELETON_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.SLIME, Material.SLIME_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.SPIDER, Material.SPIDER_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.SQUID, Material.SQUID_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.VILLAGER, Material.VILLAGER_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.WITCH, Material.WITCH_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.WOLF, Material.WOLF_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.PIG_ZOMBIE, Material.ZOMBIE_PIGMAN_SPAWN_EGG);
|
||||
SPAWN_EGGS.put(EntityType.ZOMBIE, Material.ZOMBIE_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) 0, Material.PIG_SPAWN_EGG); // Will be fixed by updateMaterial if possible
|
||||
|
||||
SPAWN_EGGS.put((byte) EntityType.BAT.getTypeId(), Material.BAT_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.BLAZE.getTypeId(), Material.BLAZE_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.CAVE_SPIDER.getTypeId(), Material.CAVE_SPIDER_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.CHICKEN.getTypeId(), Material.CHICKEN_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.COW.getTypeId(), Material.COW_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.CREEPER.getTypeId(), Material.CREEPER_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.ENDERMAN.getTypeId(), Material.ENDERMAN_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.ENDERMITE.getTypeId(), Material.ENDERMITE_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.GHAST.getTypeId(), Material.GHAST_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.GUARDIAN.getTypeId(), Material.GUARDIAN_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.HORSE.getTypeId(), Material.HORSE_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.MAGMA_CUBE.getTypeId(), Material.MAGMA_CUBE_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.MUSHROOM_COW.getTypeId(), Material.MOOSHROOM_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.OCELOT.getTypeId(), Material.OCELOT_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.PIG.getTypeId(), Material.PIG_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.RABBIT.getTypeId(), Material.RABBIT_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.SHEEP.getTypeId(), Material.SHEEP_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.SHULKER.getTypeId(), Material.SHULKER_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.SILVERFISH.getTypeId(), Material.SILVERFISH_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.SKELETON.getTypeId(), Material.SKELETON_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.SLIME.getTypeId(), Material.SLIME_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.SPIDER.getTypeId(), Material.SPIDER_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.SQUID.getTypeId(), Material.SQUID_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.VILLAGER.getTypeId(), Material.VILLAGER_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.WITCH.getTypeId(), Material.WITCH_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.WOLF.getTypeId(), Material.WOLF_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.PIG_ZOMBIE.getTypeId(), Material.ZOMBIE_PIGMAN_SPAWN_EGG);
|
||||
SPAWN_EGGS.put((byte) EntityType.ZOMBIE.getTypeId(), Material.ZOMBIE_SPAWN_EGG);
|
||||
|
||||
DispenserRegistry.c();
|
||||
|
||||
@ -363,8 +365,8 @@ public class CraftLegacy {
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<EntityType, Material> entry : SPAWN_EGGS.entrySet()) {
|
||||
MaterialData matData = new MaterialData(Material.LEGACY_MONSTER_EGG, (byte) entry.getKey().getTypeId());
|
||||
for (Map.Entry<Byte, Material> entry : SPAWN_EGGS.entrySet()) {
|
||||
MaterialData matData = new MaterialData(Material.LEGACY_MONSTER_EGG, entry.getKey());
|
||||
Item newMaterial = CraftMagicNumbers.getItem(entry.getValue());
|
||||
|
||||
materialToItem.put(matData, newMaterial);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren