Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring in plugindocs #3

Merged
2 commits merged into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/guide/InstallingPlugins.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# How to install a plugin

<i>Please keep in mind that these plugins are fully client side and therefore work on most servers. They can be considered hacks or unfair advantages, so be careful when using them.</i>

<ol>
<li>Open the compiled client</li>
<li>Open options</li>
<li>Click 'Plugins'</li>
<li>Click 'Add New'</li>
<li>Paste in the .js url.</li>
<li>Reload to use the plugin.</li>
<li>Optional: If the plugin is not working, go to options > plugins and make sure it says 'LOADED' next to your plugin. If it doesn't, it's not my fault!!!</li>
</ol>

Here is a sample plugin that allows you to climb up walls like a spider:
https://raw.githubusercontent.com/ZXMushroom63/EaglerPL/main/plugins/spider.js

And one that allows you to step up 9.5 blocks:<br>
https://raw.githubusercontent.com/ZXMushroom63/EaglerPL/main/plugins/step.js

And finally, a grappling hook mod!:<br>
https://raw.githubusercontent.com/ZXMushroom63/EaglerPL/main/plugins/grapplehook.js
14 changes: 14 additions & 0 deletions src/guide/plugindocs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Plugin API
The Plugin API consists of a global JavaScript object on the window, called, very simply, `PluginAPI`.


It has the following methods:
| Name | Description | Arguments | Documentation |
| ----------- | ----------- | ----------- | ----------- |
| `addEventListener` | Used to add listeners to events. | String eventName, Function callback | [addEventListener.md](events/addEventListener.md) |
| `updateComponent` | Tells `PluginAPI` that a global needs to be reloaded. | String globalName | [updateComponent.md](globals/updateComponent.md) |




It also has some global objects which expose some of the inner Minecraft workings. Go [here](globals/ListOfGlobals.md) to view the full list.
30 changes: 30 additions & 0 deletions src/guide/plugindocs/events/addEventListener.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# PluginAPI.addEventListener(String eventName, Function callback)
This method is used to add event listeners to the event name specified.

## Arguments:

### (String) eventName
This argument is used to specify internally which listener array to add the callback to.
It has the following valid values:
- `update`
Called every client tick. No arguments passed to callback.

- `sendchatmessage`
Called just before the player sends a chat message. Passes an object with properties:
- `message` String representing the chat message.
- `preventDefault` Boolean representing whether or not to cancel sending the packet. Default is `false`.

- `postmotionupdate`
Called after player motion is updated. No arguments passed to callback.

- `premotionupdate`
Called before player motion is updated. Passes an object with properties:
- `yaw` Number representing the player's yaw rotation.
- `pitch` Number representing the player's pitch rotation.
- `onGround` Boolean representing whether the player is on ground or not.

- `key`
Called when a special keypress is detected. ie: not `esc` or `open chat`, like `f3` or the letter `J`.
Passes an object with properties:
- `key` Integer representing the LWJGL key code.
- `preventDefault` Boolean representing whether or not to prevent the default action for this key (if any).
86 changes: 86 additions & 0 deletions src/guide/plugindocs/globals/EntityData.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# EntityData

A typical EntityData object will have the following properties:
- `x`: Number: Equal to the entity's `posX`.
- `y`: Number: Equal to the entity's `posY`.
- `z`: Number: Equal to the entity's `posZ`.
- `chunkCoordX`: Number: Equal to the entity's `chunkCoordX`. (Read-only)
- `chunkCoordY`: Number: Equal to the entity's `chunkCoordY`. (Read-only)
- `chunkCoordZ`: Number: Equal to the entity's `chunkCoordZ`. (Read-only)
- `motionX`: Number: Equal to the entity's `motionX`.
- `motionY`: Number: Equal to the entity's `motionY`.
- `motionZ`: Number: Equal to the entity's `motionZ`.
- `yaw`: Number: Equal to the entity's `rotationYaw`.
- `pitch`: Number: Equal to the entity's `rotationPitch`.
- `isInWeb`: Boolean: Equal to the entity's `isInWeb`.
- `isCollided`: Boolean: Equal to the entity's `isCollided`.
- `isCollidedVertically`: Boolean: Equal to the entity's `isCollidedVertically`.
- `isCollidedHorizontally`: Boolean: Equal to the entity's `isCollidedHorizontally`.
- `onGround`: Boolean: Equal to the entity's `onGround`.
- `dimension`: Integer: Equal to the entity's `dimension`. (Read-only)
- `id`: Integer: Equal to the entity's `entityId`. (Read-only)
- `fallDistance`: Number: Equal to the entity's `fallDistance`. (Read-only)
- `noClip`: Boolean: Equal to the entity's `noClip`.
- `stepHeight`: Number: Equal to the entity's `stepHeight`.
- `isDead`: Boolean: Equal to the entity's `isDead`. (Read-only)
- `inPortal`: Boolean: Equal to the entity's `inPortal`.
- `inWater`: Boolean: Equal to the entity's `inWater`.
- `isAirBorne`: Boolean: Equal to the entity's `isAirBorne`.
- `ticksExisted`: Integer: Equal to the entity's `ticksExisted`. (Read-only)
- `invulnerable`: Boolean: Equal to the entity's `invulnerable`.
- `isImmuneToFire`: Boolean: Equal to the entity's `isImmuneToFire`.
- `isOutsideBorder`: Boolean: Equal to the entity's `isOutsideBorder`.
- `entityCollisionReduction`: Number: Equal to the entity's `entityCollisionReduction`.

