-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from eaglerforge/main
massive update
- Loading branch information
Showing
16 changed files
with
458 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
## ModAPI.promisify() | ||
Some methods in java are asynchronous, meaning that they don't return a value/modify state immediately. Calling them in an event or in a patch to a normal function will cause a stack implosion, characterised by the client/dedicated server hanging without any error messages. | ||
|
||
In order to call them properly from javascript, you need to use the `ModAPI.promisify()` function. | ||
|
||
For example, here we have a simple client-side command that will try to use the `PlatformRuntime` class to download data from a URI: | ||
```javascript | ||
ModAPI.addEventListener("sendchatmessage", function downloadSomething(e) { | ||
if (e.message.toLowerCase().startsWith("/downloadtest")) { | ||
var arraybuffer = ModAPI.hooks.methods.nlevi_PlatformRuntime_downloadRemoteURI(ModAPI.util.str("data:text/plain,hi")); | ||
console.log(arraybuffer); | ||
} | ||
}); | ||
``` | ||
This will cause the client to hang. The correct way of calling this asynchronous method is like this: | ||
```javascript | ||
ModAPI.addEventListener("sendchatmessage", function downloadSomething(e) { | ||
if (e.message.toLowerCase().startsWith("/downloadtest")) { | ||
ModAPI.promisify(ModAPI.hooks.methods.nlevi_PlatformRuntime_downloadRemoteURI)(ModAPI.util.str("data:text/plain,hi")).then(arraybuffer => { | ||
console.log(arraybuffer); | ||
}); | ||
} | ||
}); | ||
``` | ||
|
||
You can replace the argument with any other method or constructor, including non asynchronous ones. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
## Mod tutorials with ModAPI | ||
|
||
Prerequisites: | ||
- Basic knowledge of JavaScript | ||
- A good code editor (recommended: https://vscode.dev) | ||
|
||
### Beginner | ||
- [Step Hack](step.md) | ||
- [Spider Hack](spider.md) | ||
- [VClip Exploit](comingsoon) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
## Spider Hack with ModAPI | ||
A spider hack allows players to climb up any wall like a spider. | ||
|
||
Start by creating a new file in your code editor. Save it to a folder on your device, ensuring that the file extension is `.js`. | ||
|
||
The spider hack has a lot of similarities to the step hack, so lets copy the step hack and rename the `stepHackUpdateCode` function to `spiderHackUpdateCode`: | ||
```javascript | ||
ModAPI.require("player"); | ||
|
||
function spiderHackUpdateCode() { | ||
//We will add code here. | ||
} | ||
ModAPI.addEventListener("update", spiderHackUpdateCode); | ||
``` | ||
|
||
Most spider hacks work by checking if the player is walking into a wall, and then setting their vertical velocity to a constant amount (usually `0.2`, for parity with ladders). | ||
Let's start by checking if the player is walking into a wall, by adding an if statement inside the `spiderHackUpdateCode` function: | ||
```javascript | ||
if (ModAPI.player.isCollidedHorizontally) { | ||
|
||
} | ||
``` | ||
|
||
Now, let's set the player's vertical velocity: | ||
```javascript | ||
if (ModAPI.player.isCollidedHorizontally) { | ||
ModAPI.player.motionY = 0.2; //Feel free to change this value to something bigger, smaller or even negative. | ||
} | ||
``` | ||
|
||
Time to see the final code: | ||
```javascript | ||
ModAPI.require("player"); | ||
|
||
function spiderHackUpdateCode() { | ||
if (ModAPI.player.isCollidedHorizontally) { | ||
ModAPI.player.motionY = 0.2; //Feel free to change this value to something bigger, smaller or even negative. | ||
} | ||
} | ||
ModAPI.addEventListener("update", spiderHackUpdateCode); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
## Step Hack with ModAPI | ||
A step hack allows a player to walk up full blocks (or more) as if they were slabs. | ||
|
||
Start by creating a new file in your code editor. Save it to a folder on your device, ensuring that the file extension is `.js`. | ||
|
||
Let's start by requiring the player. This will allow us to change attributes on the player: | ||
```javascript | ||
ModAPI.require("player"); | ||
``` | ||
|
||
Now, we have to detect when the player in a world. This will be done with the `update` event, which runs every tick while the player is in a world. In EaglerForge's ModAPI, to run code on an event, you have to create a function. Then, you register the function to an event. | ||
```javascript | ||
ModAPI.require("player"); | ||
|
||
function stepHackUpdateCode() { | ||
//We will add code here. | ||
} | ||
ModAPI.addEventListener("update", stepHackUpdateCode); | ||
``` | ||
|
||
Inside this method, lets change the player's `stepHeight`, which controls how high they can step. By default this is `0.5`, to alow players to walk up slabs or stairs. I'll change it to `2` for demonstration purposes. You can also try any other number, like `0`, `6`, etc. | ||
```javascript | ||
ModAPI.require("player"); | ||
|
||
function stepHackUpdateCode() { | ||
ModAPI.player.stepHeight = 2; | ||
} | ||
ModAPI.addEventListener("update", stepHackUpdateCode); | ||
``` | ||
|
||
Now, to load this mod, open your EaglerForge build, and in the start screen select `Upload Mod (.js)`. Upload the mod you created, and you should now be able to walk up two block tall pillars, or more depending on what `stepHeight` you selected. | ||
|
||
Disclaimer: using this on servers may get you banned/kicked for cheating! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.