forked from retromcorg/Project-Poseidon
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Sponge and explosions optimizations
- Loading branch information
1 parent
2f10c2c
commit f9cf830
Showing
3 changed files
with
78 additions
and
63 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 |
---|---|---|
@@ -1,35 +1,42 @@ | ||
package net.minecraft.server; | ||
|
||
public class BlockSponge extends Block { | ||
import com.legacyminecraft.poseidon.PoseidonConfig; | ||
|
||
public class BlockSponge extends Block { | ||
protected BlockSponge(int i) { | ||
super(i, Material.SPONGE); | ||
this.textureId = 48; | ||
} | ||
|
||
public void c(World world, int i, int j, int k) { | ||
byte b0 = 2; | ||
public void remove(World world, int i, int j, int k) { | ||
byte radius = 2; | ||
|
||
for (int l = i - b0; l <= i + b0; ++l) { | ||
for (int i1 = j - b0; i1 <= j + b0; ++i1) { | ||
for (int j1 = k - b0; j1 <= k + b0; ++j1) { | ||
if (world.getMaterial(l, i1, j1) == Material.WATER) { | ||
; | ||
} | ||
if (PoseidonConfig.getInstance().getConfigBoolean("fix.optimize-sponges")) { | ||
this.optimizedRemove(world, i, j, k, radius); | ||
return; | ||
} | ||
|
||
for (int x = i - radius; x <= i + radius; ++x) { | ||
for (int y = j - radius; y <= j + radius; ++y) { | ||
for (int z = k - radius; z <= k + radius; ++z) { | ||
world.applyPhysics(x, y, z, world.getTypeId(x, y, z)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public void remove(World world, int i, int j, int k) { | ||
byte b0 = 2; | ||
private void optimizedRemove(World world, int i, int j, int k, byte radius) { | ||
for (int x = i - radius; x <= i + radius; ++x) { | ||
for (int y = j - radius; y <= j + radius; ++y) { | ||
if (y > 127 || y < 0) continue; | ||
|
||
for (int z = k - radius; z <= k + radius; ++z) { | ||
int type = world.getTypeId(x, y, z); | ||
if ((type != Block.WATER.id && type != Block.STATIONARY_WATER.id)) continue; | ||
|
||
for (int l = i - b0; l <= i + b0; ++l) { | ||
for (int i1 = j - b0; i1 <= j + b0; ++i1) { | ||
for (int j1 = k - b0; j1 <= k + b0; ++j1) { | ||
world.applyPhysics(l, i1, j1, world.getTypeId(l, i1, j1)); | ||
world.applyPhysics(x, y, z, type); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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