2011-11-21 23:56:17 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
2012-07-22 08:18:00 +02:00
|
|
|
import org.bukkit.event.block.BlockFromToEvent; // CraftBukkit
|
|
|
|
|
2011-11-21 23:56:17 +01:00
|
|
|
public class BlockDragonEgg extends Block {
|
|
|
|
|
|
|
|
public BlockDragonEgg(int i, int j) {
|
|
|
|
super(i, j, Material.DRAGON_EGG);
|
|
|
|
}
|
|
|
|
|
2012-01-28 07:59:59 +01:00
|
|
|
public void onPlace(World world, int i, int j, int k) {
|
2012-07-29 09:33:13 +02:00
|
|
|
world.a(i, j, k, this.id, this.p_());
|
2011-11-21 23:56:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void doPhysics(World world, int i, int j, int k, int l) {
|
2012-07-29 09:33:13 +02:00
|
|
|
world.a(i, j, k, this.id, this.p_());
|
2011-11-21 23:56:17 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void b(World world, int i, int j, int k, Random random) {
|
|
|
|
this.l(world, i, j, k);
|
2011-11-21 23:56:17 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
private void l(World world, int i, int j, int k) {
|
2012-01-14 21:03:48 +01:00
|
|
|
if (BlockSand.canFall(world, i, j - 1, k) && j >= 0) {
|
2011-11-21 23:56:17 +01:00
|
|
|
byte b0 = 32;
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (!BlockSand.instaFall && world.c(i - b0, j - b0, k - b0, i + b0, j + b0, k + b0)) {
|
2011-11-21 23:56:17 +01:00
|
|
|
// CraftBukkit - added data
|
2011-11-30 00:17:43 +01:00
|
|
|
EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), this.id, world.getData(i, j, k));
|
2011-11-21 23:56:17 +01:00
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
world.addEntity(entityfallingblock);
|
2011-11-21 23:56:17 +01:00
|
|
|
} else {
|
|
|
|
world.setTypeId(i, j, k, 0);
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
while (BlockSand.canFall(world, i, j - 1, k) && j > 0) {
|
2011-11-21 23:56:17 +01:00
|
|
|
--j;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (j > 0) {
|
|
|
|
world.setTypeId(i, j, k, this.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman, int l, float f, float f1, float f2) {
|
|
|
|
this.n(world, i, j, k);
|
2011-11-21 23:56:17 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
public void attack(World world, int i, int j, int k, EntityHuman entityhuman) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.n(world, i, j, k);
|
2011-11-21 23:56:17 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
private void n(World world, int i, int j, int k) {
|
2011-11-21 23:56:17 +01:00
|
|
|
if (world.getTypeId(i, j, k) == this.id) {
|
|
|
|
if (!world.isStatic) {
|
|
|
|
for (int l = 0; l < 1000; ++l) {
|
|
|
|
int i1 = i + world.random.nextInt(16) - world.random.nextInt(16);
|
|
|
|
int j1 = j + world.random.nextInt(8) - world.random.nextInt(8);
|
|
|
|
int k1 = k + world.random.nextInt(16) - world.random.nextInt(16);
|
|
|
|
|
|
|
|
if (world.getTypeId(i1, j1, k1) == 0) {
|
2012-02-23 19:33:16 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
org.bukkit.block.Block from = world.getWorld().getBlockAt(i, j, k);
|
|
|
|
org.bukkit.block.Block to = world.getWorld().getBlockAt(i1, j1, k1);
|
2012-07-22 08:18:00 +02:00
|
|
|
BlockFromToEvent event = new BlockFromToEvent(from, to);
|
2012-02-23 19:33:16 +01:00
|
|
|
org.bukkit.Bukkit.getPluginManager().callEvent(event);
|
|
|
|
|
2012-07-22 08:18:00 +02:00
|
|
|
if (event.isCancelled()) {
|
|
|
|
return;
|
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
|
2012-07-22 08:18:00 +02:00
|
|
|
i1 = event.getToBlock().getX();
|
|
|
|
j1 = event.getToBlock().getY();
|
|
|
|
k1 = event.getToBlock().getZ();
|
2012-02-23 19:33:16 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-11-21 23:56:17 +01:00
|
|
|
world.setTypeIdAndData(i1, j1, k1, this.id, world.getData(i, j, k));
|
|
|
|
world.setTypeId(i, j, k, 0);
|
|
|
|
short short1 = 128;
|
|
|
|
|
|
|
|
for (int l1 = 0; l1 < short1; ++l1) {
|
|
|
|
double d0 = world.random.nextDouble();
|
|
|
|
float f = (world.random.nextFloat() - 0.5F) * 0.2F;
|
|
|
|
float f1 = (world.random.nextFloat() - 0.5F) * 0.2F;
|
|
|
|
float f2 = (world.random.nextFloat() - 0.5F) * 0.2F;
|
|
|
|
double d1 = (double) i1 + (double) (i - i1) * d0 + (world.random.nextDouble() - 0.5D) * 1.0D + 0.5D;
|
|
|
|
double d2 = (double) j1 + (double) (j - j1) * d0 + world.random.nextDouble() * 1.0D - 0.5D;
|
|
|
|
double d3 = (double) k1 + (double) (k - k1) * d0 + (world.random.nextDouble() - 0.5D) * 1.0D + 0.5D;
|
|
|
|
|
|
|
|
world.a("portal", d1, d2, d3, (double) f, (double) f1, (double) f2);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public int p_() {
|
2011-11-21 23:56:17 +01:00
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean d() {
|
2011-11-21 23:56:17 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean c() {
|
2011-11-21 23:56:17 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public int b() {
|
2011-11-21 23:56:17 +01:00
|
|
|
return 27;
|
|
|
|
}
|
|
|
|
}
|