Skip to content

Commit

Permalink
PluginAPI a5.1 Doc
Browse files Browse the repository at this point in the history
  • Loading branch information
OtterCodes101 authored Oct 3, 2023
2 parents 303c5ae + 200c84e commit eb23509
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,27 +95,28 @@ module.exports = {
'globals/AxisAlignedBB',
'globals/BlockData',
'globals/BlockPos',
'globals/ChunkData',
'globals/ContainerData',
'globals/Data',
'globals/EnchantmentData',
'globals/EntityData',
'globals/FishHookData',
'globals/InventoryBasicData',
'globals/InventoryPlayerData',
'globals/ItemData',
'globals/ItemStackData',
'globals/ListOfGlobals',
'globals/LivingEntityData',
'globals/LocalPlayerData',
'globals/MapColor',
'globals/MaterialData',
'globals/NetworkData',
'globals/PlayerCapabilities',
'globals/PlayerData',
'globals/RemotePlayerData',
'globals/require',
'globals/updateComponent',
'globals/Vec3',
'globals/Vec3i',
'globals/Vec4b',
],
}
],
Expand Down
18 changes: 16 additions & 2 deletions src/plugindocs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The Plugin API consists of a global JavaScript object on the window, called, ver
It has the following properties:
- `player: LocalPlayerData`
- A [`LocalPlayerData`](globals/LocalPlayerData.md) made from `EntityPlayerSP`.
- `network: NetworkData`
- A [`NetworkData`](globals/NetworkData.md) made from `NetHandlerPlayClient`.
- `items: ItemData{}`
- A [`ItemData`](globals/ItemData.md) dictionary of all item types, and block-item types. [Auto]
- `blocks: BlockData{}`
Expand All @@ -14,8 +16,13 @@ It has the following properties:
- `enchantments: EnchantmentData{}`
- An [`EnchantmentData`](EnchantmentData.md) dictionary of all the in-game enchantments. [Auto]
- `constructors: Object`
A object containing constructors to make some Java objects from within JavaScript. [Auto]
- A object containing constructors to make some Java objects from within JavaScript. [Auto]
- `javaClient: Object`
- This is the `Minecraft` instance exposed to JavaScript. It has no wrapping, and so many properties will be illegible. To use it, I would recommend editing the `build.gradle` in the worspace to set `minifying: false;` [Auto]
- `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`


