Package net.minecraftforge.common.data
Class ExistingFileHelper
- java.lang.Object
-
- net.minecraftforge.common.data.ExistingFileHelper
-
public class ExistingFileHelper extends java.lang.ObjectEnables data providers to check if other data files currently exist. The instance provided in theGatherDataEventutilizes the standard resources (viaVanillaPack), forge's resources, as well as any extra resource packs passed in via the--existingargument, or mod resources via the--existing-modargument.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceExistingFileHelper.IResourceTypestatic classExistingFileHelper.ResourceType
-
Field Summary
Fields Modifier and Type Field Description private SimpleReloadableResourceManagerclientResourcesprivate booleanenableprivate com.google.common.collect.Multimap<ResourcePackType,ResourceLocation>generatedprivate SimpleReloadableResourceManagerserverData
-
Constructor Summary
Constructors Constructor Description ExistingFileHelper(java.util.Collection<java.nio.file.Path> existingPacks, boolean enable)Deprecated.ExistingFileHelper(java.util.Collection<java.nio.file.Path> existingPacks, java.util.Set<java.lang.String> existingMods, boolean enable)Deprecated.ExistingFileHelper(java.util.Collection<java.nio.file.Path> existingPacks, java.util.Set<java.lang.String> existingMods, boolean enable, java.lang.String assetIndex, java.io.File assetsDir)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanexists(ResourceLocation loc, ResourcePackType packType)Check if a given resource exists in the known resource packs.booleanexists(ResourceLocation loc, ResourcePackType packType, java.lang.String pathSuffix, java.lang.String pathPrefix)Check if a given resource exists in the known resource packs.booleanexists(ResourceLocation loc, ExistingFileHelper.IResourceType type)Check if a given resource exists in the known resource packs.private ResourceLocationgetLocation(ResourceLocation base, java.lang.String suffix, java.lang.String prefix)private IResourceManagergetManager(ResourcePackType packType)IResourcegetResource(ResourceLocation loc, ResourcePackType packType)IResourcegetResource(ResourceLocation loc, ResourcePackType packType, java.lang.String pathSuffix, java.lang.String pathPrefix)booleanisEnabled()voidtrackGenerated(ResourceLocation loc, ResourcePackType packType, java.lang.String pathSuffix, java.lang.String pathPrefix)Track the existence of a generated file.voidtrackGenerated(ResourceLocation loc, ExistingFileHelper.IResourceType type)Track the existence of a generated file.
-
-
-
Field Detail
-
clientResources
private final SimpleReloadableResourceManager clientResources
-
serverData
private final SimpleReloadableResourceManager serverData
-
enable
private final boolean enable
-
generated
private final com.google.common.collect.Multimap<ResourcePackType,ResourceLocation> generated
-
-
Constructor Detail
-
ExistingFileHelper
@Deprecated public ExistingFileHelper(java.util.Collection<java.nio.file.Path> existingPacks, boolean enable)Deprecated.
-
ExistingFileHelper
@Deprecated public ExistingFileHelper(java.util.Collection<java.nio.file.Path> existingPacks, java.util.Set<java.lang.String> existingMods, boolean enable)Deprecated.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-existingMods-enable-
-
ExistingFileHelper
public ExistingFileHelper(java.util.Collection<java.nio.file.Path> existingPacks, java.util.Set<java.lang.String> existingMods, boolean enable, @Nullable java.lang.String assetIndex, @Nullable java.io.File assetsDir)
-
-
Method Detail
-
getManager
private IResourceManager getManager(ResourcePackType packType)
-
getLocation
private ResourceLocation getLocation(ResourceLocation base, java.lang.String suffix, java.lang.String prefix)
-
exists
public boolean exists(ResourceLocation loc, ResourcePackType 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(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(ResourceLocation loc, ResourcePackType packType, java.lang.String pathSuffix, java.lang.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(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
actbut 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.
- 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(ResourceLocation loc, ResourcePackType packType, java.lang.String pathSuffix, java.lang.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
actbut 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.
- 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 IResource getResource(ResourceLocation loc, ResourcePackType packType, java.lang.String pathSuffix, java.lang.String pathPrefix) throws java.io.IOException
- Throws:
java.io.IOException
-
getResource
public IResource getResource(ResourceLocation loc, ResourcePackType packType) throws java.io.IOException
- Throws:
java.io.IOException
-
isEnabled
public boolean isEnabled()
- Returns:
trueif validation is enabled,falseotherwise
-
-