2011-01-08 12:18:05 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start
|
2011-01-08 12:18:05 +01:00
|
|
|
import org.bukkit.craftbukkit.CraftBlock;
|
|
|
|
import org.bukkit.craftbukkit.CraftItemStack;
|
|
|
|
import org.bukkit.craftbukkit.CraftPlayer;
|
|
|
|
import org.bukkit.event.Event.Type;
|
|
|
|
import org.bukkit.event.player.PlayerItemEvent;
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2011-01-08 12:18:05 +01:00
|
|
|
|
|
|
|
public class ItemSeeds extends Item {
|
|
|
|
|
|
|
|
private int a;
|
|
|
|
|
|
|
|
public ItemSeeds(int i, int j) {
|
|
|
|
super(i);
|
|
|
|
a = j;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
|
|
|
|
if (l != 1) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
int i1 = world.a(i, j, k);
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
if (i1 == Block.aA.bi && world.e(i, j + 1, k)) {
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start - Seeds
|
2011-01-08 12:18:05 +01:00
|
|
|
CraftBlock blockClicked = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
|
|
|
|
CraftItemStack itemInHand = new CraftItemStack(itemstack);
|
|
|
|
CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
|
|
|
|
PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, CraftBlock.notchToBlockFace(l));
|
2011-01-11 09:25:13 +01:00
|
|
|
|
2011-01-08 12:18:05 +01:00
|
|
|
((WorldServer) world).getServer().getPluginManager().callEvent(pie);
|
2011-01-11 09:25:13 +01:00
|
|
|
|
|
|
|
if (pie.isCancelled()) {
|
2011-01-08 12:18:05 +01:00
|
|
|
return false;
|
|
|
|
}
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-01-14 14:31:10 +01:00
|
|
|
world.e(i, j + 1, k, a);
|
2011-01-11 09:25:13 +01:00
|
|
|
itemstack.a--;
|
|
|
|
return true;
|
2011-01-08 12:18:05 +01:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|