net.minecraft.util.datafix.FixTypes Java Examples

The following examples show how to use net.minecraft.util.datafix.FixTypes. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TemplateManager.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: CraftMetaSpawnEgg.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@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());
        }
    }
}
 
Example #3
Source File: EnderUtilities.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example #4
Source File: TemplateManagerEU.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #5
Source File: EntityBlock.java    From OpenModsLib with MIT License 5 votes vote down vote up
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;
	});
}
 
Example #6
Source File: TileEntitySaltFurnace.java    From TofuCraftReload with MIT License 4 votes vote down vote up
public static void registerFixesFurnace(DataFixer fixer) {
    fixer.registerWalker(FixTypes.BLOCK_ENTITY, new ItemStackDataLists(TileEntitySaltFurnace.class, new String[]{"Items"}));
}
 
Example #7
Source File: EntityVillageLord.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
public static void registerFixesVillageLord(DataFixer fixer) {
	EntityLiving.registerFixesMob(fixer, EntityVillageLord.class);
	fixer.registerWalker(FixTypes.ENTITY, new ItemStackDataLists(EntityVillageLord.class, new String[] { "Items" }));
}
 
Example #8
Source File: GokiStats.java    From GokiStats with MIT License 4 votes vote down vote up
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
    proxy.registerHandlers();
    FMLCommonHandler.instance().getDataFixer().registerVanillaWalker(FixTypes.PLAYER, new StatFix());
}
 
Example #9
Source File: GenericInventoryTeFixerWalker.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void register(DataFixer registry, Class<?> registeringClass) {
	registry.registerWalker(FixTypes.BLOCK_ENTITY, new ItemStackDataLists(registeringClass, GenericInventory.TAG_ITEMS));
}