Skip to content

Commit

Permalink
Merge pull request #17 from ZXMushroom63/main
Browse files Browse the repository at this point in the history
Plugin API a5.3 Doc
  • Loading branch information
OtterCodes101 authored Oct 21, 2023
2 parents b925cf1 + fd516ba commit 6798275
Show file tree
Hide file tree
Showing 12 changed files with 418 additions and 103 deletions.
131 changes: 67 additions & 64 deletions src/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ module.exports = {
['meta', { name: 'apple-mobile-web-app-status-bar-style', content: 'black' }],
['link', { rel: 'icon', href: '/favicon.ico' }],
['meta', {
name: 'theme-color',
content: '#22282e',
media: '(prefers-color-scheme: light)'
}],
name: 'theme-color',
content: '#22282e',
media: '(prefers-color-scheme: light)'
}],
['meta', {
name: 'theme-color',
content: '#22282e',
media: '(prefers-color-scheme: dark)'
}]
name: 'theme-color',
content: '#22282e',
media: '(prefers-color-scheme: dark)'
}]
],

/**
Expand Down Expand Up @@ -58,77 +58,80 @@ module.exports = {
sidebar: {
'/guide/': [
{

title: 'Guide',
collapsable: false,
children: [
children: [
'',
'non-eagler',
'making-patch-files',
'InstallingPlugins',
'making-patch-files',
'InstallingPlugins',
'MakingPlugins',
],

}
],
'/plugindocs/': [
{
title: 'Plugin API',
collapsable: false,
children: [
'',
],
},
{
title: 'Events',
collapsable: true,
children: [
'events/addEventListener',
'events/removeEventListener',
'events/FromServerEvents',
'events/ToServerEvents',
],
},
{
title: 'Globals',
collapsable: true,
children: [
'globals/Data',
'globals/AxisAlignedBB',
'globals/BlockData',
'globals/BlockPos',
'globals/ChunkData',
'globals/ContainerData',
'globals/EnchantmentData',
'globals/EntityData',
'globals/FishHookData',
'globals/InventoryBasicData',
'globals/InventoryPlayerData',
'globals/ItemData',
'globals/ItemStackData',
'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',
],
}
'/plugindocs/': [
{
title: 'Plugin API',
collapsable: false,
children: [
'',
],
},
{
title: 'Events',
collapsable: true,
children: [
'events/addEventListener',
'events/removeEventListener',
'events/FromServerEvents',
'events/ToServerEvents',
],
},
{
title: 'Globals',
collapsable: true,
children: [
'globals/Data',
'globals/AxisAlignedBB',
'globals/BlockData',
'globals/BlockPos',
'globals/ChunkData',
'globals/ContainerData',
'globals/EnchantmentData',
'globals/EntityData',
'globals/FishHookData',
'globals/FoodStatsData',
'globals/GameSettingsData',
'globals/InventoryBasicData',
'globals/InventoryPlayerData',
'globals/ItemData',
'globals/ItemStackData',
'globals/KeyBindingData',
'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',
],
}
],
}
},

/**
* Apply plugins,ref:https://v1.vuepress.vuejs.org/zh/plugin/
*/
plugins: [
plugins: [
'@vuepress/plugin-back-to-top',
'@vuepress/plugin-medium-zoom',
]
Expand Down
35 changes: 18 additions & 17 deletions src/guide/InstallingPlugins.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
# 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>Optional: Refresh the GUI to see if the plugin loaded correctly.</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/EaglerReborn/reborn/main/exampleplugins/spider.js

And one that allows you to step up 9.5 blocks:<br>
_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._

1. Open the compiled client
2. Open options
3. Click 'Plugins'
4. Click 'Add New'
5. Paste in the .js url.
6. Optional: Refresh the GUI to see if the plugin loaded correctly.


-----


Here is a sample plugin that prevents you from taking fall damage:\
https://raw.githubusercontent.com/EaglerReborn/reborn/main/exampleplugins/nofall.js

And one that allows you to step up 9.5 blocks:\
https://raw.githubusercontent.com/EaglerReborn/reborn/main/exampleplugins/step.js

And finally, a grappling hook mod!:<br>
And finally, a grappling hook mod!:\
https://raw.githubusercontent.com/EaglerReborn/reborn/main/exampleplugins/grapplehook.js
92 changes: 92 additions & 0 deletions src/guide/MakingPlugins.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# How to create a plugin

You will need:
- Knowledge of JavaScript
- A code editor (I use [vscode.dev](https://vscode.dev))
- Knowledge of Minecraft

## What is a plugin?
A plugin is a script that is loaded by EaglerReborn on startup or when added. It can do anythin regular JavaScript do, as well as access the [Plugin API](../plugindocs/README.md).

<details>
<summary>
How to make an example "Spider" hack plugin
</summary>

## How to make an example "Spider" hack plugin

Spider is a hack that allows you to climb up walls like a spider.

Create a new file with the `.js` extension, and open it in your code editor.

We will start by [requiring](../plugindocs/README.md#using-non-auto-properties) the player.
Requiring allows us to access non-automatic properties of the Plugin API.

Add this line of code:
```javascript
PluginAPI.require("player");
```
This will allow us to access the player.


Now, we need to add a listener that will run code every game tick.\
Make a function. (Name it whatever you want)
```javascript
function spiderListener() {

}
```

Inside this function we will do two things:
- Check if the player is walking in to a wall
- If they are, add vertical motion

Let's start with checking if the player is walking in to a wall.\
In the function you just made, add an `if` block.
```javascript
if () {

}
```

We can check whether or not the player is walking in to a wall with `PluginAPI.player.isCollidedHorizontally`.
```javascript
if (PluginAPI.player.isCollidedHorizontally) {

}
```

Now to add the vertical motion, we change the `motionY` property of `PluginAPI.player`.\
I will use the `+=` operator, which adds an amount to a variable.

In the if, add these lines:
```javascript
PluginAPI.player.motionY += 0.2;
PluginAPI.player.reload();
```

You can change the `0.2` to something larger or smaller if you want. The `reload()` call is used to tell the Plugin API to update the in-game values, so we can see our changes.

Finally, we need to add the listener.
```javascript
PluginAPI.addEventListener("update", spiderListener);
```
This tells the Plugin API to run `spiderListener` every game update (or tick).

Your finished code should somewhat look like this:
```javascript
function spiderListener() {
if (PluginAPI.player.isCollidedHorizontally) {
PluginAPI.player.motionY += 0.2;
PluginAPI.player.reload();
}
}
PluginAPI.addEventListener("update", spiderListener);
```

Now, open the EaglerReborn client.
Go to Options > Plugins and press "upload".
Select the plugin file.

Now, when joining a server (without an anti-cheat), you should be able to climb up walls like a spider.
</details>
28 changes: 14 additions & 14 deletions src/guide/making-patch-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ In order to make your own patch files, you will need the following:
4. FFMPEG

---
<sub>Note: This tutorial only works on Linux or MacOS. To do this on Windows, either setup up a virtual machine or use WSL (preferably WSL 2).</sub>
Note: This tutorial only works on Linux or MacOS. To do this on Windows, either setup up a virtual machine or use WSL (preferably WSL 2).

---

First, move the 1.8.8 jar, the 1.8.json file, and mcp918.zip into the mcp918 folder.<br>
Then. open a terminal in the root directory of the repo.<br>
Run `java -jar buildtools/BuildTools.jar init` in the terminal.<br>
After it's done, do `java -jar buildtools/BuildTools.jar workspace`. It should ask you what directory you want it in.<br>
After putting this info in, it should create the directory you specified and place a Gradle project inside.<br>
This is the decompiled source of Minecraft 1.8.8, plus the patches.<br>
Just modify the files and do `./gradlew teavm` inside the workspace to compile.<br>
Then do `bash CompileEPK.sh` to get an assets.epk file.<br>
If you want to quickly test, do `python -m http.server` in the workspace and go to localhost:8000 in your browser.<br>
If you want to make a pull request, do `java -jar buildtools/BuildTools.jar pullrequest` to generate a pullrequest folder.<br>
Then, take this modified version of the repo and upload it to Github, make a pullrequest, and I will take a look.<br>
First, move the 1.8.8 jar, the 1.8.json file, and mcp918.zip into the mcp918 folder.
Then. open a terminal in the root directory of the repo.
Run `java -jar buildtools/BuildTools.jar init` in the terminal.
After it's done, do `java -jar buildtools/BuildTools.jar workspace`. It should ask you what directory you want it in.
After putting this info in, it should create the directory you specified and place a Gradle project inside.
This is the decompiled source of Minecraft 1.8.8, plus the patches.
Just modify the files and do `./gradlew teavm` inside the workspace to compile.
Then do `bash CompileEPK.sh` to get an assets.epk file.
If you want to quickly test, do `python -m http.server` in the workspace and go to localhost:8000 in your browser.
If you want to make a pull request, do `java -jar buildtools/BuildTools.jar pullrequest` to generate a pullrequest folder.
Then, take this modified version of the repo and upload it to Github, make a pullrequest, and I will take a look.
If you are making your own fork of EaglerReborn and have it open source, you can do `java -jar buildtools/BuildTools.jar merge`
to finish generating the patch files.<br>
<br>
to finish generating the patch files.

To make an offline download, run `bash MakeOfflineDownload.sh` after running `./gradlew teavm` and `bash CompileEPK.sh`
8 changes: 6 additions & 2 deletions src/plugindocs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ 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`.
- A [`LocalPlayerData`](globals/LocalPlayerData.md) made from `EntityPlayerSP`. Regenerated every time the `update` event is called.
- `network: NetworkData`
- A [`NetworkData`](globals/NetworkData.md) made from `NetHandlerPlayClient`.
- A [`NetworkData`](globals/NetworkData.md) made from `NetHandlerPlayClient`. Regenerated every time the `update` event is called.
- `settings: GameSettingsData`
- A [`GameSettingsData`](globals/GameSettingsData.md) made from `GameSettings`. Regenerated every time the `update` event is called.
- `items: ItemData{}`
- A [`ItemData`](globals/ItemData.md) dictionary of all item types, and block-item types. [Auto]
- `blocks: BlockData{}`
Expand Down Expand Up @@ -39,6 +41,8 @@ It has the following methods:
- 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 generate `PluginAPI.player` or `PluginAPI.network`

### Passing 'Ref' objects
Eg: `setCurrentItemOrArmor({slotIn: Integer, itemStack: ItemStackRef}) : void`
Expand Down
13 changes: 11 additions & 2 deletions src/plugindocs/events/addEventListener.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,24 @@ It has the following valid values:
- `gui`
Called when the Plugin Manager GUI shows up. No arguments passed to callback.

- `load`
Called when all plugins have finished loading.

- `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`.
- `preventDefault:` Boolean representing whether or not to cancel processing the chat message. Default is `false`.

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

- `motionupdate`
Called on motion update.
- `preventDefault`: Boolean representing whether or not to cancel sending motion updates to the server.

- `premotionupdate`
Called before player motion is updated. Passes an object with properties:
- `yaw`: Number representing the player's yaw rotation.
Expand All @@ -39,8 +46,10 @@ It has the following valid values:
- `preventDefault`: Boolean representing whether or not to prevent the default action for this key (if any).


More events:
### More events:

[Receiving packet events](FromServerEvents.md)

[Sending packet events](ToServerEvents.md)

### (Function) Callback
Expand Down
Loading

0 comments on commit 6798275

Please sign in to comment.