2012-03-15 04:12:58 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
2012-07-22 08:18:00 +02:00
|
|
|
import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
|
|
|
|
|
2012-03-15 04:12:58 +01:00
|
|
|
public class BlockRedstoneOre extends Block {
|
|
|
|
|
|
|
|
private boolean a;
|
|
|
|
|
|
|
|
public BlockRedstoneOre(int i, int j, boolean flag) {
|
|
|
|
super(i, j, Material.STONE);
|
|
|
|
if (flag) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.b(true);
|
2012-03-15 04:12:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
this.a = flag;
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public int r_() {
|
2012-03-15 04:12:58 +01:00
|
|
|
return 30;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void attack(World world, int i, int j, int k, EntityHuman entityhuman) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.l(world, i, j, k);
|
2012-03-15 04:12:58 +01:00
|
|
|
super.attack(world, i, j, k, entityhuman);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void b(World world, int i, int j, int k, Entity entity) {
|
2012-03-15 04:15:22 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
if (entity instanceof EntityHuman) {
|
|
|
|
org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, i, j, k, -1, null);
|
|
|
|
if (!event.isCancelled()) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.l(world, i, j, k);
|
2012-03-15 04:15:22 +01:00
|
|
|
super.b(world, i, j, k, entity);
|
|
|
|
}
|
|
|
|
} else {
|
2012-07-22 08:18:00 +02:00
|
|
|
EntityInteractEvent event = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(i, j, k));
|
2012-03-15 04:15:22 +01:00
|
|
|
world.getServer().getPluginManager().callEvent(event);
|
|
|
|
if (!event.isCancelled()) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.l(world, i, j, k);
|
2012-03-15 04:15:22 +01:00
|
|
|
super.b(world, i, j, k, entity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2012-03-15 04:12:58 +01:00
|
|
|
}
|
|
|
|
|
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.l(world, i, j, k);
|
|
|
|
return super.interact(world, i, j, k, entityhuman, l, f, f1, f2);
|
2012-03-15 04:12:58 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
private void l(World world, int i, int j, int k) {
|
|
|
|
this.n(world, i, j, k);
|
2012-03-15 04:12:58 +01:00
|
|
|
if (this.id == Block.REDSTONE_ORE.id) {
|
|
|
|
world.setTypeId(i, j, k, Block.GLOWING_REDSTONE_ORE.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void b(World world, int i, int j, int k, Random random) {
|
2012-03-15 04:12:58 +01:00
|
|
|
if (this.id == Block.GLOWING_REDSTONE_ORE.id) {
|
|
|
|
world.setTypeId(i, j, k, Block.REDSTONE_ORE.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getDropType(int i, Random random, int j) {
|
|
|
|
return Item.REDSTONE.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getDropCount(int i, Random random) {
|
|
|
|
return this.a(random) + random.nextInt(i + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int a(Random random) {
|
|
|
|
return 4 + random.nextInt(2);
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void dropNaturally(World world, int i, int j, int k, int l, float f, int i1) {
|
|
|
|
super.dropNaturally(world, i, j, k, l, f, i1);
|
2012-08-08 13:23:43 +02:00
|
|
|
/* CraftBukkit start - delegate to getExpDrop
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.getDropType(l, world.random, i1) != this.id) {
|
|
|
|
int j1 = 1 + world.random.nextInt(5);
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
this.f(world, i, j, k, j1);
|
2012-08-08 13:23:43 +02:00
|
|
|
} */
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getExpDrop(World world, int l, int i1) {
|
|
|
|
if (this.getDropType(l, world.random, i1) != this.id) {
|
|
|
|
int j1 = 1 + world.random.nextInt(5);
|
|
|
|
|
|
|
|
return j1;
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
2012-08-08 13:23:43 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
// CraftBukkit end
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void n(World world, int i, int j, int k) {
|
2012-03-15 04:12:58 +01:00
|
|
|
Random random = world.random;
|
|
|
|
double d0 = 0.0625D;
|
|
|
|
|
|
|
|
for (int l = 0; l < 6; ++l) {
|
|
|
|
double d1 = (double) ((float) i + random.nextFloat());
|
|
|
|
double d2 = (double) ((float) j + random.nextFloat());
|
|
|
|
double d3 = (double) ((float) k + random.nextFloat());
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
if (l == 0 && !world.s(i, j + 1, k)) {
|
2012-03-15 04:12:58 +01:00
|
|
|
d2 = (double) (j + 1) + d0;
|
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
if (l == 1 && !world.s(i, j - 1, k)) {
|
2012-03-15 04:12:58 +01:00
|
|
|
d2 = (double) (j + 0) - d0;
|
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
if (l == 2 && !world.s(i, j, k + 1)) {
|
2012-03-15 04:12:58 +01:00
|
|
|
d3 = (double) (k + 1) + d0;
|
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
if (l == 3 && !world.s(i, j, k - 1)) {
|
2012-03-15 04:12:58 +01:00
|
|
|
d3 = (double) (k + 0) - d0;
|
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
if (l == 4 && !world.s(i + 1, j, k)) {
|
2012-03-15 04:12:58 +01:00
|
|
|
d1 = (double) (i + 1) + d0;
|
|
|
|
}
|
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
if (l == 5 && !world.s(i - 1, j, k)) {
|
2012-03-15 04:12:58 +01:00
|
|
|
d1 = (double) (i + 0) - d0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (d1 < (double) i || d1 > (double) (i + 1) || d2 < 0.0D || d2 > (double) (j + 1) || d3 < (double) k || d3 > (double) (k + 1)) {
|
2012-10-25 05:53:23 +02:00
|
|
|
world.addParticle("reddust", d1, d2, d3, 0.0D, 0.0D, 0.0D);
|
2012-03-15 04:12:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
protected ItemStack f_(int i) {
|
2012-03-15 04:12:58 +01:00
|
|
|
return new ItemStack(Block.REDSTONE_ORE);
|
|
|
|
}
|
|
|
|
}
|