summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/ItemMobSpawner.java
blob: 2f0a41861cc51cfe987431aa5065c229e12bac09 (plain)
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
package net.minecraft.server;
// CraftBukkit start - the whole file!

public class ItemMobSpawner extends ItemLog { // Actually not ItemLog but 'ItemUsingMetadata' orso.

    public  ItemMobSpawner(int id) {
        super(id, Block.MOB_SPAWNER);
    }

    // interact
    public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int x, int y, int z, int face) {

        // super.interact (for ItemBlock this normally attempts to place it)
        if (!super.a(itemstack, entityhuman, world, x, y, z, face)) return false;

        // 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++; }

        // Set the remembered datavalue for the spawner
        TileEntity entity = world.getTileEntity(x, y, z);
        if (entity instanceof TileEntityMobSpawner) {
            ((TileEntityMobSpawner) entity).setId(itemstack.getData());
            return true;
        }

        return false;
    }
}
// CraftBukkit end - the whole file!