类 ExistingFileHelper
java.lang.Object
net.minecraftforge.common.data.ExistingFileHelper
Enables data providers to check if other data files currently exist. The
instance provided in the
GatherDataEvent
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.-
嵌套类概要
嵌套类修饰符和类型类说明static interface
static class
-
字段概要
字段修饰符和类型字段说明private final MultiPackResourceManager
private final boolean
private final com.google.common.collect.Multimap
<PackType, ResourceLocation> private final MultiPackResourceManager
-
构造器概要
构造器构造器说明ExistingFileHelper
(Collection<Path> existingPacks, Set<String> existingMods, boolean enable, @Nullable String assetIndex, @Nullable File assetsDir) Create a new helper. -
方法概要
修饰符和类型方法说明boolean
exists
(ResourceLocation loc, PackType packType) Check if a given resource exists in the known resource packs.boolean
exists
(ResourceLocation loc, PackType packType, String pathSuffix, String pathPrefix) Check if a given resource exists in the known resource packs.boolean
Check if a given resource exists in the known resource packs.private ResourceLocation
getLocation
(ResourceLocation base, String suffix, String prefix) private ResourceManager
getManager
(PackType packType) getResource
(ResourceLocation loc, PackType packType) getResource
(ResourceLocation loc, PackType packType, String pathSuffix, String pathPrefix) getResourceStack
(ResourceLocation loc, PackType packType) boolean
void
trackGenerated
(ResourceLocation loc, PackType packType, String pathSuffix, String pathPrefix) Track the existence of a generated file.void
Track the existence of a generated file.
-
字段详细资料
-
clientResources
-
serverData
-
enable
private final boolean enable -
generated
-
-
构造器详细资料
-
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.
- 参数:
existingPacks
- a collection of paths to existing packsexistingMods
- a set of mod IDs for existing modsenable
-true
if 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
-
-
方法详细资料
-
getManager
-
getLocation
-
exists
Check if a given resource exists in the known resource packs.- 参数:
loc
- the complete location of the resource, e.g."minecraft:textures/block/stone.png"
packType
- the type of resources to check- 返回:
true
if the resource exists in any pack,false
otherwise
-
exists
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.IResourceType
definition.- 参数:
loc
- the base location of the resource, e.g."minecraft:block/stone"
type
- aExistingFileHelper.IResourceType
describing how to form the path to the resource- 返回:
true
if the resource exists in any pack,false
otherwise
-
exists
public boolean exists(ResourceLocation loc, PackType packType, String pathSuffix, String pathPrefix) Check if a given resource exists in the known resource packs.- 参数:
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"
- 返回:
true
if the resource exists in any pack,false
otherwise
-
trackGenerated
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.IResourceType
definition.This should be called by data providers immediately when a new data object is created, i.e. not during
run
but instead when the "builder" (or whatever intermediate object) is created, such as aModelBuilder
.This represents a promise to generate the file later, since other datagen may rely on this file existing.
- 参数:
loc
- the base location of the resource, e.g."minecraft:block/stone"
type
- aExistingFileHelper.IResourceType
describing how to form the path to the resource
-
trackGenerated
public void trackGenerated(ResourceLocation loc, 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
run
but instead when the "builder" (or whatever intermediate object) is created, such as aModelBuilder
.This represents a promise to generate the file later, since other datagen may rely on this file existing.
- 参数:
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
@VisibleForTesting public Resource getResource(ResourceLocation loc, PackType packType, String pathSuffix, String pathPrefix) throws FileNotFoundException -
getResource
@VisibleForTesting public Resource getResource(ResourceLocation loc, PackType packType) throws FileNotFoundException -
getResourceStack
-
isEnabled
public boolean isEnabled()- 返回:
true
if validation is enabled,false
otherwise
-