diff --git a/src/.vuepress/config.js b/src/.vuepress/config.js index 6c5e7b4..55f10bb 100755 --- a/src/.vuepress/config.js +++ b/src/.vuepress/config.js @@ -95,8 +95,8 @@ module.exports = { 'globals/AxisAlignedBB', 'globals/BlockData', 'globals/BlockPos', + 'globals/ChunkData', 'globals/ContainerData', - 'globals/Data', 'globals/EnchantmentData', 'globals/EntityData', 'globals/FishHookData', @@ -104,11 +104,11 @@ module.exports = { 'globals/InventoryPlayerData', 'globals/ItemData', 'globals/ItemStackData', - 'globals/ListOfGlobals', 'globals/LivingEntityData', 'globals/LocalPlayerData', 'globals/MapColor', 'globals/MaterialData', + 'globals/NetworkData', 'globals/PlayerCapabilities', 'globals/PlayerData', 'globals/RemotePlayerData', @@ -116,6 +116,7 @@ module.exports = { 'globals/updateComponent', 'globals/Vec3', 'globals/Vec3i', + 'globals/Vec4b', ], } ], diff --git a/src/plugindocs/README.md b/src/plugindocs/README.md index 3e8f637..1876f69 100644 --- a/src/plugindocs/README.md +++ b/src/plugindocs/README.md @@ -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{}` @@ -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: @@ -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. diff --git a/src/plugindocs/events/addEventListener.md b/src/plugindocs/events/addEventListener.md index 7421b5d..1a140bc 100644 --- a/src/plugindocs/events/addEventListener.md +++ b/src/plugindocs/events/addEventListener.md @@ -31,4 +31,7 @@ It has the following valid values: More events: -[Receiving packet events](FromServerEvents.md) \ No newline at end of file +[Receiving packet events](FromServerEvents.md) + +### (Function) Callback +The function to call when this event fires. \ No newline at end of file diff --git a/src/plugindocs/events/removeEventListener.md b/src/plugindocs/events/removeEventListener.md new file mode 100644 index 0000000..a1b65c9 --- /dev/null +++ b/src/plugindocs/events/removeEventListener.md @@ -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 +}); +``` \ No newline at end of file diff --git a/src/plugindocs/globals/Data.md b/src/plugindocs/globals/Data.md index 388388f..855fcc2 100644 --- a/src/plugindocs/globals/Data.md +++ b/src/plugindocs/globals/Data.md @@ -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. \ No newline at end of file +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. \ No newline at end of file diff --git a/src/plugindocs/globals/ItemStackData.md b/src/plugindocs/globals/ItemStackData.md index 9a62be2..58df6d6 100644 --- a/src/plugindocs/globals/ItemStackData.md +++ b/src/plugindocs/globals/ItemStackData.md @@ -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` diff --git a/src/plugindocs/globals/LivingEntityData.md b/src/plugindocs/globals/LivingEntityData.md index 19b5928..5ba870b 100644 --- a/src/plugindocs/globals/LivingEntityData.md +++ b/src/plugindocs/globals/LivingEntityData.md @@ -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` diff --git a/src/plugindocs/globals/LocalPlayerData.md b/src/plugindocs/globals/LocalPlayerData.md index a1499e9..838b60d 100644 --- a/src/plugindocs/globals/LocalPlayerData.md +++ b/src/plugindocs/globals/LocalPlayerData.md @@ -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` diff --git a/src/plugindocs/globals/NetworkData.md b/src/plugindocs/globals/NetworkData.md new file mode 100644 index 0000000..bbc7d8a --- /dev/null +++ b/src/plugindocs/globals/NetworkData.md @@ -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` \ No newline at end of file diff --git a/src/plugindocs/globals/RemotePlayerData.md b/src/plugindocs/globals/RemotePlayerData.md index 0bc919a..29691a2 100644 --- a/src/plugindocs/globals/RemotePlayerData.md +++ b/src/plugindocs/globals/RemotePlayerData.md @@ -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` \ No newline at end of file