From 708aa59569e819313fb5ecb32e17c8dfdff20fde Mon Sep 17 00:00:00 2001 From: radmanplays <95340057+radmanplays@users.noreply.github.com> Date: Sat, 2 Mar 2024 09:10:59 +0330 Subject: [PATCH 1/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b1a404d..d2bef45 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Eaglerforge v1 +# Eaglerforge v1 ### Play Minecraft 1.8 in your browser, supports singleplayer and multiplayer with a javascript modding api From fb9982d09a20cedcff8102f304466654852c474d Mon Sep 17 00:00:00 2001 From: radmanplays <95340057+radmanplays@users.noreply.github.com> Date: Sat, 2 Mar 2024 09:22:05 +0330 Subject: [PATCH 2/2] Create grapplehook.js --- ExampleMods/grapplehook.js | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 ExampleMods/grapplehook.js diff --git a/ExampleMods/grapplehook.js b/ExampleMods/grapplehook.js new file mode 100644 index 0000000..a2ec754 --- /dev/null +++ b/ExampleMods/grapplehook.js @@ -0,0 +1,42 @@ +ModAPI.require("player"); //Require the player +var GrappleHookMod = { + oldXYZ: [0, 0, 0], //The previous hook position. + prev: "NONE", //The previous state + scaleH: 0.25, //Used for X and Z velocity + scaleV: 0.15, //((Grapple Y) minus (Player Y)) times scaleV + lift: 0.4, //Base vertical motion + crouchToCancel: true //Whether or not crouching should disable the grappling hook. +}; +ModAPI.addEventListener("update", () => { //Every client tick + if (!ModAPI.player.fishEntity) { //If the fish hook does not exist. + if (GrappleHookMod.prev === "GROUND" && (!GrappleHookMod.crouchToCancel || !ModAPI.player.isSneaking())) { //If the old state was ground + GrappleHookMod.prev = "NONE"; //Update the state + var mx = GrappleHookMod.oldXYZ[0] - ModAPI.player.x; //Get delta X + var my = GrappleHookMod.oldXYZ[1] - ModAPI.player.y; //Get delta Y + var mz = GrappleHookMod.oldXYZ[2] - ModAPI.player.z; //Get delta Z + mx *= GrappleHookMod.scaleH; //Multiply by horizontal scale + my *= GrappleHookMod.scaleV; //Multiply by vertical scale + mz *= GrappleHookMod.scaleH; //Multiply by horizontal scale + ModAPI.player.motionX += mx; //Add x motion + ModAPI.player.motionY += my + GrappleHookMod.lift; //Add y motion, plus base lift. + ModAPI.player.motionZ += mz; //Add z motion + ModAPI.player.reload(); //Push changes + } else { + GrappleHookMod.prev = "NONE"; + } + } else if (GrappleHookMod.prev === "NONE") { //If the hook exists, but the previous state was NONE, update the state. + GrappleHookMod.prev = "AIR"; + } + if ( + ModAPI.player.fishEntity !== undefined && //If the fish hook exists + GrappleHookMod.prev === "AIR" && //And the hook was previously in the air + ModAPI.player.fishEntity.inGround //And the hook is in the ground + ) { + GrappleHookMod.oldXYZ = [ //Set old grapple hook position + ModAPI.player.fishEntity.x, + ModAPI.player.fishEntity.y, + ModAPI.player.fishEntity.z, + ]; + GrappleHookMod.prev = "GROUND";//Update state + } +});