# Plugin API
The Plugin API consists of a global JavaScript object on the window, called, very simply, PluginAPI.
It has the following properties:
player: LocalPlayerData- A
LocalPlayerDatamade fromEntityPlayerSP. Regenerated every time theupdateevent is called.
- A
network: NetworkData- A
NetworkDatamade fromNetHandlerPlayClient. Regenerated every time theupdateevent is called.
- A
settings: GameSettingsData- A
GameSettingsDatamade fromGameSettings. Regenerated every time theupdateevent is called.
- A
items: ItemData{}- A
ItemDatadictionary of all item types, and block-item types. [Auto]
- A
blocks: BlockData{}- A
BlockDatadictionary of all block types. [Auto]
- A
materials: MaterialData{}- A
MaterialDatadictionary of all the block materials. [Auto]
- A
enchantments: EnchantmentData{}- An
EnchantmentDatadictionary of all the in-game enchantments. [Auto]
- An
constructors: Object- A object containing constructors to make some Java objects from within JavaScript. [Auto]
javaClient: Object- This is the
Minecraftinstance exposed to JavaScript. It has no wrapping, and so many properties will be illegible. To use it, I would recommend editing thebuild.gradlein the workspace to setminifying: false;[Auto]
- This is the
version: String- The version of the Plugin API (If not accessible, you can check the PluginAPI version in the f3 menu)
clientBrand: String- The brand of the Eaglercraft client, taken from
ClientBrandRetriever.java
- The brand of the Eaglercraft client, taken from
It has the following methods:
addEventListener(eventName: String, callback: Function) : void- Documentation here
require(componentName: String)- Documentation here
updateComponent(componentName: String)- [Deprecated, use
reload()instead] - Documentation here
- [Deprecated, use
displayToChat({msg: String})- Displays client-side message to user's ingame chat gui.
clickMouse()- Triggers a left click ingame.
rightClickMouse()- Triggers a right click ingame.
update()- Force triggers a Plugin API update. Note that while the update event fires, not all objects are necessarily generated. Eg: Calling
update()while not ingame will not generatePluginAPI.playerorPluginAPI.network
- Force triggers a Plugin API update. Note that while the update event fires, not all objects are necessarily generated. Eg: Calling
# Passing 'Ref' objects
Eg: setCurrentItemOrArmor({slotIn: Integer, itemStack: ItemStackRef}) : void
This method's itemStack parameter uses an 'ItemStackRef'. 'Refs' are short for 'references', as they are the root reference to a java object, not just a data wrapper. You can get a ref from a Data by using getRef(), as specified here.
# Using non-auto properties
In order to use non-auto properties like PluginAPI.player or PluginAPI.network, they must be required
# Triggering data updates (reload())
To trigger the game to read your updated values, call the reload() method on the object.
Eg:
PluginAPI.player.motionY += 1;
PluginAPI.player.reload();
Frequent calls to reload() may cause lag, so try to limit them.