Search in sources :

Example 1 with ICrop

use of forestry.api.farming.ICrop in project PneumaticCraft by MineMaarten.

the class FarmablePlastic method getCropAt.

@Override
public ICrop getCropAt(World world, int x, int y, int z) {
    if (!isSaplingAt(world, x, y, z))
        return null;
    int meta = world.getBlockMetadata(x, y, z);
    return meta == 6 || meta == 13 ? new ICrop() {

        private World world;

        private int x, y, z;

        public ICrop setCoord(World world, int x, int y, int z) {
            this.world = world;
            this.x = x;
            this.y = y;
            this.z = z;
            return this;
        }

        @Override
        public Collection<ItemStack> harvest() {
            List<ItemStack> drops = world.getBlock(x, y, z).getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
            for (ItemStack drop : drops) {
                drop.setItemDamage(drop.getItemDamage() % 16);
            }
            world.func_147480_a(x, y, z, false);
            world.setBlockToAir(x, y, z);
            return drops;
        }
    }.setCoord(world, x, y, z) : null;
}
Also used : World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) ICrop(forestry.api.farming.ICrop)

Aggregations

ICrop (forestry.api.farming.ICrop)1 ItemStack (net.minecraft.item.ItemStack)1 World (net.minecraft.world.World)1