Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sponge & Explosion fixes by Cody #103

Merged
merged 2 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
Loading