mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-23 06:01:38 -09:00
disable all particles doc
This commit is contained in:
parent
ea4b568b31
commit
18af63692c
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)
|
- A copy of the eaglercraft workspace (optional, get it at: https://git.eaglercraft.rip/eaglercraft/eaglercraft-1.8-workspace)
|
||||||
|
|
||||||
Tutorials:
|
Tutorials:
|
||||||
- [Disable All Particles](comingsoon)
|
- [Disable All Particles](disable_all_particles.md)
|
||||||
- [/hat mod](comingsoon)
|
- [/hat mod](comingsoon)
|
||||||
- [/spawnxp command](comingsoon)
|
- [/spawnxp command](comingsoon)
|
||||||
- [Slippery Mod](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.
|
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.
|
We'll also require the player, so the `ModAPI.player` global is generated.
|
||||||
|
|
||||||
```javascript
|
```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", "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", "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