1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
package net.minecraft.server;
import java.util.Random;
public class BlockRedstoneOre extends Block {
private boolean a;
public BlockRedstoneOre(int i, int j, boolean flag) {
super(i, j, Material.STONE);
if (flag) {
this.a(true);
}
this.a = flag;
}
public int d() {
return 30;
}
public void attack(World world, int i, int j, int k, EntityHuman entityhuman) {
this.g(world, i, j, k);
super.attack(world, i, j, k, entityhuman);
}
public void b(World world, int i, int j, int k, Entity entity) {
// 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()) {
this.g(world, i, j, k);
super.b(world, i, j, k, entity);
}
} else {
org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(i, j, k));
world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.g(world, i, j, k);
super.b(world, i, j, k, entity);
}
}
// CraftBukkit end
}
public boolean interact(World world, int i, int j, int k, EntityHuman entityhuman) {
this.g(world, i, j, k);
return super.interact(world, i, j, k, entityhuman);
}
private void g(World world, int i, int j, int k) {
this.h(world, i, j, k);
if (this.id == Block.REDSTONE_ORE.id) {
world.setTypeId(i, j, k, Block.GLOWING_REDSTONE_ORE.id);
}
}
public void a(World world, int i, int j, int k, Random random) {
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);
}
private void h(World world, int i, int j, int k) {
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());
if (l == 0 && !world.r(i, j + 1, k)) {
d2 = (double) (j + 1) + d0;
}
if (l == 1 && !world.r(i, j - 1, k)) {
d2 = (double) (j + 0) - d0;
}
if (l == 2 && !world.r(i, j, k + 1)) {
d3 = (double) (k + 1) + d0;
}
if (l == 3 && !world.r(i, j, k - 1)) {
d3 = (double) (k + 0) - d0;
}
if (l == 4 && !world.r(i + 1, j, k)) {
d1 = (double) (i + 1) + d0;
}
if (l == 5 && !world.r(i - 1, j, k)) {
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)) {
world.a("reddust", d1, d2, d3, 0.0D, 0.0D, 0.0D);
}
}
}
protected ItemStack a_(int i) {
return new ItemStack(Block.REDSTONE_ORE);
}
}
|