-
Notifications
You must be signed in to change notification settings - Fork 0
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 when you cancel the placement of a block; The held stack will be one lesser (or empty if it had size of 1) client-side 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.