Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package net.minecraft.server;
2
3import uk.betacraft.uberbukkit.UberbukkitConfig;
4
5public class ItemDye extends Item {
6
7 public static final String[] a = new String[] { "black", "red", "green", "brown", "blue", "purple", "cyan", "silver", "gray", "pink", "lime", "yellow", "lightBlue", "magenta", "orange", "white" };
8 public static final int[] bk = new int[] { 1973019, 11743532, 3887386, 5320730, 2437522, 8073150, 2651799, 2651799, 4408131, 14188952, 4312372, 14602026, 6719955, 12801229, 15435844, 15790320 };
9
10 public ItemDye(int i) {
11 super(i);
12 this.a(true);
13 this.d(0);
14 }
15
16 public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) {
17 if (itemstack.getData() == 15) {
18 int i1 = world.getTypeId(i, j, k);
19
20 if (i1 == Block.SAPLING.id) {
21 if (!world.isStatic) {
22 ((BlockSapling) Block.SAPLING).b(world, i, j, k, world.random);
23 --itemstack.count;
24 }
25
26 return true;
27 }
28
29 if (i1 == Block.CROPS.id) {
30 if (!world.isStatic) {
31 ((BlockCrops) Block.CROPS).d_(world, i, j, k);
32 --itemstack.count;
33 }
34
35 return true;
36 }
37
38 if (i1 == Block.GRASS.id && UberbukkitConfig.getInstance().getBoolean("mechanics.allow_bone_meal_on_grass", true)) {
39 if (!world.isStatic) {
40 --itemstack.count;
41
42 label53:
43 for (int j1 = 0; j1 < 128; ++j1) {
44 int k1 = i;
45 int l1 = j + 1;
46 int i2 = k;
47
48 for (int j2 = 0; j2 < j1 / 16; ++j2) {
49 k1 += b.nextInt(3) - 1;
50 l1 += (b.nextInt(3) - 1) * b.nextInt(3) / 2;
51 i2 += b.nextInt(3) - 1;
52 if (world.getTypeId(k1, l1 - 1, i2) != Block.GRASS.id || world.e(k1, l1, i2)) {
53 continue label53;
54 }
55 }
56
57 if (world.getTypeId(k1, l1, i2) == 0) {
58 // uberbukkit
59 if (UberbukkitConfig.getInstance().getBoolean("mechanics.allow_grow_tallgrass", true) && b.nextInt(10) != 0) {
60 world.setTypeIdAndData(k1, l1, i2, Block.LONG_GRASS.id, 1);
61 } else if (b.nextInt(3) != 0) {
62 world.setTypeId(k1, l1, i2, Block.YELLOW_FLOWER.id);
63 } else {
64 world.setTypeId(k1, l1, i2, Block.RED_ROSE.id);
65 }
66 }
67 }
68 }
69
70 return true;
71 }
72 }
73
74 return false;
75 }
76
77 public void a(ItemStack itemstack, EntityLiving entityliving) {
78 if (entityliving instanceof EntitySheep) {
79 EntitySheep entitysheep = (EntitySheep) entityliving;
80 int i = BlockCloth.c(itemstack.getData());
81
82 if (!entitysheep.isSheared() && entitysheep.getColor() != i) {
83 entitysheep.setColor(i);
84 --itemstack.count;
85 }
86 }
87 }
88}