summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server
diff options
context:
space:
mode:
authorEvilSeph <evilseph@unaligned.org>2011-06-17 14:48:20 -0400
committerEvilSeph <evilseph@unaligned.org>2011-06-17 22:19:43 -0400
commitd48e9c22f5ceb9d4d75756c2f4af78f0c9ff9f75 (patch)
treeceafaf0c8093fec829c97b4c54d2aff93afb8d86 /src/main/java/net/minecraft/server
parent22f26895eca8e99f795368a9a7167852c1805a1e (diff)
downloadcraftbukkit-d48e9c22f5ceb9d4d75756c2f4af78f0c9ff9f75.tar
craftbukkit-d48e9c22f5ceb9d4d75756c2f4af78f0c9ff9f75.tar.gz
craftbukkit-d48e9c22f5ceb9d4d75756c2f4af78f0c9ff9f75.tar.lz
craftbukkit-d48e9c22f5ceb9d4d75756c2f4af78f0c9ff9f75.tar.xz
craftbukkit-d48e9c22f5ceb9d4d75756c2f4af78f0c9ff9f75.zip
Added BlockSpread, BlockForm and BlockFade events.
Diffstat (limited to 'src/main/java/net/minecraft/server')
-rw-r--r--src/main/java/net/minecraft/server/BlockIce.java51
-rw-r--r--src/main/java/net/minecraft/server/BlockMushroom.java60
-rw-r--r--src/main/java/net/minecraft/server/BlockSnow.java102
-rw-r--r--src/main/java/net/minecraft/server/World.java18
4 files changed, 228 insertions, 3 deletions
diff --git a/src/main/java/net/minecraft/server/BlockIce.java b/src/main/java/net/minecraft/server/BlockIce.java
new file mode 100644
index 00000000..bdd7d660
--- /dev/null
+++ b/src/main/java/net/minecraft/server/BlockIce.java
@@ -0,0 +1,51 @@
+package net.minecraft.server;
+
+import java.util.Random;
+
+// CraftBukkit start
+import org.bukkit.block.BlockState;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.event.block.BlockFadeEvent;
+// CraftBukkit end
+
+public class BlockIce extends BlockBreakable {
+
+ public BlockIce(int i, int j) {
+ super(i, j, Material.ICE, false);
+ this.frictionFactor = 0.98F;
+ this.a(true);
+ }
+
+ public void remove(World world, int i, int j, int k) {
+ Material material = world.getMaterial(i, j - 1, k);
+
+ if (material.isSolid() || material.isLiquid()) {
+ world.setTypeId(i, j, k, Block.WATER.id);
+ }
+ }
+
+ public int a(Random random) {
+ return 0;
+ }
+
+ public void a(World world, int i, int j, int k, Random random) {
+ if (world.a(EnumSkyBlock.BLOCK, i, j, k) > 11 - Block.q[this.id]) {
+ // CraftBukkit start
+ CraftServer server = world.getServer();
+ CraftWorld cworld = world.getWorld();
+ BlockState blockState = cworld.getBlockAt(i, j, k).getState();
+ blockState.setTypeId(this.id);
+
+ BlockFadeEvent event = new BlockFadeEvent(cworld.getBlockAt(i, j, k), blockState);
+ server.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
+
+ this.b_(world, i, j, k, world.getData(i, j, k));
+ world.setTypeId(i, j, k, Block.STATIONARY_WATER.id);
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/BlockMushroom.java b/src/main/java/net/minecraft/server/BlockMushroom.java
new file mode 100644
index 00000000..b3381425
--- /dev/null
+++ b/src/main/java/net/minecraft/server/BlockMushroom.java
@@ -0,0 +1,60 @@
+package net.minecraft.server;
+
+import java.util.Random;
+
+// CraftBukkit start
+import org.bukkit.Location;
+import org.bukkit.Server;
+import org.bukkit.block.BlockState;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.event.block.BlockSpreadEvent;
+// CraftBukkit end
+
+public class BlockMushroom extends BlockFlower {
+
+ protected BlockMushroom(int i, int j) {
+ super(i, j);
+ float f = 0.2F;
+
+ this.a(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f);
+ this.a(true);
+ }
+
+ public void a(World world, int i, int j, int k, Random random) {
+ if (random.nextInt(100) == 0) {
+ int l = i + random.nextInt(3) - 1;
+ int i1 = j + random.nextInt(2) - random.nextInt(2);
+ int j1 = k + random.nextInt(3) - 1;
+
+ if (world.isEmpty(l, i1, j1) && this.f(world, l, i1, j1)) {
+ int k1 = i + (random.nextInt(3) - 1);
+
+ k1 = k + (random.nextInt(3) - 1);
+ if (world.isEmpty(l, i1, j1) && this.f(world, l, i1, j1)) {
+ // CraftBukkit start
+ Server server = world.getServer();
+ CraftWorld craftworld = world.getWorld();
+ BlockState blockState = craftworld.getBlockAt(l, i1, j1).getState();
+ blockState.setTypeId(this.id);
+
+ BlockSpreadEvent event = new BlockSpreadEvent(craftworld.getBlockAt(l, i1, j1), craftworld.getBlockAt(i, j, k), blockState);
+
+ server.getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ blockState.update(true);
+ }
+ // CraftBukkit end
+ }
+ }
+ }
+ }
+
+ protected boolean c(int i) {
+ return Block.o[i];
+ }
+
+ public boolean f(World world, int i, int j, int k) {
+ return j >= 0 && j < 128 ? world.j(i, j, k) < 13 && this.c(world.getTypeId(i, j - 1, k)) : false;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/BlockSnow.java b/src/main/java/net/minecraft/server/BlockSnow.java
new file mode 100644
index 00000000..bd5aad77
--- /dev/null
+++ b/src/main/java/net/minecraft/server/BlockSnow.java
@@ -0,0 +1,102 @@
+package net.minecraft.server;
+
+import java.util.Random;
+
+// CraftBukkit start
+import org.bukkit.block.BlockState;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.event.block.BlockFadeEvent;
+// CraftBukkit end
+
+public class BlockSnow extends Block {
+
+ protected BlockSnow(int i, int j) {
+ super(i, j, Material.SNOW_LAYER);
+ this.a(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
+ this.a(true);
+ }
+
+ public AxisAlignedBB d(World world, int i, int j, int k) {
+ int l = world.getData(i, j, k) & 7;
+
+ return l >= 3 ? AxisAlignedBB.b((double) i + this.minX, (double) j + this.minY, (double) k + this.minZ, (double) i + this.maxX, (double) ((float) j + 0.5F), (double) k + this.maxZ) : null;
+ }
+
+ public boolean a() {
+ return false;
+ }
+
+ public boolean b() {
+ return false;
+ }
+
+ public void a(IBlockAccess iblockaccess, int i, int j, int k) {
+ int l = iblockaccess.getData(i, j, k) & 7;
+ float f = (float) (2 * (1 + l)) / 16.0F;
+
+ this.a(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F);
+ }
+
+ public boolean canPlace(World world, int i, int j, int k) {
+ int l = world.getTypeId(i, j - 1, k);
+
+ return l != 0 && Block.byId[l].a() ? world.getMaterial(i, j - 1, k).isSolid() : false;
+ }
+
+ public void doPhysics(World world, int i, int j, int k, int l) {
+ this.g(world, i, j, k);
+ }
+
+ private boolean g(World world, int i, int j, int k) {
+ if (!this.canPlace(world, i, j, k)) {
+ this.b_(world, i, j, k, world.getData(i, j, k));
+ world.setTypeId(i, j, k, 0);
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ public void a(World world, EntityHuman entityhuman, int i, int j, int k, int l) {
+ int i1 = Item.SNOW_BALL.id;
+ float f = 0.7F;
+ double d0 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
+ double d1 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
+ double d2 = (double) (world.random.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
+ EntityItem entityitem = new EntityItem(world, (double) i + d0, (double) j + d1, (double) k + d2, new ItemStack(i1, 1, 0));
+
+ entityitem.pickupDelay = 10;
+ world.addEntity(entityitem);
+ world.setTypeId(i, j, k, 0);
+ entityhuman.a(StatisticList.C[this.id], 1);
+ }
+
+ public int a(int i, Random random) {
+ return Item.SNOW_BALL.id;
+ }
+
+ public int a(Random random) {
+ return 0;
+ }
+
+ public void a(World world, int i, int j, int k, Random random) {
+ if (world.a(EnumSkyBlock.BLOCK, i, j, k) > 11) {
+ // CraftBukkit start
+ CraftServer server = world.getServer();
+ CraftWorld cworld = world.getWorld();
+ BlockState blockState = cworld.getBlockAt(i, j, k).getState();
+ blockState.setTypeId(this.id);
+
+ BlockFadeEvent event = new BlockFadeEvent(cworld.getBlockAt(i, j, k), blockState);
+ server.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
+
+ this.b_(world, i, j, k, world.getData(i, j, k));
+ world.setTypeId(i, j, k, 0);
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 3493b906..b718f8c5 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -19,10 +19,13 @@ import org.bukkit.craftbukkit.event.CraftEventFactory;
import org.bukkit.event.block.BlockCanBuildEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.SnowFormEvent;
+import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.event.weather.ThunderChangeEvent;
+import org.bukkit.block.BlockState;
+import org.bukkit.craftbukkit.block.CraftBlockState;
// CraftBukkit end
public class World implements IBlockAccess {
@@ -1830,7 +1833,7 @@ public class World implements IBlockAccess {
i2 = chunk.getTypeId(l, k1, j1);
if (this.v() && i2 == 0 && Block.SNOW.canPlace(this, l + i, k1, j1 + j) && l1 != 0 && l1 != Block.ICE.id && Block.byId[l1].material.isSolid()) {
// CraftBukkit start
- SnowFormEvent snow = new SnowFormEvent(((WorldServer) this).getWorld().getBlockAt(l + i, k1, j1 + j));
+ SnowFormEvent snow = new SnowFormEvent(this.getWorld().getBlockAt(l + i, k1, j1 + j));
getServer().getPluginManager().callEvent(snow);
if (!snow.isCancelled()) {
@@ -1840,9 +1843,18 @@ public class World implements IBlockAccess {
// CraftBukkit end
}
- if (l1 == Block.STATIONARY_WATER.id && chunk.getData(l, k1 - 1, j1) == 0) {
- this.setTypeId(l + i, k1 - 1, j1 + j, Block.ICE.id);
+ // CraftBukkit start
+ if (l1 == Block.STATIONARY_WATER.id && chunk.getData(l, k1 - 1, j1) == 0) {
+ BlockState blockState = this.getWorld().getBlockAt(l + i, k1 - 1, j1 + j).getState();
+ blockState.setTypeId(Block.ICE.id);
+
+ BlockFormEvent iceBlockForm = new BlockFormEvent(this.getWorld().getBlockAt(l + i, k1 - 1, j1 + j), blockState);
+ this.getServer().getPluginManager().callEvent(iceBlockForm);
+ if (!iceBlockForm.isCancelled()) {
+ blockState.update(true);
+ }
}
+ // CraftBukkit end
}
}