Hello. This doc isn't done. At all. Just understand that almost all of the functions listed here take the same arguments and have the same return type as in the normal `Entity.java`.
However, rather than taking a list of arguments `func(a = 1, b = 2, c = 3)` they either take an object or nothing: `func({a: 1, b: 2, c: 3})`. I do this so I don't have to manually write interfaces for every combination possible. Good luck understanding the code below!

```
data.setCallbackBoolean("isBurning", ()->{return isBurning();});
data.setCallbackBoolean("isPushedByWater", ()->{return isPushedByWater();});
data.setCallbackBoolean("isEating", ()->{return isEating();});
data.setCallbackBoolean("isEntityAlive", ()->{return isEntityAlive();});
data.setCallbackBoolean("isEntityInsideOpaqueBlock", ()->{return isEntityInsideOpaqueBlock();});
data.setCallbackBoolean("isImmuneToExplosions", ()->{return isImmuneToExplosions();});
data.setCallbackBoolean("isImmuneToFire", ()->{return isImmuneToFire();});
data.setCallbackBoolean("isInLava", ()->{return isInLava();});
data.setCallbackBooleanWithDataArg("isInRangeToRender3d", (BaseData params)->{return isInRangeToRender3d(params.getDouble("x"), params.getDouble("y"), params.getDouble("z"));});
data.setCallbackBooleanWithDataArg("isInRangeToRenderDist", (BaseData params)->{return isInRangeToRenderDist(params.getDouble("distance"));});
data.setCallbackBoolean("isInWater", ()->{return isInWater();});
data.setCallbackBoolean("isInvisible", ()->{return isInvisible();});
data.setCallbackBoolean("isPushedByWater", ()->{return isPushedByWater();});
data.setCallbackBoolean("isRiding", ()->{return isRiding();});
data.setCallbackBoolean("isSilent", ()->{return isSilent();});
data.setCallbackBoolean("isSneaking", ()->{return isSneaking();});
data.setCallbackBoolean("isSprinting", ()->{return isSprinting();});
data.setCallbackBoolean("isWet", ()->{return isWet();});

data.setCallbackVoidWithDataArg("setAir", (BaseData params)->{setAir(params.getInt("air"));});
data.setCallbackVoidWithDataArg("setAlwaysRenderNameTag", (BaseData params)->{setAlwaysRenderNameTag(params.getBoolean("alwaysRenderNameTag"));});
data.setCallbackVoidWithDataArg("setAngles", (BaseData params)->{setAngles(params.getFloat("yaw"),params.getFloat("pitch"));});
data.setCallbackVoid("setBeenAttacked", ()->{setBeenAttacked();});
data.setCallbackVoidWithDataArg("setCustomNameTag", (BaseData params)->{setCustomNameTag(params.getString("name"));});
data.setCallbackVoid("setDead", ()->{setDead();});
data.setCallbackVoidWithDataArg("setEating", (BaseData params)->{setEating(params.getBoolean("eating"));});
data.setCallbackVoidWithDataArg("setEntityId", (BaseData params)->{setEntityId(params.getInt("id"));});
data.setCallbackVoidWithDataArg("setFire", (BaseData params)->{setFire(params.getInt("seconds"));});
data.setCallbackVoidWithDataArg("setFlag", (BaseData params)->{setFlag(params.getInt("flag"), params.getBoolean("set"));});
data.setCallbackVoid("setInWeb", ()->{setInWeb();});
data.setCallbackVoidWithDataArg("setInvisible", (BaseData params)->{setInvisible(params.getBoolean("invisible"));});
data.setCallbackVoidWithDataArg("setLocationAndAngles", (BaseData params)->{setLocationAndAngles(params.getDouble("x"), params.getDouble("y"), params.getDouble("z"), params.getFloat("yaw"), params.getFloat("pitch"));});
data.setCallbackVoid("setOnFireFromLava", ()->{setOnFireFromLava();});
data.setCallbackVoidWithDataArg("setOutsideBorder", (BaseData params)->{setOutsideBorder(params.getBoolean("outsideBorder"));});
data.setCallbackVoidWithDataArg("setPosition", (BaseData params)->{setPosition(params.getDouble("x"), params.getDouble("y"), params.getDouble("z"));});
data.setCallbackVoidWithDataArg("setPositionAndRotation", (BaseData params)->{setPositionAndRotation(params.getDouble("x"), params.getDouble("y"), params.getDouble("z"), params.getFloat("yaw"), params.getFloat("pitch"));});
data.setCallbackVoidWithDataArg("setPositionAndRotation2", (BaseData params)->{setPositionAndRotation2(params.getDouble("d0"), params.getDouble("d1"), params.getDouble("d2"), params.getFloat("f"), params.getFloat("f1"), params.getInt("var9"), params.getBoolean("var10"));});
data.setCallbackVoidWithDataArg("setPositionAndUpdate", (BaseData params)->{setPositionAndUpdate(params.getDouble("d0"), params.getDouble("d1"), params.getDouble("d2"));});
data.setCallbackVoidWithDataArg("setRotation", (BaseData params)->{setRotation(params.getFloat("yaw"),params.getFloat("pitch"));});
data.setCallbackVoidWithDataArg("setRotationYawHead", (BaseData params)->{setRotationYawHead(params.getFloat("rotation"));});
data.setCallbackVoidWithDataArg("setSilent", (BaseData params)->{setSilent(params.getBoolean("isSilent"));});
data.setCallbackVoidWithDataArg("setSize", (BaseData params)->{setSize(params.getFloat("f"), params.getFloat("f1"));});
data.setCallbackVoidWithDataArg("setSneaking", (BaseData params)->{setSneaking(params.getBoolean("sneaking"));});
data.setCallbackVoidWithDataArg("setSprinting", (BaseData params)->{setSprinting(params.getBoolean("flag"));});
data.setCallbackVoidWithDataArg("setVelocity", (BaseData params)->{setVelocity(params.getDouble("x"), params.getDouble("y"), params.getDouble("z"));});

data.setCallbackString("getUUID", ()->{return entityUniqueID.toString();});
```
18 changes: 18 additions & 0 deletions src/guide/plugindocs/globals/FishHookData.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# EntityData