It has the following methods:
Expand All @@ -28,10 +35,17 @@ It has the following methods:
- Documentation [here](globals/updateComponent.md)
- `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.

### 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](globals/Data.md).

### Using non-auto properties
In order to use non-auto properties like `PluginAPI.player`, they must be [required](globals/require.md)
In order to use non-auto properties like `PluginAPI.player` or `PluginAPI.network`, they must be [required](globals/require.md)

### Triggering data updates (`reload()`)
To trigger the game to read your updated values, call the `reload()` method on the object.
Expand Down
5 changes: 4 additions & 1 deletion src/plugindocs/events/addEventListener.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ It has the following valid values:


More events:
[Receiving packet events](FromServerEvents.md)
[Receiving packet events](FromServerEvents.md)

### (Function) Callback
The function to call when this event fires.
32 changes: 32 additions & 0 deletions src/plugindocs/events/removeEventListener.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# PluginAPI.removeEventListener(String eventName, Function callback, Boolean slow?)
This method is used to add event listeners to the event name specified.

## Arguments:

### (String) eventName
Type of event to remove the listener from.

### (Function) callback
The function to remove from the event listener array.

### [Optional] (Boolean) slow
Wether or not to use the functions definition rather than it's reference to look in the listener array. Much slower with it on.

Example where it is not necessary:
```
function myListener() {
// idk
}
PluginAPI.addEventListener("update", myListener);
PluginAPI.removeEventListener("update", myListener);
```

Example where it is necessary:
```
PluginAPI.addEventListener("update", function myListener() {
// idk
});
PluginAPI.removeEventListener("update", function myListener() {
// idk
});
```
3 changes: 2 additions & 1 deletion src/plugindocs/globals/Data.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Data

Data is the parent of all other types of data, so all types of data share the `reload()` method. Reload is used to force reload the data in-game.
Data is the parent of all other types of data, so all types of data share the `reload()` method. Reload is used to force reload the data in-game.
Almost all data objects also have a `getRef()` method. `getRef()` is used to get the java object.
4 changes: 2 additions & 2 deletions src/plugindocs/globals/ItemStackData.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ Has the following methods:
- `hasDisplayName() : Boolean`
- `hasEffect() : Boolean`
- `isItemEnchantable() : Boolean`
- `addEnchantment({enchId: Integer, level: Integer}) : void`
- `addEnchantment({ench: EnchantmentRef, level: Integer}) : void`
- `isItemEnchanted() : Boolean`
- `canEditBlocks() : Boolean`
- `isOnItemFrame() : Boolean`
- `getRepairCost() : Integer`
- `setRepairCost({cost: Integer}) : void`
- `setItem(itemId: Integer) : void`
- `setItem(newItem: ItemRef) : void`
- `canDestroy({blockId: Integer}) : Boolean`
- `canPlaceOn({blockId: Integer}) : Boolean`
- `toNBT() : String`
Expand Down
2 changes: 1 addition & 1 deletion src/plugindocs/globals/LivingEntityData.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ It has the following methods:
- `getAttackingPlayer() : PlayerData`
- `getLastAttacker() : LivingEntityData`
- `getEntityLivingToAttack() : LivingEntityData`
- `setEntityLivingToAttack({uuid: String}) : void`
- `setEntityLivingToAttack({entity: EntityRef}) : void`
- `canBreatheUnderwater() : Boolean`
- `isChild() : Boolean`
- `canDropLoot() : Boolean`
Expand Down
2 changes: 1 addition & 1 deletion src/plugindocs/globals/LocalPlayerData.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ A LocalPlayerData usually has all of the properties of [PlayerData](PlayerData.m
- `horseJumpPowerCounter: Integer`

It has these methods:
- `mountEntity({entityUUID: String}) : void`
- `mountEntity({entityIn: EntityRef}) : void`
- `dropOneItem({dropAll: Boolean}) : EntityData`
- `sendChatMessage({message: String}) : void`
- `respawnPlayer() : void`
Expand Down
39 changes: 39 additions & 0 deletions src/plugindocs/globals/NetworkData.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# NetworkData
Represents the network handler. Has many built-in functions to easily send packets to the server..

Properties:
- `doneLoadingTerrain`: Boolean
- `currentServerMaxPlayers`: Integer

Methods:
- `sendPacketAnimation() : void`
- `sendPacketEntityAction({entityRef: EntityRef, action: String, auxData: Integer}) : void`
- `action` can be one of: `START_SNEAKING`, `STOP_SNEAKING`, `STOP_SLEEPING`, `START_SPRINTING`, `STOP_SPRINTING`, `RIDING_JUMP` or `OPEN_INVENTORY`
- `sendPacketInput({strafeSpeed: Number, forwardSpeed: Number, jumping: Boolean, sneaking: Boolean}) : void`
- `sendPacketCloseWindow({windowId: Integer}) : void`
- `sendPacketClickWindow({windowId: Integer, slotId: Integer, usedButton: Integer, mode: Integer, clickedItemRef: ItemStackRef?, actionNumber: Short}) : void`
- `sendPacketConfirmTransaction({windowId: Integer, uid: Short, accepted: Boolean}) : void`
- `sendPacketKeepAlive({key: Integer}) : void`
- `sendPacketChatMessage({messageIn: String}) : void`
- `sendPacketUseEntity({entityRef: EntityRef, hitVec: Vec3}) : void`
- `sendPacketUseEntity({entityRef: EntityRef, action: String}) : void`
- `action` can be one of: `INTERACT`, `ATTACK` or `INTERACT_AT`
- `sendPacketPlayer({isOnGround: Boolean}) : void`
- `sendPacketPlayerDigging({action: String, pos: BlockPos, facing: String}) : void`
- `action` can be one of: `START_DESTROY_BLOCK`, `ABORT_DESTROY_BLOCK`, `STOP_DESTROY_BLOCK`, `DROP_ALL_ITEMS`, `DROP_ITEM` or `RELEASE_USE_ITEM`
- `facing` can be one of: `UP`, `DOWN`, `NORTH`, `SOUTH`, `EAST` or `WEST`
- `sendPacketPlayerBlockPlacement({stackRef: ItemStackRef}) : void`
- `sendPacketHeldItemChange({slotId: Integer}) : void`
- `sendPacketCreativeInventoryAction({slotId: Integer, stackRef: ItemStackRef}) : void`
- `sendPacketEnchantItem({windowId: Integer, button: Integer}) : void`
- `sendPacketUpdateSign({pos: BlockPos, lines: String[]}) : void`
- `sendPacketPlayerAbilities({capabilitiesRef: PlayerCapabilitiesRef}) : void`
- `sendPacketTabComplete({msg: String}) : void`
- `sendPacketTabComplete({msg: String, target: BlockPos}) : void`
- `sendPacketClientSettings({lang: String, view: Integer, chatVisibility: String, enableColors: Boolean, modelPartFlags: Integer}) : void`
- `chatVisibility` can be one of: `FULL`, `SYSTEM` or `HIDDEN`
- `sendPacketClientStatus({status: String}) : void`
- `status` can be one of: `PERFORM_RESPAWN`, `REQUEST_STATS` or `OPEN_INVENTORY_ACHIEVEMENT`
- `sendPacketSpectate({uuid: String}) : void`
- `sendPacketResourcePackStatus({hash: String, status: String}) : void`
- `status` can be one of: `SUCCESSFULLY_LOADED`, `DECLINED`, `FAILED_DOWNLOAD` or `ACCEPTED`
2 changes: 1 addition & 1 deletion src/plugindocs/globals/RemotePlayerData.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ A RemotePlayerData usually has all of the properties of [PlayerData](PlayerData.
- `otherPlayerMPPitch: Number`

It has these methods:
- `setCurrentItemOrArmor({slotIn: Integer, itemNbt: String}) : void`
- `setCurrentItemOrArmor({slotIn: Integer, itemStack: ItemStackRef}) : void`
- `isSpectator() : Boolean`

0 comments on commit eb23509

Please sign in to comment.