use of net.minecraft.server.v1_16_R1.MinecraftKey in project SilkSpawners by timbru31.
the class NMSHandler method getVanillaEggNBTEntityID.
@Override
public String getVanillaEggNBTEntityID(final ItemStack item) {
net.minecraft.server.v1_16_R3.ItemStack itemStack = null;
final CraftItemStack craftStack = CraftItemStack.asCraftCopy(item);
itemStack = CraftItemStack.asNMSCopy(craftStack);
NBTTagCompound tag = itemStack.getTag();
if (tag == null || !tag.hasKey("EntityTag")) {
final MinecraftKey vanillaKey = IRegistry.ITEM.getKey(itemStack.getItem());
if (vanillaKey != null) {
return vanillaKey.getKey().replace("minecraft:", "").replace("_spawn_egg", "");
}
} else {
tag = tag.getCompound("EntityTag");
if (tag.hasKey("id")) {
return tag.getString("id").replace("minecraft:", "");
}
}
return null;
}
use of net.minecraft.server.v1_16_R1.MinecraftKey in project PaperDev by Kamillaova.
the class CraftMetaSpawnEgg method deserializeInternal.
@Override
void deserializeInternal(NBTTagCompound tag) {
super.deserializeInternal(tag);
if (tag.hasKey(ENTITY_TAG.NBT)) {
entityTag = tag.getCompound(ENTITY_TAG.NBT);
// PAIL: convert
MinecraftServer.getServer().dataConverterManager.a(DataConverterTypes.ENTITY, entityTag);
if (entityTag.hasKey(ENTITY_ID.NBT)) {
this.spawnedType = EntityType.fromName(new MinecraftKey(entityTag.getString(ENTITY_ID.NBT)).getKey());
}
}
}
use of net.minecraft.server.v1_16_R1.MinecraftKey in project PaperDev by Kamillaova.
the class CraftStatistic method getMaterialFromStatistic.
public static Material getMaterialFromStatistic(net.minecraft.server.v1_12_R1.Statistic statistic) {
String statisticString = statistic.name;
String val = statisticString.substring(statisticString.lastIndexOf(".") + 1);
Item item = (Item) Item.REGISTRY.get(new MinecraftKey(val));
if (item != null) {
return Material.getMaterial(Item.getId(item));
}
Block block = (Block) Block.REGISTRY.get(new MinecraftKey(val));
if (block != null) {
return Material.getMaterial(Block.getId(block));
}
try {
return Material.getMaterial(Integer.parseInt(val));
} catch (NumberFormatException e) {
return null;
}
}
Aggregations