mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-23 06:01:38 -09:00
Merge branch 'main' of https://github.com/eaglerforge/EaglerForgeInjector
This commit is contained in:
commit
f6742d0c59
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Eagler Forge
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
90
docs/tutorials/disable_all_particles.md
Normal file
90
docs/tutorials/disable_all_particles.md
Normal file
@ -0,0 +1,90 @@
|
||||
## Disable All Particles
|
||||
Particles in minecraft are really laggy, and there's a large chance you may want to disable them to boost your FPS when breaking blocks.
|
||||
|
||||
Let's look through the Eaglercraft 1.8 source code to find where particles are rendered. We can do this with a global search for `particle`. You'll find a lot of hits in the `EffectRenderer` class in the `net.minecraft.client.particle` package. We methods we'll want to patch are:
|
||||
- `renderParticles`
|
||||
- `addEffect`
|
||||
- `addBlockDestroyEffects`
|
||||
- `hasParticlesInAlphaLayer`
|
||||
|
||||
For the first 3 methods, you can see that they are defined something like:
|
||||
```java
|
||||
public void renderParticles() {
|
||||
// render particles code.
|
||||
}
|
||||
```
|
||||
The `void` in `public void` means that it does not expect a return value.
|
||||
Using [`ModAPI.util.getMethodFromPackage`](../apidoc/utils.md) we can find the compiled method name, and look for it in [`ModAPI.hooks.methods`](../apidoc/hooks.md#property-modapihooksmethods).
|
||||
|
||||
```javascript
|
||||
(function NoParticles() {
|
||||
//Basic, boilerplate code
|
||||
ModAPI.meta.title("No Particles");
|
||||
ModAPI.meta.description("Disables all particles in game");
|
||||
ModAPI.meta.credits("By <developer name>");
|
||||
|
||||
ModAPI.hooks.methods[
|
||||
ModAPI.util.getMethodFromPackage("net.minecraft.client.particle.EffectRenderer", "renderParticles")
|
||||
] = function () {}; //Override renderParticles in EffectRenderer to an empty function that does nothing.
|
||||
})();
|
||||
```
|
||||
|
||||
We can also do this for `addEffect` and `addBlockDestroyEffects`.
|
||||
|
||||
```javascript
|
||||
(function NoParticles() {
|
||||
//Basic, boilerplate code
|
||||
ModAPI.meta.title("No Particles");
|
||||
ModAPI.meta.description("Disables all particles in game");
|
||||
ModAPI.meta.credits("By <developer name>");
|
||||
|
||||
ModAPI.hooks.methods[
|
||||
ModAPI.util.getMethodFromPackage("net.minecraft.client.particle.EffectRenderer", "renderParticles")
|
||||
] = function () {}; //Override renderParticles in EffectRenderer with an empty function that does nothing.
|
||||
|
||||
ModAPI.hooks.methods[
|
||||
ModAPI.util.getMethodFromPackage("net.minecraft.client.particle.EffectRenderer", "addEffect")
|
||||
] = function () {}; //Override addEffect in EffectRenderer with an empty function that does nothing.
|
||||
|
||||
ModAPI.hooks.methods[
|
||||
ModAPI.util.getMethodFromPackage("net.minecraft.client.particle.EffectRenderer", "addBlockDestroyEffects")
|
||||
] = function () {}; //Override addBlockDestroyEffects in EffectRenderer with an empty function that does nothing.
|
||||
})();
|
||||
```
|
||||
|
||||
For `hasParticlesInAlphaLayer`, it doesn't use `void`, but instead a `boolean`.
|
||||
```java
|
||||
public boolean hasParticlesInAlphaLayer() {
|
||||
// hasParticlesInAlphaLayer code.
|
||||
}
|
||||
```
|
||||
When TeaVM translates booleans, it converts booleans to integers:
|
||||
- `false` turns into `0`
|
||||
- `true` turns into `1`
|
||||
|
||||
So when we override `hasParticlesInAlphaLayer`, we'll need to return a `0` or a `1`. Since we want the game to thing that there aren't any particles in the alpha layer, we'll return `0` (false).
|
||||
|
||||
```javascript
|
||||
(function NoParticles() {
|
||||
//Basic, boilerplate code
|
||||
ModAPI.meta.title("No Particles");
|
||||
ModAPI.meta.description("Disables all particles in game");
|
||||
ModAPI.meta.credits("By <developer name>");
|
||||
|
||||
ModAPI.hooks.methods[
|
||||
ModAPI.util.getMethodFromPackage("net.minecraft.client.particle.EffectRenderer", "renderParticles")
|
||||
] = function () {}; //Override renderParticles in EffectRenderer with an empty function that does nothing.
|
||||
|
||||
ModAPI.hooks.methods[
|
||||
ModAPI.util.getMethodFromPackage("net.minecraft.client.particle.EffectRenderer", "addEffect")
|
||||
] = function () {}; //Override addEffect in EffectRenderer with an empty function that does nothing.
|
||||
|
||||
ModAPI.hooks.methods[
|
||||
ModAPI.util.getMethodFromPackage("net.minecraft.client.particle.EffectRenderer", "addBlockDestroyEffects")
|
||||
] = function () {}; //Override addBlockDestroyEffects in EffectRenderer with an empty function that does nothing.
|
||||
|
||||
ModAPI.hooks.methods[
|
||||
ModAPI.util.getMethodFromPackage("net.minecraft.client.particle.EffectRenderer", "hasParticlesInAlphaLayer")
|
||||
] = function () {return 0}; //Override hasParticlesInAlphaLayer in EffectRenderer with a function that returns 0.
|
||||
})();
|
||||
```
|
@ -20,7 +20,7 @@ Prerequisites:
|
||||
- A copy of the eaglercraft workspace (optional, get it at: https://git.eaglercraft.rip/eaglercraft/eaglercraft-1.8-workspace)
|
||||
|
||||
Tutorials:
|
||||
- [Disable All Particles](comingsoon)
|
||||
- [Disable All Particles](disable_all_particles.md)
|
||||
- [/hat mod](comingsoon)
|
||||
- [/spawnxp command](comingsoon)
|
||||
- [Slippery Mod](comingsoon)
|
||||
|
@ -15,7 +15,7 @@ Example of the issue: if mod A and mod B both use `var myVariable = 0`, the valu
|
||||
This allows us to use variables without worrying about mod compatibility, as variables are scoped to the function.
|
||||
|
||||
\
|
||||
Then, we'll add some basic metadata for the mod loader (note that this is optional, but makes the mod look a lot better in the GUI once the game is loaded.)\
|
||||
Then, we'll add some basic [metadata](../apidoc/meta.md) for the mod loader (note that this is optional, but makes the mod look a lot better in the GUI once the game is loaded.)\
|
||||
We'll also require the player, so the `ModAPI.player` global is generated.
|
||||
|
||||
```javascript
|
||||
|
@ -1,4 +1,4 @@
|
||||
ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.client.particle.EffectRenderer", "renderParticles")] = ()=>{};
|
||||
ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.client.particle.EffectRenderer", "hasParticlesInAlphaLayer")] = ()=>{return 0};
|
||||
ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.client.particle.EffectRenderer", "addEffect")] = ()=>{};
|
||||
ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.client.particle.EffectRenderer", "addBlockDestroyEffects")] = ()=>{};
|
||||
ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.client.particle.EffectRenderer", "addBlockDestroyEffects")] = ()=>{};
|
||||
ModAPI.hooks.methods[ModAPI.util.getMethodFromPackage("net.minecraft.client.particle.EffectRenderer", "hasParticlesInAlphaLayer")] = ()=>{return 0};
|
Loading…
x
Reference in New Issue
Block a user