Class ExistingFileHelper
java.lang.Object
io.github.vampirestudios.vampirelib.api.datagen.ExistingFileHelper
Enables data providers to check if other data files currently exist. The
instance provided in the utilizes the standard
resources (via
VanillaPackResources), forge's resources, as well as any
extra resource packs passed in via the --existing argument,
or mod resources via the --existing-mod argument.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic class -
Constructor Summary
ConstructorsConstructorDescriptionExistingFileHelper(Collection<Path> existingPacks, Set<String> existingMods, boolean enable, @Nullable String assetIndex, @Nullable File assetsDir) Create a new helper. -
Method Summary
Modifier and TypeMethodDescriptionbooleanexists(net.minecraft.resources.ResourceLocation loc, ExistingFileHelper.IResourceType type) Check if a given resource exists in the known resource packs.booleanexists(net.minecraft.resources.ResourceLocation loc, net.minecraft.server.packs.PackType packType) Check if a given resource exists in the known resource packs.booleanexists(net.minecraft.resources.ResourceLocation loc, net.minecraft.server.packs.PackType packType, String pathSuffix, String pathPrefix) Check if a given resource exists in the known resource packs.net.minecraft.server.packs.resources.ResourcegetResource(net.minecraft.resources.ResourceLocation loc, net.minecraft.server.packs.PackType packType) net.minecraft.server.packs.resources.ResourcegetResource(net.minecraft.resources.ResourceLocation loc, net.minecraft.server.packs.PackType packType, String pathSuffix, String pathPrefix) booleanvoidtrackGenerated(net.minecraft.resources.ResourceLocation loc, ExistingFileHelper.IResourceType type) Track the existence of a generated file.voidtrackGenerated(net.minecraft.resources.ResourceLocation loc, net.minecraft.server.packs.PackType packType, String pathSuffix, String pathPrefix) Track the existence of a generated file.
-
Constructor Details
-
ExistingFileHelper
public ExistingFileHelper(Collection<Path> existingPacks, Set<String> existingMods, boolean enable, @Nullable @Nullable String assetIndex, @Nullable @Nullable File assetsDir) Create a new helper. This should probably NOT be used by mods, as the instance provided by forge is designed to be a central instance that tracks existence of generated data.Only create a new helper if you intentionally want to ignore the existence of other generated files.
- Parameters:
existingPacks- a collection of paths to existing packsexistingMods- a set of mod IDs for existing modsenable-trueif validation is enabledassetIndex- the identifier for the asset index, generally Minecraft's current major versionassetsDir- the directory in which to find vanilla assets and indexes
-
-
Method Details
-
exists
public boolean exists(net.minecraft.resources.ResourceLocation loc, net.minecraft.server.packs.PackType packType) Check if a given resource exists in the known resource packs.- Parameters:
loc- the complete location of the resource, e.g."minecraft:textures/block/stone.png"packType- the type of resources to check- Returns:
trueif the resource exists in any pack,falseotherwise
-
exists
public boolean exists(net.minecraft.resources.ResourceLocation loc, ExistingFileHelper.IResourceType type) Check if a given resource exists in the known resource packs. This is a convenience method to avoid repeating type/prefix/suffix and instead use the common definitions inExistingFileHelper.ResourceType, or a customExistingFileHelper.IResourceTypedefinition.- Parameters:
loc- the base location of the resource, e.g."minecraft:block/stone"type- aExistingFileHelper.IResourceTypedescribing how to form the path to the resource- Returns:
trueif the resource exists in any pack,falseotherwise
-
exists
public boolean exists(net.minecraft.resources.ResourceLocation loc, net.minecraft.server.packs.PackType packType, String pathSuffix, String pathPrefix) Check if a given resource exists in the known resource packs.- Parameters:
loc- the base location of the resource, e.g."minecraft:block/stone"packType- the type of resources to checkpathSuffix- a string to append after the path, e.g.".json"pathPrefix- a string to append before the path, before a slash, e.g."models"- Returns:
trueif the resource exists in any pack,falseotherwise
-
trackGenerated
public void trackGenerated(net.minecraft.resources.ResourceLocation loc, ExistingFileHelper.IResourceType type) Track the existence of a generated file. This is a convenience method to avoid repeating type/prefix/suffix and instead use the common definitions inExistingFileHelper.ResourceType, or a customExistingFileHelper.IResourceTypedefinition.This should be called by data providers immediately when a new data object is created, i.e. not during
runbut instead when the "builder" (or whatever intermediate object) is created.This represents a promise to generate the file later, since other datagen may rely on this file existing.
- Parameters:
loc- the base location of the resource, e.g."minecraft:block/stone"type- aExistingFileHelper.IResourceTypedescribing how to form the path to the resource
-
trackGenerated
public void trackGenerated(net.minecraft.resources.ResourceLocation loc, net.minecraft.server.packs.PackType packType, String pathSuffix, String pathPrefix) Track the existence of a generated file.This should be called by data providers immediately when a new data object is created, i.e. not during
runbut instead when the "builder" (or whatever intermediate object) is created.This represents a promise to generate the file later, since other datagen may rely on this file existing.
- Parameters:
loc- the base location of the resource, e.g."minecraft:block/stone"packType- the type of resources to checkpathSuffix- a string to append after the path, e.g.".json"pathPrefix- a string to append before the path, before a slash, e.g."models"
-
getResource
public net.minecraft.server.packs.resources.Resource getResource(net.minecraft.resources.ResourceLocation loc, net.minecraft.server.packs.PackType packType, String pathSuffix, String pathPrefix) throws IOException - Throws:
IOException
-
getResource
public net.minecraft.server.packs.resources.Resource getResource(net.minecraft.resources.ResourceLocation loc, net.minecraft.server.packs.PackType packType) throws IOException - Throws:
IOException
-
isEnabled
public boolean isEnabled()- Returns:
trueif validation is enabled,falseotherwise
-