fixed buttons, plates

added yield to explosion
added event for chunk unloading
This commit is contained in:
Tahg 2011-02-19 10:55:47 -05:00
parent d4b67c5549
commit ca4076077e
4 changed files with 39 additions and 13 deletions

View file

@ -167,7 +167,7 @@ public class BlockButton extends Block {
if (j1 == 0) { if (j1 == 0) {
return true; return true;
} else { } else {
//Allow the lever to change the current //Allow the button to change the current
int old = (j1 != 8) ? 1 : 0; int old = (j1 != 8) ? 1 : 0;
int current = (j1 == 8) ? 1 : 0; int current = (j1 == 8) ? 1 : 0;
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current); BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
@ -243,6 +243,14 @@ public class BlockButton extends Block {
int l = world.getData(i, j, k); int l = world.getData(i, j, k);
if ((l & 8) != 0) { if ((l & 8) != 0) {
// Craftbukkit start
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer server = ((WorldServer) world).getServer();
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 1, 0);
server.getPluginManager().callEvent(eventRedstone);
if(eventRedstone.getNewCurrent() > 0) return;
// Craftbukkit end
world.c(i, j, k, l & 7); world.c(i, j, k, l & 7);
world.h(i, j, k, this.id); world.h(i, j, k, this.id);
int i1 = l & 7; int i1 = l & 7;

View file

@ -4,7 +4,8 @@ import java.util.List;
import java.util.Random; import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.block.BlockFace;import org.bukkit.craftbukkit.CraftServer; import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.entity.CraftLivingEntity; import org.bukkit.craftbukkit.entity.CraftLivingEntity;
@ -115,6 +116,15 @@ public class BlockPressurePlate extends Block {
flag1 = true; flag1 = true;
} }
// Craftbukkit start
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer server = ((WorldServer) world).getServer();
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, flag ? 1 : 0, flag1 ? 1 : 0);
server.getPluginManager().callEvent(eventRedstone);
flag1 = eventRedstone.getNewCurrent() > 0;
// Craftbukkit end
if (flag1 && !flag) { if (flag1 && !flag) {
world.c(i, j, k, 1); world.c(i, j, k, 1);
world.h(i, j, k, this.id); world.h(i, j, k, this.id);

View file

@ -10,15 +10,17 @@ import java.util.Set;
// CraftBukkit start // CraftBukkit start
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.craftbukkit.CraftChunk; import org.bukkit.craftbukkit.CraftChunk;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event.Type; import org.bukkit.event.Event.Type;
import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
// CraftBukkit end // CraftBukkit end
public class ChunkProviderServer implements IChunkProvider { public class ChunkProviderServer implements IChunkProvider
{
public LongHashset a = new LongHashset(); // CraftBukkit public LongHashset a = new LongHashset(); // CraftBukkit
private Chunk b; private Chunk b;
private IChunkProvider c; private IChunkProvider c;
@ -39,7 +41,7 @@ public class ChunkProviderServer implements IChunkProvider {
return this.e.containsKey(i, j); return this.e.containsKey(i, j);
} }
// CraftBukkit end // CraftBukkit end
public void c(int i, int j) { public void c(int i, int j) {
int k = i * 16 + 8 - this.g.spawnX; int k = i * 16 + 8 - this.g.spawnX;
int l = j * 16 + 8 - this.g.spawnZ; int l = j * 16 + 8 - this.g.spawnZ;
@ -197,16 +199,22 @@ public class ChunkProviderServer implements IChunkProvider {
public boolean a() { public boolean a() {
if (!this.g.C) { if (!this.g.C) {
// CraftBukkit start // CraftBukkit start
Server server = g.getServer();
while (!this.a.isEmpty()) { while (!this.a.isEmpty()) {
long chunkcoordinates = this.a.popFirst(); long chunkcoordinates = this.a.popFirst();
Chunk chunk = e.get(chunkcoordinates); Chunk chunk = e.get(chunkcoordinates);
if (chunk == null) continue; if (chunk == null) {
chunk.e(); continue;
this.b(chunk); }
this.a(chunk); ChunkUnloadEvent cue = new ChunkUnloadEvent(Type.CHUNK_UNLOADED, chunk.bukkitChunk);
this.a.remove(chunkcoordinates); server.getPluginManager().callEvent(cue);
this.e.remove(chunkcoordinates); if (!cue.isCancelled()) {
this.f.remove(chunk); chunk.e();
this.b(chunk);
this.a(chunk);
this.e.remove(chunkcoordinates);
this.f.remove(chunk);
}
} }
// CraftBukkit end // CraftBukkit end

View file

@ -240,7 +240,7 @@ public class Explosion {
} }
if (i1 > 0) { if (i1 > 0) {
Block.byId[i1].a(this.i, j, k, l, this.i.getData(j, k, l), 0.3F); Block.byId[i1].a(this.i, j, k, l, this.i.getData(j, k, l), event.getYield()); //Modified by Craftbukkit
this.i.e(j, k, l, 0); this.i.e(j, k, l, 0);
Block.byId[i1].a_(this.i, j, k, l); Block.byId[i1].a_(this.i, j, k, l);
} }