Search in sources :

Example 1 with TileEntityCropSticks

use of com.infinityraider.agricraft.content.core.TileEntityCropSticks in project AgriCraft by AgriCraft.

the class ItemTrowel method tryPlantOnSoil.

protected ActionResultType tryPlantOnSoil(World world, BlockPos pos, ItemStack stack, @Nullable PlayerEntity player) {
    if (this.hasPlant(stack)) {
        BlockPos up = pos.up();
        TileEntity tile = world.getTileEntity(up);
        if (tile instanceof TileEntityCropSticks) {
            return this.tryPlantOnCropSticks((TileEntityCropSticks) tile, stack, player);
        }
        return this.tryNewPlant(world, up, stack, player);
    }
    return ActionResultType.FAIL;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityCropSticks(com.infinityraider.agricraft.content.core.TileEntityCropSticks) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with TileEntityCropSticks

use of com.infinityraider.agricraft.content.core.TileEntityCropSticks in project AgriCraft by AgriCraft.

the class ItemSeedBag method attemptPlantSeed.

protected boolean attemptPlantSeed(World world, BlockPos pos, Contents contents, @Nullable PlayerEntity player) {
    if (contents.getCount() > 0) {
        TileEntity tile = world.getTileEntity(pos);
        if (tile instanceof TileEntityCropSticks) {
            // Attempt to plant on crop sticks
            if (this.attemptPlantOnCrops((TileEntityCropSticks) tile, contents.extractFirstSeed(1, true), player)) {
                contents.extractFirstSeed(1, false);
                return true;
            }
        } else {
            BlockPos up = pos.up();
            tile = world.getTileEntity(up);
            if (tile instanceof TileEntityCropSticks) {
                // Attempt to plant above
                if (this.attemptPlantOnCrops((TileEntityCropSticks) tile, contents.extractFirstSeed(1, true), player)) {
                    contents.extractFirstSeed(1, false);
                    return true;
                }
            } else if (tile == null && AgriCraft.instance.getConfig().allowPlantingOutsideCropSticks()) {
                // Attempt to plant on soil
                if (this.attemptPlantOnSoil(world, pos, contents.extractFirstSeed(1, true), player)) {
                    contents.extractFirstSeed(1, false);
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityCropSticks(com.infinityraider.agricraft.content.core.TileEntityCropSticks) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

TileEntityCropSticks (com.infinityraider.agricraft.content.core.TileEntityCropSticks)2 TileEntity (net.minecraft.tileentity.TileEntity)2 BlockPos (net.minecraft.util.math.BlockPos)2