craftbukkit/src/main/java/net/minecraft/server/ItemMobSpawner.java

34 lines
1.1 KiB
Java
Raw Normal View History

2011-09-26 03:07:06 -04:00
package net.minecraft.server;
2011-09-26 03:59:03 -04:00
// CraftBukkit start - the whole file!
2011-09-26 03:07:06 -04:00
public class ItemMobSpawner extends ItemWithAuxData {
2011-09-26 03:07:06 -04:00
2011-09-26 03:59:03 -04:00
public ItemMobSpawner(int id) {
super(id, Block.MOB_SPAWNER);
2011-09-26 03:07:06 -04:00
}
2011-09-26 03:59:03 -04:00
// interact
public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int x, int y, int z, int face) {
2011-09-26 03:07:06 -04:00
2011-09-26 03:59:03 -04:00
// super.interact (for ItemBlock this normally attempts to place it)
if (!super.a(itemstack, entityhuman, world, x, y, z, face)) return false;
2011-09-26 03:07:06 -04:00
2011-09-26 03:59:03 -04:00
// Adjust the coords for the face clicked.
if (face == 0) { y--; }
else if (face == 1) { y++; }
else if (face == 2) { z--; }
else if (face == 3) { z++; }
else if (face == 4) { x--; }
else if (face == 5) { x++; }
2011-09-26 03:07:06 -04:00
2011-09-26 03:59:03 -04:00
// Set the remembered datavalue for the spawner
TileEntity entity = world.getTileEntity(x, y, z);
2011-09-26 03:07:06 -04:00
if (entity instanceof TileEntityMobSpawner) {
2011-09-26 03:59:03 -04:00
((TileEntityMobSpawner) entity).setId(itemstack.getData());
2011-09-26 03:07:06 -04:00
return true;
}
2011-09-26 03:59:03 -04:00
return false;
2011-09-26 03:07:06 -04:00
}
}
2011-09-26 03:59:03 -04:00
// CraftBukkit end - the whole file!