public class GameRegistry
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
GameRegistry.ItemStackHolder
ItemStackHolder can be used to automatically populate public static final fields with
ItemStack instances, referring a specific item, potentially configured with NBT. |
static interface |
GameRegistry.ObjectHolder
ObjectHolder can be used to automatically populate public static final fields with entries
from the registry.
|
static class |
GameRegistry.Type |
Constructor and Description |
---|
GameRegistry() |
Modifier and Type | Method and Description |
---|---|
static void |
addRecipe(IRecipe recipe) |
static void |
addRecipe(ItemStack output,
java.lang.Object... params) |
static IRecipe |
addShapedRecipe(ItemStack output,
java.lang.Object... params) |
static void |
addShapelessRecipe(ItemStack output,
java.lang.Object... params) |
static void |
addSmelting(Block input,
ItemStack output,
float xp) |
static void |
addSmelting(Item input,
ItemStack output,
float xp) |
static void |
addSmelting(ItemStack input,
ItemStack output,
float xp) |
static void |
addSubstitutionAlias(java.lang.String nameToSubstitute,
GameRegistry.Type type,
java.lang.Object object)
Add a forced persistent substitution alias for the block or item to another block or item.
|
static <K extends IForgeRegistryEntry<K>> |
findRegistry(java.lang.Class<K> registryType)
Retrieves the registry associated with this super class type.
|
static void |
generateWorld(int chunkX,
int chunkZ,
World world,
IChunkGenerator chunkGenerator,
IChunkProvider chunkProvider)
Callback hook for world gen - if your mod wishes to add extra mod related generation to the world
call this
|
static int |
getFuelValue(ItemStack itemStack) |
static ItemStack |
makeItemStack(java.lang.String itemName,
int meta,
int stackSize,
java.lang.String nbtString)
|
static <K extends IForgeRegistryEntry<?>> |
register(K object)
Register the previously named
IForgeRegistry object with the registry system. |
static <K extends IForgeRegistryEntry<?>> |
register(K object,
ResourceLocation name)
Register the unnamed
IForgeRegistry object with the registry system. |
static void |
registerFuelHandler(IFuelHandler handler) |
static void |
registerTileEntity(java.lang.Class<? extends TileEntity> tileEntityClass,
java.lang.String id) |
static void |
registerTileEntityWithAlternatives(java.lang.Class<? extends TileEntity> tileEntityClass,
java.lang.String id,
java.lang.String... alternatives)
Register a tile entity, with alternative TileEntity identifiers.
|
static Block |
registerWithItem(Block block)
Deprecated.
|
static void |
registerWorldGenerator(IWorldGenerator generator,
int modGenerationWeight)
Register a world generator - something that inserts new block types into the world
|
public static void registerWorldGenerator(IWorldGenerator generator, int modGenerationWeight)
generator
- the generatormodGenerationWeight
- a weight to assign to this generator. Heavy weights tend to sink to the bottom of
list of world generators (i.e. they run later)public static void generateWorld(int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
chunkX
- Chunk X coordinatechunkZ
- Chunk Z coordinateworld
- World we're generating intochunkGenerator
- The chunk generatorchunkProvider
- The chunk providerpublic static <K extends IForgeRegistryEntry<?>> K register(K object)
IForgeRegistry
object with the registry system.
Always ensure the object is already named using IForgeRegistryEntry.setRegistryName(ResourceLocation)
or another mechanism.
Note: That DOES NOT create the ItemBlock for you if this is a Block, you should register that item separately.K
- The registry supertypeobject
- The object to register with a registryjava.lang.IllegalArgumentException
- if the object is not yet named (use register(IForgeRegistryEntry, ResourceLocation)
instead)public static <K extends IForgeRegistryEntry<?>> K register(K object, ResourceLocation name)
IForgeRegistry
object with the registry system.
Always make sure you have not previously named the object.
It is advised that you set the object's registry name and use register(IForgeRegistryEntry)
instead.
Note: That DOES NOT create the ItemBlock for you if this is a Block, you should register that item separately.K
- The registry supertypeobject
- The object to registername
- The name to register it withjava.lang.IllegalStateException
- if the object already has an existing name (use register(IForgeRegistryEntry)
instead)@Deprecated public static Block registerWithItem(Block block)
block
- The block to register with a registryjava.lang.IllegalArgumentException
- if the object is not yet namedpublic static <K extends IForgeRegistryEntry<K>> IForgeRegistry<K> findRegistry(java.lang.Class<K> registryType)
registryType
- The base class of items in this registry.public static void addSubstitutionAlias(java.lang.String nameToSubstitute, GameRegistry.Type type, java.lang.Object object) throws ExistingSubstitutionException
nameToSubstitute
- The name to link to (this is the NEW block or item)type
- The type (Block or Item)object
- a NEW instance that is type compatible with the existing instanceExistingSubstitutionException
- if someone else has already registered an alias either from or to one of the namesIncompatibleSubstitutionException
- if the substitution is incompatiblepublic static void addRecipe(@Nonnull ItemStack output, java.lang.Object... params)
public static IRecipe addShapedRecipe(@Nonnull ItemStack output, java.lang.Object... params)
public static void addShapelessRecipe(@Nonnull ItemStack output, java.lang.Object... params)
public static void addRecipe(IRecipe recipe)
public static void addSmelting(@Nonnull ItemStack input, @Nonnull ItemStack output, float xp)
public static void registerTileEntity(java.lang.Class<? extends TileEntity> tileEntityClass, java.lang.String id)
public static void registerTileEntityWithAlternatives(java.lang.Class<? extends TileEntity> tileEntityClass, java.lang.String id, java.lang.String... alternatives)
tileEntityClass
- The tileEntity class to registerid
- The primary ID, this will be the ID that the tileentity saves asalternatives
- A list of alternative IDs that will also map to this class. These will never save, but they will loadpublic static void registerFuelHandler(IFuelHandler handler)
public static int getFuelValue(@Nonnull ItemStack itemStack)
@Nonnull public static ItemStack makeItemStack(java.lang.String itemName, int meta, int stackSize, java.lang.String nbtString)
ItemStack
based on the itemName reference, with supplied meta, stackSize and nbt, if possible
Will return null if the item doesn't exist (because it's not from a loaded mod for example)
Will throw a RuntimeException
if the nbtString is invalid for use in an ItemStack
itemName
- a registry name referencemeta
- the metastackSize
- the stack sizenbtString
- an nbt stack as a string, will be processed by JsonToNBT