类net.minecraft.util.datafix.FixTypes源码实例Demo

下面列出了怎么用net.minecraft.util.datafix.FixTypes的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: GregTech   文件: TemplateManager.java
public static Template getBuiltinTemplate(World world, ResourceLocation templateId) {
    if (templateMap.containsKey(templateId)) {
        return templateMap.get(templateId);
    }
    Template template = new Template();
    String resourcePath = "/assets/" + templateId.getResourceDomain() + "/structures/" + templateId.getResourcePath() + ".nbt";
    InputStream inputStream = TemplateManager.class.getResourceAsStream(resourcePath);
    if (inputStream != null) {
        try {
            NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(inputStream);
            if (!nbttagcompound.hasKey("DataVersion", 99)) {
                nbttagcompound.setInteger("DataVersion", 500);
            }
            DataFixer dataFixer = world.getMinecraftServer().getDataFixer();
            template.read(dataFixer.process(FixTypes.STRUCTURE, nbttagcompound));
        } catch (IOException exception) {
            GTLog.logger.error("Failed to load builtin template {}", templateId, exception);
        } finally {
            IOUtils.closeQuietly(inputStream);
        }
    } else {
        GTLog.logger.warn("Failed to find builtin structure with path {}", resourcePath);
    }
    templateMap.put(templateId, template);
    return template;
}
 
源代码2 项目: Kettle   文件: CraftMetaSpawnEgg.java
@Override
void deserializeInternal(NBTTagCompound tag) {
    super.deserializeInternal(tag);

    if (tag.hasKey(ENTITY_TAG.NBT)) {
        entityTag = tag.getCompoundTag(ENTITY_TAG.NBT);
        MinecraftServer.getServerCB().getDataFixer().process(FixTypes.ENTITY, entityTag); // PAIL: convert TODO: identify DataConverterTypes after implementation

        if (entityTag.hasKey(ENTITY_ID.NBT)) {
            this.spawnedType = EntityType.fromName(new ResourceLocation(entityTag.getString(ENTITY_ID.NBT)).getResourcePath());
        }
    }
}
 
源代码3 项目: enderutilities   文件: EnderUtilities.java
@Mod.EventHandler
public void onServerAboutToStartEvent(FMLServerAboutToStartEvent event)
{
    // Register data fixers
    ModFixs dataFixer = proxy.getDataFixer();
    TileEntityID renames = new TileEntityID();
    dataFixer.registerFix(FixTypes.BLOCK_ENTITY, renames);
    dataFixer.registerFix(FixTypes.ITEM_INSTANCE, renames);
}
 
源代码4 项目: enderutilities   文件: TemplateManagerEU.java
private void readTemplateFromStream(String id, InputStream stream) throws IOException
{
    NBTTagCompound nbt = CompressedStreamTools.readCompressed(stream);

    if (nbt.hasKey("DataVersion", Constants.NBT.TAG_ANY_NUMERIC) == false)
    {
        nbt.setInteger("DataVersion", 500);
    }

    TemplateEnderUtilities template = new TemplateEnderUtilities();
    template.read(this.fixer.process(FixTypes.STRUCTURE, nbt));
    this.templates.put(id, template);
}
 
源代码5 项目: OpenModsLib   文件: EntityBlock.java
public static void registerFixes(DataFixer fixers, final Class<? extends EntityBlock> cls) {
	fixers.registerWalker(FixTypes.ENTITY, (fixer, compound, versionIn) -> {
		if (EntityList.getKey(cls).equals(new ResourceLocation(compound.getString("id")))) {
			if (compound.hasKey(TAG_TILE_ENTITY, Constants.NBT.TAG_COMPOUND)) {
				final NBTTagCompound teTag = compound.getCompoundTag(TAG_TILE_ENTITY);
				final NBTTagCompound fixedTeTag = fixer.process(FixTypes.BLOCK_ENTITY, teTag, versionIn);
				compound.setTag(TAG_TILE_ENTITY, fixedTeTag);
			}
		}

		return compound;
	});
}
 
源代码6 项目: TofuCraftReload   文件: TileEntitySaltFurnace.java
public static void registerFixesFurnace(DataFixer fixer) {
    fixer.registerWalker(FixTypes.BLOCK_ENTITY, new ItemStackDataLists(TileEntitySaltFurnace.class, new String[]{"Items"}));
}
 
源代码7 项目: ToroQuest   文件: EntityVillageLord.java
public static void registerFixesVillageLord(DataFixer fixer) {
	EntityLiving.registerFixesMob(fixer, EntityVillageLord.class);
	fixer.registerWalker(FixTypes.ENTITY, new ItemStackDataLists(EntityVillageLord.class, new String[] { "Items" }));
}
 
源代码8 项目: GokiStats   文件: GokiStats.java
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
    proxy.registerHandlers();
    FMLCommonHandler.instance().getDataFixer().registerVanillaWalker(FixTypes.PLAYER, new StatFix());
}
 
@Override
public void register(DataFixer registry, Class<?> registeringClass) {
	registry.registerWalker(FixTypes.BLOCK_ENTITY, new ItemStackDataLists(registeringClass, GenericInventory.TAG_ITEMS));
}
 
 类所在包
 同包方法