Sponge now removes water and obeys new 'sponge-radius' configuration variable.

This commit is contained in:
sk89q 2010-11-19 21:14:01 -08:00
parent 8983d7bc84
commit 6d0d2ee538
3 changed files with 39 additions and 10 deletions

View File

@ -1,4 +1,9 @@
1.2
- Sponge updated to remove water when the sponge block is set. Sponge radius
can now be controlled using the 'sponge-radius' parameter and the
default is now set to simulate Classic.
- Updated for a newer build of "b126," meaning that lava spread control
now works well!
- A new summary of the status of some core protections is now printed
on start. Disable this with 'summary-on-start'.
- Blacklist system has been overhauled. Check README.txt for changed

View File

@ -43,10 +43,13 @@ WorldGuard on your server. You can either restart your server or use
spread (preventing waterfalls from becoming tsunamis).
- simulate-sponge (def. false)
Toggle simulation of the sponge. The sponge only prevents water
from spreading. It will not take away existing water. Simulation of
the sponge requires iterating over a 9x9x9 cuboid around the water
block and the resource impact of this has not been quantified.
Toggle simulation of the sponge from Classic. It blocks water from
flowing near the sponge.
- sponge-radius (def. 3)
The radius of the sponge's effect. The default is that of Classic,
creating a 5x5x5 cuboid free of water. Increasing the number will
increase server load exponentially, although 3-5 has fairly low impact.
- enforce-single-session (def. true)
Enforce single sessions. If the player is already found to be on

View File

@ -70,6 +70,7 @@ public class WorldGuardListener extends PluginListener {
private boolean preventLavaFire;
private boolean disableAllFire;
private boolean simulateSponge;
private int spongeRadius;
private boolean blockLagFix;
private Set<Integer> fireNoSpreadBlocks;
private Set<Integer> allowedLavaSpreadOver;
@ -135,6 +136,7 @@ public void loadConfiguration() {
allowedLavaSpreadOver = toBlockIDSet(properties.getString("allowed-lava-spread-blocks", ""));
classicWater = properties.getBoolean("classic-water", false);
simulateSponge = properties.getBoolean("simulate-sponge", false);
spongeRadius = Math.max(1, properties.getInt("sponge-radius", 3)) - 1;
blockLagFix = properties.getBoolean("block-lag-fix", false);
// Console log configuration
@ -303,6 +305,25 @@ public void run() {
return true;
}
}
if (simulateSponge && blockPlaced.getType() == 19) {
int ox = blockPlaced.getX();
int oy = blockPlaced.getY();
int oz = blockPlaced.getZ();
Server server = etc.getServer();
for (int cx = -spongeRadius; cx <= spongeRadius; cx++) {
for (int cy = -spongeRadius; cy <= spongeRadius; cy++) {
for (int cz = -spongeRadius; cz <= spongeRadius; cz++) {
int id = server.getBlockIdAt(ox + cx, oy + cy, oz + cz);
if (id == 8 || id == 9) {
server.setBlockAt(0, ox + cx, oy + cy, oz + cz);
}
}
}
}
}
return false;
}
@ -582,15 +603,15 @@ public boolean onFlow(Block blockFrom, Block blockTo) {
boolean isLava = blockFrom.getType() == 10 || blockFrom.getType() == 11;
if (simulateSponge && isWater) {
int ox = blockFrom.getX();
int oy = blockFrom.getY() + 1;
int oz = blockFrom.getZ();
int ox = blockTo.getX();
int oy = blockTo.getY();
int oz = blockTo.getZ();
Server server = etc.getServer();
for (int cx = -4; cx <= 4; cx++) {
for (int cy = -4; cy <= 4; cy++) {
for (int cz = -4; cz <= 4; cz++) {
for (int cx = -spongeRadius; cx <= spongeRadius; cx++) {
for (int cy = -spongeRadius; cy <= spongeRadius; cy++) {
for (int cz = -spongeRadius; cz <= spongeRadius; cz++) {
if (server.getBlockIdAt(ox + cx, oy + cy, oz + cz) == 19) {
return true;
}