A typical EntityData object will have the following properties:
All of the properties of [EntityData](EntityData.md), and:
- `inGround`: Boolean: Whether or not the fish hook is in the ground.
- `xTile`: Integer: Equal to the fish hook's `xTile`.
- `yTile`: Integer: Equal to the fish hook's `yTile`.
- `zTile`: Integer: Equal to the fish hook's `zTile`.
- `shake`: Integer: Equal to the fish hook's `shake`.
- `ticksCatchable`: Integer: Equal to the fish hook's `ticksCatchable`.
- `ticksCatchableDelay`: Integer: Equal to the fish hook's `ticksCatchableDelay`.
- `ticksCaughtDelay`: Integer: Equal to the fish hook's `ticksCaughtDelay`.
- `ticksInAir`: Integer: Equal to the fish hook's `ticksInAir`.
- `ticksInGround`: Integer: Equal to the fish hook's `ticksInGround`.
- `caughtEntity`: [EntityData](EntityData.md): The entity the fish hook is hooked on to. (If existing)
- `fishApproachAngle`: Number: Equal to the fish hook's `fishApproachAngle`.
- `fishPitch`: Number: Equal to the fish hook's `fishPitch`
- `fishPosRotationIncrements`: Integer: Equal to the fish hook's `fishPosRotationIncrements`.
7 changes: 7 additions & 0 deletions src/guide/plugindocs/globals/ListOfGlobals.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# List of Globals

- `PluginAPI.player`
An [`EntityData`](EntityData.md) made from `EntityPlayerSP`.


I hope to add more soon. Maybe even one for the renderer!
24 changes: 24 additions & 0 deletions src/guide/plugindocs/globals/PlayerData.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# EntityData

A typical EntityData object will have the following properties:
All of the properties of [EntityData](EntityData.md), and:

- `cameraYaw`: Number: Equal to the player's `cameraYaw`.
- `chasingPosX`: Number: Equal to the player's `chasingPosX`.
- `chasingPosY`: Number: Equal to the player's `chasingPosY`.
- `chasingPosZ`: Number: Equal to the player's `chasingPosZ`.
- `experience`: Number: The player's experience number.
- `experienceLevel`: Integer: The player's experience level.
- `experienceTotal`: Integer: The player's experience total.
- `fishEntity`: [FishHookData](FishHookData.md): The player's fishing bobber / hook. (If existing)
- `flyToggleTimer`: Integer: Equal to the player's `flyToggleTimer`.
- `hasReducedDebug`: Boolean: Equal to the player's `hasReducedDebug`.
- `itemInUseCount`: Integer: The count of the item that the player is currenly using. (Read-only)
- `lastXPSound`: Integer: Equal to the player's `lastXPSound`.
- `sleepTimer`: Integer: Equal to the player's `sleepTimer`.
- `sleeping`: Boolean: Whether or not the player is sleeping.
- `spawnForced`: Boolean: Equal to the player's `spawnForced`.
- `speedInAir`: Number: Equal to the player's `speedInAir`.
- `speedOnGround`: Number: Equal to the player's `speedOnGround`.
- `xpCooldown`: Integer: Equal to the player's `xpCooldown`.
- `xpSeed`: Integer: Equal to the player's `xpSeed`.
9 changes: 9 additions & 0 deletions src/guide/plugindocs/globals/updateComponent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# PluginAPI.updateComponent(String componentName)
This method is used to tell `PluginAPI` that a global needs to be reloaded.

## Arguments:

### (String) componentName
This argument is used to get which global object needs reloading:

It is always equal to the identifier of the global. ie: `PluginAPI.player`'s identifier is `player`.
Loading