2011-12-09 17:01:37 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-07-22 08:18:00 +02:00
|
|
|
// CraftBukkit start
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.entity.SheepDyeWoolEvent;
|
|
|
|
// CraftBukkit end
|
2011-12-09 17:11:56 +01:00
|
|
|
|
2011-12-09 17:01:37 +01:00
|
|
|
public class ItemDye extends Item {
|
|
|
|
|
|
|
|
public static final String[] a = new String[] { "black", "red", "green", "brown", "blue", "purple", "cyan", "silver", "gray", "pink", "lime", "yellow", "lightBlue", "magenta", "orange", "white"};
|
|
|
|
public static final int[] b = new int[] { 1973019, 11743532, 3887386, 5320730, 2437522, 8073150, 2651799, 2651799, 4408131, 14188952, 4312372, 14602026, 6719955, 12801229, 15435844, 15790320};
|
|
|
|
|
|
|
|
public ItemDye(int i) {
|
|
|
|
super(i);
|
|
|
|
this.a(true);
|
2012-01-14 21:03:48 +01:00
|
|
|
this.setMaxDurability(0);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a(CreativeModeTab.l);
|
2011-12-09 17:01:37 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public String c_(ItemStack itemstack) {
|
2011-12-09 17:01:37 +01:00
|
|
|
int i = MathHelper.a(itemstack.getData(), 0, 15);
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
return super.getName() + "." + a[i];
|
2011-12-09 17:01:37 +01:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) {
|
2012-10-25 05:53:23 +02:00
|
|
|
if (!entityhuman.a(i, j, k, l, itemstack)) {
|
2011-12-09 17:01:37 +01:00
|
|
|
return false;
|
|
|
|
} else {
|
2012-07-29 09:33:13 +02:00
|
|
|
int i1;
|
|
|
|
int j1;
|
2011-12-09 17:01:37 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (itemstack.getData() == 15) {
|
|
|
|
i1 = world.getTypeId(i, j, k);
|
2011-12-09 17:01:37 +01:00
|
|
|
if (i1 == Block.SAPLING.id) {
|
|
|
|
if (!world.isStatic) {
|
2012-01-12 12:02:39 +01:00
|
|
|
// CraftBukkit start
|
2012-01-14 23:02:10 +01:00
|
|
|
Player player = (entityhuman instanceof EntityPlayer) ? (Player) entityhuman.getBukkitEntity() : null;
|
2012-01-14 21:03:48 +01:00
|
|
|
((BlockSapling) Block.SAPLING).grow(world, i, j, k, world.random, true, player, itemstack);
|
2011-12-09 17:11:56 +01:00
|
|
|
//--itemstack.count; - called later if the bonemeal attempt was succesful
|
2012-01-12 12:02:39 +01:00
|
|
|
// CraftBukkit end
|
2011-12-09 17:01:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i1 == Block.BROWN_MUSHROOM.id || i1 == Block.RED_MUSHROOM.id) {
|
2012-01-12 12:02:39 +01:00
|
|
|
// CraftBukkit start
|
2011-12-09 17:11:56 +01:00
|
|
|
if (!world.isStatic) {
|
2012-01-14 23:02:10 +01:00
|
|
|
Player player = (entityhuman instanceof EntityPlayer) ? (Player) entityhuman.getBukkitEntity() : null;
|
2012-01-14 21:03:48 +01:00
|
|
|
((BlockMushroom) Block.byId[i1]).grow(world, i, j, k, world.random, true, player, itemstack);
|
2011-12-09 17:11:56 +01:00
|
|
|
//--itemstack.count; - called later if the bonemeal attempt was succesful
|
2012-01-12 12:02:39 +01:00
|
|
|
// CraftBukkit end
|
2011-12-09 17:01:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i1 == Block.MELON_STEM.id || i1 == Block.PUMPKIN_STEM.id) {
|
2012-07-29 09:33:13 +02:00
|
|
|
if (world.getData(i, j, k) == 7) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-12-09 17:01:37 +01:00
|
|
|
if (!world.isStatic) {
|
2012-07-29 09:33:13 +02:00
|
|
|
((BlockStem) Block.byId[i1]).l(world, i, j, k);
|
2011-12-09 17:01:37 +01:00
|
|
|
--itemstack.count;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
if (i1 > 0 && Block.byId[i1] instanceof BlockCrops) {
|
2012-07-29 09:33:13 +02:00
|
|
|
if (world.getData(i, j, k) == 7) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!world.isStatic) {
|
2012-10-25 05:53:23 +02:00
|
|
|
((BlockCrops) Block.byId[i1]).c_(world, i, j, k);
|
2012-07-29 09:33:13 +02:00
|
|
|
--itemstack.count;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i1 == Block.COCOA.id) {
|
2011-12-09 17:01:37 +01:00
|
|
|
if (!world.isStatic) {
|
2012-10-25 05:53:23 +02:00
|
|
|
world.setData(i, j, k, 8 | BlockDirectional.e(world.getData(i, j, k)));
|
2011-12-09 17:01:37 +01:00
|
|
|
--itemstack.count;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i1 == Block.GRASS.id) {
|
|
|
|
if (!world.isStatic) {
|
|
|
|
--itemstack.count;
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
label137:
|
2012-07-29 09:33:13 +02:00
|
|
|
for (j1 = 0; j1 < 128; ++j1) {
|
2011-12-09 17:01:37 +01:00
|
|
|
int k1 = i;
|
|
|
|
int l1 = j + 1;
|
|
|
|
int i2 = k;
|
|
|
|
|
|
|
|
for (int j2 = 0; j2 < j1 / 16; ++j2) {
|
2012-07-29 09:33:13 +02:00
|
|
|
k1 += d.nextInt(3) - 1;
|
|
|
|
l1 += (d.nextInt(3) - 1) * d.nextInt(3) / 2;
|
|
|
|
i2 += d.nextInt(3) - 1;
|
|
|
|
if (world.getTypeId(k1, l1 - 1, i2) != Block.GRASS.id || world.s(k1, l1, i2)) {
|
2012-10-25 05:53:23 +02:00
|
|
|
continue label137;
|
2011-12-09 17:01:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (world.getTypeId(k1, l1, i2) == 0) {
|
2012-07-29 09:33:13 +02:00
|
|
|
if (d.nextInt(10) != 0) {
|
|
|
|
if (Block.LONG_GRASS.d(world, k1, l1, i2)) {
|
|
|
|
world.setTypeIdAndData(k1, l1, i2, Block.LONG_GRASS.id, 1);
|
|
|
|
}
|
|
|
|
} else if (d.nextInt(3) != 0) {
|
|
|
|
if (Block.YELLOW_FLOWER.d(world, k1, l1, i2)) {
|
|
|
|
world.setTypeId(k1, l1, i2, Block.YELLOW_FLOWER.id);
|
|
|
|
}
|
|
|
|
} else if (Block.RED_ROSE.d(world, k1, l1, i2)) {
|
2011-12-09 17:01:37 +01:00
|
|
|
world.setTypeId(k1, l1, i2, Block.RED_ROSE.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else if (itemstack.getData() == 3) {
|
|
|
|
i1 = world.getTypeId(i, j, k);
|
|
|
|
j1 = world.getData(i, j, k);
|
|
|
|
if (i1 == Block.LOG.id && BlockLog.e(j1) == 3) {
|
|
|
|
if (l == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l == 1) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l == 2) {
|
|
|
|
--k;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l == 3) {
|
|
|
|
++k;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l == 4) {
|
|
|
|
--i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (l == 5) {
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (world.isEmpty(i, j, k)) {
|
|
|
|
world.setTypeId(i, j, k, Block.COCOA.id);
|
|
|
|
if (world.getTypeId(i, j, k) == Block.COCOA.id) {
|
|
|
|
Block.byId[Block.COCOA.id].postPlace(world, i, j, k, l, f, f1, f2);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
--itemstack.count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-09 17:01:37 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean a(ItemStack itemstack, EntityLiving entityliving) {
|
2011-12-09 17:01:37 +01:00
|
|
|
if (entityliving instanceof EntitySheep) {
|
|
|
|
EntitySheep entitysheep = (EntitySheep) entityliving;
|
2012-07-29 09:33:13 +02:00
|
|
|
int i = BlockCloth.e_(itemstack.getData());
|
2011-12-09 17:01:37 +01:00
|
|
|
|
|
|
|
if (!entitysheep.isSheared() && entitysheep.getColor() != i) {
|
2012-01-22 03:28:32 +01:00
|
|
|
// CraftBukkit start
|
2012-07-29 09:33:13 +02:00
|
|
|
byte bColor = (byte) i;
|
2012-07-22 08:18:00 +02:00
|
|
|
SheepDyeWoolEvent event = new SheepDyeWoolEvent((org.bukkit.entity.Sheep) entitysheep.getBukkitEntity(), org.bukkit.DyeColor.getByData(bColor));
|
2012-01-22 03:28:32 +01:00
|
|
|
entitysheep.world.getServer().getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
if (event.isCancelled()) {
|
2012-07-29 09:33:13 +02:00
|
|
|
return false;
|
2012-01-22 03:28:32 +01:00
|
|
|
}
|
|
|
|
|
2012-02-29 22:31:04 +01:00
|
|
|
i = (byte) event.getColor().getData();
|
2012-01-22 03:28:32 +01:00
|
|
|
// CraftBukkit end
|
2012-02-29 22:31:04 +01:00
|
|
|
|
|
|
|
entitysheep.setColor(i);
|
2011-12-09 17:01:37 +01:00
|
|
|
--itemstack.count;
|
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
2011-12-09 17:01:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|