Package de.ellpeck.rockbottom.api
Interface IGameInstance
- All Superinterfaces:
IMod
The game instance that can be used to interact with various game-related
values and access things like
IRenderer and IAssetManager.
Notice that this instance represents both the server and the client, however
some methods that are not implemented on the dedicated server (like graphics
and rendering methods) will throw an UnsupportedOperationException.
To access any methods from this class, use RockBottomAPI.getGame().-
Method Summary
Modifier and TypeMethodDescriptionvoidchangeWorld(ResourceName subName, DataSet worldData) <T> voidenqueueAction(BiConsumer<IGameInstance, T> action, T object) Enqueues an action to be executed next tick.voidexit()Gets theIAssetManagerof the current game instance.Gets theIChatLogof the current game instance.Gets theURLClassLoaderthat the game is using to load its own classes and classes from jars out of the mods folder.Gets theIDataManagerof the current game instance.Gets the defaultUUIDthat will be applied to the game while there is no logged in account.intGets theIGuiManagerof the current game instance.intGets the current height of the window in pixelsgetInput()Gets theIInputHandlerof the current game instance.Gets theIInteractionManagerof the current game instance.Gets theIParticleManagerof the current game instance.Gets theAbstractPlayerEntityof the current game instance.intGets theIPlayerDesignthat defines what the player looks like.Gets theIWorldthat the player is currently in.Gets theIRenderercontext of the current game instance.Gets an input stream based on a resource available to the game using thegetClassLoader().Gets a url based on a resource available to the game using thegetClassLoader().Gets theSettingsof the current game instance.floatGets theIToasterof the current game instance.intGets the total amount of ticks the game has been running for.intGets theUUIDof the current game instance.intgetWidth()Gets the current width of the window in pixelslongGets theGLFWpointer to the window that is open.getWorld()Gets theIWorldof the current game instance.booleanGets if the game is currently in dedicated server mode.booleanvoidjoinWorld(DataSet playerSet, WorldInfo info, ResourceName subName, DataSet worldData, DynamicRegistryInfo regInfo) voidvoidvoidrestart()voidsetFullscreen(boolean fullscreen) voidsetPlayerDesign(String jsonString) voidstartWorld(File worldFile, WorldInfo info, boolean isNewlyCreated) Methods inherited from interface de.ellpeck.rockbottom.api.mod.IMod
getAuthors, getContentLocation, getDescription, getDisplayName, getId, getModConfig, getModGuiClass, getResourceLocation, getSortingPriority, getVersion, init, initAssets, isCompatibleWithModVersion, isDisableable, isRequiredOnClient, isRequiredOnServer, postInit, postInitAssets, postPostInit, preInit, preInitAssets, prePreInit, receiveMessage
-
Method Details
-
startWorld
-
joinWorld
@ApiInternal void joinWorld(DataSet playerSet, WorldInfo info, ResourceName subName, DataSet worldData, DynamicRegistryInfo regInfo) -
changeWorld
-
quitWorld
-
openIngameMenu
-
enqueueAction
Enqueues an action to be executed next tick. This is done synchronously, meaning that you can call this function from a different thread without causing concurrent modification issues.- Type Parameters:
T- A user-chosen generic typ for the passed additional object- Parameters:
action- The action to be executedobject- An object you can pass for later use in the action consumer- See Also:
-
getDataManager
IDataManager getDataManager()Gets theIDataManagerof the current game instance. This can be used for accessing locations on disk like the save folder or the game folder itself. Additionally, it can saveIJsonSettings.- Returns:
- The data manager
-
restart
-
getSettings
Settings getSettings()Gets theSettingsof the current game instance. These store all of the values that can be edited in the settings gui.- Returns:
- The settings
-
getPlayer
AbstractPlayerEntity getPlayer()Gets theAbstractPlayerEntityof the current game instance. Note that this is not implemented on the dedicated server.- Returns:
- The player
- Throws:
UnsupportedOperationException- on the dedicated server
-
getGuiManager
IGuiManager getGuiManager()Gets theIGuiManagerof the current game instance. This can be used to open Guis and fade the screen in and out. Note that this is not implemented on the dedicated server.- Returns:
- The gui manager
- Throws:
UnsupportedOperationException- on the dedicated server
-
getInteractionManager
IInteractionManager getInteractionManager()Gets theIInteractionManagerof the current game instance. This can be used to access the positions in the world that the player is currently breaking. Note that this is not implemented on the dedicated server.- Returns:
- The interaction manager
- Throws:
UnsupportedOperationException- on the dedicated server
-
getChatLog
IChatLog getChatLog()Gets theIChatLogof the current game instance. This can be used to write messages and commands into the in-game chat.- Returns:
- The chat log
-
getWorld
IWorld getWorld()Gets theIWorldof the current game instance. In the title screen, this value is unassigned.- Returns:
- The world
-
getPlayerWorld
IWorld getPlayerWorld()Gets theIWorldthat the player is currently in. If the player is in the normal world, then this call will be equal togetWorld(). If the player is in a sub world, then this call will return the sub world. Notice that, on the client side, this call will always return the same asgetWorld().- Returns:
- The player's world
-
getAssetManager
IAssetManager getAssetManager()Gets theIAssetManagerof the current game instance. This can be used to get graphics, sounds and various other assets. Note that this is not implemented on the dedicated server.- Returns:
- The asset manager
- Throws:
UnsupportedOperationException- on the dedicated server
-
getRenderer
IRenderer getRenderer()Gets theIRenderercontext of the current game instance. This can be used to draw various shapes and interact with the OpenGL context.- Returns:
- The graphics context
-
getParticleManager
IParticleManager getParticleManager()Gets theIParticleManagerof the current game instance. This can be used to spawn and render particles. Note that this is not implemented on the dedicated server.- Returns:
- The particle manager
- Throws:
UnsupportedOperationException- on the dedicated server
-
getUniqueId
UUID getUniqueId()Gets theUUIDof the current game instance. This will be applied to the player as soon as a world starts. Note that the dedicated server does not have a unique id. In case the current unique id does not exist for one reason or another, thegetDefaultUniqueId()will be returned.- Returns:
- The game's unique id
- Throws:
UnsupportedOperationException- on the dedicated server
-
getDefaultUniqueId
UUID getDefaultUniqueId()Gets the defaultUUIDthat will be applied to the game while there is no logged in account. This is also the UUID that the default player will be saved to disk with.- Returns:
- The default unique id
-
getTpsAverage
-
getFpsAverage
-
getClassLoader
URLClassLoader getClassLoader()Gets theURLClassLoaderthat the game is using to load its own classes and classes from jars out of the mods folder.- Returns:
- The class loader
-
getResourceStream
Gets an input stream based on a resource available to the game using thegetClassLoader(). This is equivalent toClass.getResourceAsStream(String), however it will include all resources loaded by the class loader, even content pack and mod resources.- Parameters:
s- The location- Returns:
- An input stream or null if there is nothing at the specified location
-
getResourceURL
Gets a url based on a resource available to the game using thegetClassLoader(). This is equivalent toClass.getResource(String), however it will include all resources loaded by the class loader, even content pack and mod resources.- Parameters:
s- The location- Returns:
- A url or null if there is nothing at the specified location
-
setFullscreen
-
getTotalTicks
int getTotalTicks()Gets the total amount of ticks the game has been running for. Note that, when closing down the game and opening it back up, this value will be reset.- Returns:
- The total ticks
-
getPlayerDesign
IPlayerDesign getPlayerDesign()Gets theIPlayerDesignthat defines what the player looks like. Note that this is not implemented on the dedicated server.- Returns:
- The player design
- Throws:
UnsupportedOperationException- on the dedicated server
-
setPlayerDesign
-
isDedicatedServer
boolean isDedicatedServer()Gets if the game is currently in dedicated server mode. This will be true when "--server" is appended to the launch arguments.- Returns:
- If the instance is a dedicated server.
-
getInput
IInputHandler getInput()Gets theIInputHandlerof the current game instance. This is a class that allows for the polling of inputs. Note that, when usingKeybind,Keybind.isDown()andKeybind.isPressed()should be used instead. Note that this is not implemented on the dedicated server.- Returns:
- The input manager
- Throws:
UnsupportedOperationException- on the dedicated server
-
exit
-
getToaster
IToaster getToaster()Gets theIToasterof the current game instance. This is the system that displaysBasicToastobjects, which are the little pop-up messages in the top left. Note that this is not implemented on the dedicated server.- Returns:
- The toaster
- Throws:
UnsupportedOperationException- on the dedicated server
-
getWidth
int getWidth()Gets the current width of the window in pixels- Returns:
- The width
- Throws:
UnsupportedOperationException- on the dedicated server- See Also:
-
getHeight
int getHeight()Gets the current height of the window in pixels- Returns:
- The height
- Throws:
UnsupportedOperationException- on the dedicated server- See Also:
-
getWindow
long getWindow()Gets theGLFWpointer to the window that is open.- Returns:
- The window pointer
- Throws:
UnsupportedOperationException- on the dedicated server
-
isRunning
boolean isRunning()- Returns:
- True if the game's update loop should continue. This can be
useful when working with different
Threadinstances that loop.
-
getPlayerCap
-
getTickDelta
float getTickDelta()- Returns:
- The amount of ticks that have passed since the last tick. This will always return 0 when called from an update loop, but can return values between 0 and 1 when called from a rendering loop, as there are more FPS than TPS.
-