Skip to content

Helpful Methods

Matryoshika edited this page May 30, 2018 · 3 revisions

Helpful Methods

Available in the class matryoshika.scripter.HelperMethods are a handful of useful static methods to help you with scripting.

getTimer() returns an integer representing the ticks a server has been online. Useful for functions that needs to check against a timer. While it is highly improbable, the timer will revert back to 0 if it goes over Integer.MAX_VALUE.

executeCommand(ICommandSender, String) will execute a command as if the ICommandSender executed it. ICommandSender can be any object that extends Entity, or MinecraftServer.
If ICommandSender is null, it will automatically be executed as MinecraftServer (console), if you cannot get access to the MinecraftServer object otherwise.
String represents the raw command. Any command feature is also available here, like @p etc.

getItem(String) will return an Item singleton from the Item-Registry, where String represents it's RegistryName; For example minecraft:iron_ingot

getBlock(String) will return a Block singleton from the Block-Registry, where String represents it's RegistryName; For example minecraft:iron_block

getPosition(Entity, String) will return one coordinate for the passed Entity, denoted by String which can be either of "x", "y" or "z".
Call this multiple times with different axii to gain the Entity's current actual position.

updatePlayerInventory(EntityPlayer) will send a packet to the player to re-sync their inventory.
Useful for interacting with events that reduce ItemStacks, or when editing player's inventories; The client will continue as if an event succeeded (if canceled) or not be aware of any change in the inventory until a re-sync happens, through this or by any other means.

updateTileInventory(TileEntity) will send a packet to every player within 64 blocks, forcing clients to re-sync.
Useful when interacting with TileEntities with dynamic rendering, like altars, drawers etc.

Clone this wiki locally