public interface GameRegistry
Game
.
Note that the registries may be in flux, especially during game initialization. These will be accurate for the time they are called, however they may change at a later point. Do not assume that the contents of a collection will be all the entries that will exist.
Some of the returned instances my become incorrect if they are later
overwritten. However, this should occur prior to
GameState.POST_INITIALIZATION
.
Modifier and Type | Method and Description |
---|---|
<T extends ResettableBuilder<?,? super T>> |
createBuilder(Class<T> builderClass)
Gets a builder of the desired class type, examples may include:
ItemStack.Builder , etc. |
<T extends CatalogType> |
getAllFor(String pluginId,
Class<T> typeClass)
Gets a collection of all available found specific types of
CatalogType requested. |
default <T extends CatalogType> |
getAllForMinecraft(Class<T> typeClass)
Gets all
CatalogType for Minecraft as a base mod. |
default <T extends CatalogType> |
getAllForSponge(Class<T> typeClass)
Gets all
CatalogType for Sponge as a base mod. |
<T extends CatalogType> |
getAllOf(Class<T> typeClass)
Gets a collection of all available found specific types of
CatalogType requested. |
Optional<BlockStatistic> |
getBlockStatistic(StatisticType statType,
BlockType blockType)
|
CraftingRecipeRegistry |
getCraftingRecipeRegistry()
Retrieves the crafting RecipeRegistry for this GameRegistry.
|
Collection<String> |
getDefaultGameRules()
Gets a
Collection of the default GameRules. |
Optional<DisplaySlot> |
getDisplaySlotForColor(TextColor color)
Gets a
DisplaySlot which displays only for teams with the
provided color. |
Optional<EntityStatistic> |
getEntityStatistic(StatisticType statType,
EntityType entityType)
|
ExtentBufferFactory |
getExtentBufferFactory()
Gets the
ExtentBufferFactory for creating buffers
to store extent data. |
Optional<ItemStatistic> |
getItemStatistic(StatisticType statType,
ItemType itemType)
|
Locale |
getLocale(String locale)
Gets a locale for the specified locale code, e.g.
|
Optional<ResourcePack> |
getResourcePackById(String id)
Gets a
ResourcePack that's already been created by its ID. |
Optional<Rotation> |
getRotationFromDegree(int degrees)
Gets the
Rotation with the provided degrees. |
SelectorFactory |
getSelectorFactory()
Deprecated.
Use the appropriate class in the selector package instead
|
SmeltingRecipeRegistry |
getSmeltingRecipeRegistry()
Retrieves the smelting RecipeRegistry for this GameRegistry.
|
TextSerializerFactory |
getTextSerializerFactory()
Deprecated.
Use
TextSerializers instead |
Optional<Translation> |
getTranslationById(String id)
Gets the
Translation with the provided ID. |
<T extends CatalogType> |
getType(Class<T> typeClass,
String id)
Attempts to retrieve the specific type of
CatalogType based on
the string id given. |
ValueFactory |
getValueFactory()
Gets the
ValueFactory for creating values. |
VillagerRegistry |
getVillagerRegistry()
Gets the
VillagerRegistry for the register mappings of
Career s to TradeOfferGenerator s based on a level. |
Favicon |
loadFavicon(BufferedImage image)
Loads a favicon from a specified
BufferedImage . |
Favicon |
loadFavicon(InputStream in)
Loads a favicon from a specified
InputStream . |
Favicon |
loadFavicon(Path path)
Loads a favicon from a specified
Path . |
Favicon |
loadFavicon(String raw)
Loads a
Favicon from the specified encoded string. |
Favicon |
loadFavicon(URL url)
Loads a favicon from a specified
URL . |
<T extends CatalogType> |
register(Class<T> type,
T obj)
Deprecated.
Is scheduled to be removed in API 8, the
GameRegistryEvent.Register
should be used instead |
AITaskType |
registerAITaskType(Object plugin,
String id,
String name,
Class<? extends AbstractAITask<? extends Agent>> aiClass)
Registers a new
AbstractAITask with an Agent as the
owner. |
<T> GameRegistry |
registerBuilderSupplier(Class<T> builderClass,
Supplier<? extends T> supplier)
Registers a
Supplier for creating the desired ResettableBuilder . |
<T extends CatalogType> |
registerModule(Class<T> catalogClass,
CatalogRegistryModule<T> registryModule)
Registers the
CatalogRegistryModule for dummy registration and
handling. |
GameRegistry |
registerModule(RegistryModule module)
Registers the desired
RegistryModule . |
<T extends CatalogType> Optional<T> getType(Class<T> typeClass, String id)
CatalogType
based on
the string id given.
Some types may not be available for various reasons including but not restricted to: mods adding custom types, plugins providing custom types, game version changes.
T
- The type of dummy typetypeClass
- The class of the type of CatalogType
id
- The case insensitive string id of the dummy typeCatalogType
<T extends CatalogType> Collection<T> getAllOf(Class<T> typeClass)
CatalogType
requested.
The presented CatalogType
s may not exist in default catalogs
due to various reasons including but not restricted to: mods, plugins,
game changes.
T
- The type of CatalogType
typeClass
- The class of CatalogType
<T extends CatalogType> Collection<T> getAllFor(String pluginId, Class<T> typeClass)
CatalogType
requested.T
- The type of CatalogType
pluginId
- The plugin id to check for typestypeClass
- The class of CatalogType
default <T extends CatalogType> Collection<T> getAllForMinecraft(Class<T> typeClass)
CatalogType
for Minecraft as a base mod. Note that
some CatalogType
s are not originally from the game itself, and
may be provided by Sponge.T
- The type of catalog typetypeClass
- The type of catalog typedefault <T extends CatalogType> Collection<T> getAllForSponge(Class<T> typeClass)
CatalogType
for Sponge as a base mod. Note that
some CatalogType
s are not originally from the game itself, and
may be provided by Sponge.T
- The type of catalog typetypeClass
- The type of catalog type<T extends CatalogType> GameRegistry registerModule(Class<T> catalogClass, CatalogRegistryModule<T> registryModule) throws IllegalArgumentException, RegistryModuleAlreadyRegisteredException
CatalogRegistryModule
for dummy registration and
handling.
By default, the only supported modules that can be registered are
dependent that plugins are not attempting to register new modules for
API-provided CatalogType
s.
T
- The type of dummycatalogClass
- The dummy class itselfregistryModule
- The registry moduleIllegalArgumentException
- If there is a module already registeredRegistryModuleAlreadyRegisteredException
- If the registry module
is already registeredUnsupportedOperationException
- If an attempt is made to register
a module for an API catalogGameRegistry registerModule(RegistryModule module) throws RegistryModuleAlreadyRegisteredException
RegistryModule
.module
- The module to registerRegistryModuleAlreadyRegisteredException
- if the specified
registry module is already registered<T> GameRegistry registerBuilderSupplier(Class<T> builderClass, Supplier<? extends T> supplier)
Supplier
for creating the desired ResettableBuilder
.T
- The type of builder/supplierbuilderClass
- The builder classsupplier
- The supplier<T extends ResettableBuilder<?,? super T>> T createBuilder(Class<T> builderClass) throws IllegalArgumentException
ItemStack.Builder
, etc.T
- The type of builderbuilderClass
- The class of the builderIllegalArgumentException
- If there is no supplier for the given
builder class@Deprecated <T extends CatalogType> T register(Class<T> type, T obj) throws IllegalArgumentException, CatalogTypeAlreadyRegisteredException
GameRegistryEvent.Register
should be used insteadCatalogType
instance if registration for that
type is supported.
Note that this is intended only for registering new instances of already existing CatalogTypes, not for registering entirely new CatalogType classes.
T
- dummy object typetype
- The CatalogType classobj
- The dummy type instanceIllegalArgumentException
- If there is an id conflict with the
given type and an existing typeUnsupportedOperationException
- If registration for the given type
is not supportedCatalogTypeAlreadyRegisteredException
- if the type cannot be
registered because a matching type was already registeredCollection<String> getDefaultGameRules()
Collection
of the default GameRules.Optional<EntityStatistic> getEntityStatistic(StatisticType statType, EntityType entityType)
Statistic
for the given StatisticType
and
EntityType
. If the statistic group is not a valid
EntityStatistic
group then Optional.empty()
will be
returned.statType
- The type of statistic to returnentityType
- The entity type for the statistic to returnOptional<ItemStatistic> getItemStatistic(StatisticType statType, ItemType itemType)
Statistic
for the given StatisticType
and
ItemType
. If the statistic group is not a valid
ItemStatistic
group then Optional.empty()
will be
returned.statType
- The type of statistic to returnitemType
- The item type for the statistic to returnOptional<BlockStatistic> getBlockStatistic(StatisticType statType, BlockType blockType)
Statistic
for the given StatisticType
and
BlockType
. If the statistic group is not a valid
BlockStatistic
group then Optional.empty()
will be
returned.statType
- The type of statistic to returnblockType
- The block type for the statistic to returnOptional<Rotation> getRotationFromDegree(int degrees)
Rotation
with the provided degrees.degrees
- The degrees of the rotationRotation
with the given degrees or
Optional.empty() if not foundFavicon loadFavicon(String raw) throws IOException
Favicon
from the specified encoded string. The format of
the input depends on the implementation.raw
- The encoded faviconIOException
- If the favicon couldn't be loadedFavicon loadFavicon(Path path) throws IOException
Path
.path
- The path to the faviconIOException
- If the favicon couldn't be loadedFileNotFoundException
- If the file doesn't existFavicon loadFavicon(URL url) throws IOException
URL
.url
- The favicon URLIOException
- If the favicon couldn't be loadedFavicon loadFavicon(InputStream in) throws IOException
InputStream
.in
- The favicon input streamIOException
- If the favicon couldn't be loadedFavicon loadFavicon(BufferedImage image) throws IOException
BufferedImage
.image
- The favicon imageIOException
- If the favicon couldn't be loadedCraftingRecipeRegistry getCraftingRecipeRegistry()
SmeltingRecipeRegistry getSmeltingRecipeRegistry()
Optional<ResourcePack> getResourcePackById(String id)
ResourcePack
that's already been created by its ID.id
- The ID of the packOptional<DisplaySlot> getDisplaySlotForColor(TextColor color)
DisplaySlot
which displays only for teams with the
provided color.color
- The color for the display slotDisplaySlot
with the provided color, or
Optional.empty() if not foundAITaskType registerAITaskType(Object plugin, String id, String name, Class<? extends AbstractAITask<? extends Agent>> aiClass)
AbstractAITask
with an Agent
as the
owner. The complete id will be in the format of
PluginContainer.getId()
:id
.plugin
- The plugin who owns itid
- The id that represents the task typename
- The name for the taskaiClass
- The class of the taskExtentBufferFactory getExtentBufferFactory()
ExtentBufferFactory
for creating buffers
to store extent data.ValueFactory getValueFactory()
ValueFactory
for creating values.VillagerRegistry getVillagerRegistry()
VillagerRegistry
for the register mappings of
Career
s to TradeOfferGenerator
s based on a level.@Deprecated TextSerializerFactory getTextSerializerFactory()
TextSerializers
insteadTextSerializerFactory
.@Deprecated SelectorFactory getSelectorFactory()
SelectorFactory
.Locale getLocale(String locale)
en_US
.locale
- The locale to lookup (e.g. en_US
).Optional<Translation> getTranslationById(String id)
Translation
with the provided ID.id
- The ID of the translationTranslation
with the given ID or Optional.empty() if
not found