Skip to content

Commit

Permalink
Sponge & Explosion fixes by Cody
Browse files Browse the repository at this point in the history
  • Loading branch information
moderatorman committed Aug 9, 2024
1 parent cc77c44 commit 4eed931
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ private void write() {
generateConfigOption("command.tps.info", "Enables the /tps command to show the server's TPS for various intervals.");
generateConfigOption("command.tps.enabled", true);

//UberBukkit
generateConfigOption("fix.optimize-sponges", true);

//Tree Leave Destroy Blacklist
if (Boolean.valueOf(String.valueOf(getConfigOption("world.settings.block-tree-growth.enabled", true)))) {
if (String.valueOf(this.getConfigOption("world.settings.block-tree-growth.list", "")).trim().isEmpty()) {
Expand Down
37 changes: 22 additions & 15 deletions src/main/java/net/minecraft/server/BlockSponge.java
Original file line number Diff line number Diff line change
@@ -1,33 +1,40 @@
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);
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/net/minecraft/server/Explosion.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ public void a() {

this.size = f;

ArrayList<ChunkPosition> arraylist = new ArrayList<>(this.blocks);
ArrayList<ChunkPosition> arraylist = new ArrayList<>();
arraylist.addAll(this.blocks);

if (this.setFire) {
for (int l2 = arraylist.size() - 1; l2 >= 0; --l2) {
ChunkPosition chunkposition = arraylist.get(l2);
Expand Down Expand Up @@ -360,4 +362,4 @@ public int hashCode() {
}
}
// Paper end
}
}

0 comments on commit 4eed931

Please sign in to comment.