Search in sources :

Example 1 with TileEntityFlower

use of binnie.botany.tile.TileEntityFlower in project Binnie by ForestryMC.

the class BlockFlower method getActualState.

@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("deprecation")
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
    TileEntityFlower flower = TileUtil.getTile(world, pos, TileEntityFlower.class);
    if (flower != null && flower.getType() != null) {
        state = state.withProperty(FLOWER, flower.getType());
        state = state.withProperty(FLOWERED, flower.isFlowered());
        state = state.withProperty(SECTION, flower.getRenderSection());
        state = state.withProperty(SEED, flower.getAge() == 0);
    } else {
        state = state.withProperty(FLOWER, FlowerDefinition.Dandelion.getSpecies().getType());
        state = state.withProperty(FLOWERED, false);
        state = state.withProperty(SEED, false);
    }
    return state;
}
Also used : TileEntityFlower(binnie.botany.tile.TileEntityFlower) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with TileEntityFlower

use of binnie.botany.tile.TileEntityFlower in project Binnie by ForestryMC.

the class BlockFlower method updateTick.

@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileEntityFlower) {
        ((TileEntityFlower) tile).randomUpdate(rand);
        checkAndDropBlock(world, pos);
        return;
    }
    world.setBlockToAir(pos);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityFlower(binnie.botany.tile.TileEntityFlower)

Example 3 with TileEntityFlower

use of binnie.botany.tile.TileEntityFlower in project Binnie by ForestryMC.

the class GardenLogic method trySetCrop.

private boolean trySetCrop(World world, BlockPos position, FarmDirection direction, IFarmHousing housing) {
    for (IFarmable farmable : farmables) {
        if (!housing.plantGermling(farmable, world, position, direction)) {
            continue;
        }
        if (housing instanceof IOwnedTile) {
            TileEntity tile = world.getTileEntity(position);
            if (tile instanceof TileEntityFlower) {
                TileEntityFlower flower = (TileEntityFlower) tile;
                IOwnedTile owned = (IOwnedTile) housing;
                flower.setOwner(owned.getOwnerHandler().getOwner());
            }
        }
        return true;
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IFarmable(forestry.api.farming.IFarmable) IOwnedTile(forestry.core.owner.IOwnedTile) TileEntityFlower(binnie.botany.tile.TileEntityFlower)

Example 4 with TileEntityFlower

use of binnie.botany.tile.TileEntityFlower in project Binnie by ForestryMC.

the class FarmableFlower method getCropAt.

@Nullable
@Override
public ICrop getCropAt(World world, BlockPos pos, IBlockState blockState) {
    IFlower flower = null;
    if (world.getTileEntity(pos) instanceof TileEntityFlower) {
        flower = ((TileEntityFlower) world.getTileEntity(pos)).getFlower();
    }
    // TODO Look at TileEntityFlower::onShear logic
    if (flower != null && flower.getAge() > 1) {
        IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
        ItemStack mature = flowerRoot.getMemberStack(flower, EnumFlowerStage.FLOWER);
        ItemStack seed = flowerRoot.getMemberStack(flower, EnumFlowerStage.SEED);
        if (!mature.isEmpty() && !seed.isEmpty()) {
            world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
            return new FlowerCrop(pos, mature, seed);
        }
    }
    return null;
}
Also used : IFlower(binnie.botany.api.genetics.IFlower) TileEntityFlower(binnie.botany.tile.TileEntityFlower) ItemStack(net.minecraft.item.ItemStack) IFlowerRoot(binnie.botany.api.genetics.IFlowerRoot) Nullable(javax.annotation.Nullable)

Example 5 with TileEntityFlower

use of binnie.botany.tile.TileEntityFlower in project Binnie by ForestryMC.

the class FlowerRoot method plant.

public boolean plant(World world, BlockPos pos, IFlower flower, GameProfile owner) {
    boolean set = world.setBlockState(pos, ModuleFlowers.flower.getDefaultState());
    if (!set) {
        return false;
    }
    TileEntity tile = world.getTileEntity(pos);
    TileEntity below = world.getTileEntity(pos.down());
    if (tile != null && tile instanceof TileEntityFlower) {
        TileEntityFlower tileFlower = (TileEntityFlower) tile;
        if (below instanceof TileEntityFlower) {
            tileFlower.setSection(((TileEntityFlower) below).getSection());
        } else {
            tileFlower.create(flower, owner);
        }
    }
    tryGrowSection(world, pos);
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityFlower(binnie.botany.tile.TileEntityFlower)

Aggregations

TileEntityFlower (binnie.botany.tile.TileEntityFlower)12 TileEntity (net.minecraft.tileentity.TileEntity)9 IFlower (binnie.botany.api.genetics.IFlower)5 ItemStack (net.minecraft.item.ItemStack)3 IFlowerRoot (binnie.botany.api.genetics.IFlowerRoot)2 IBlockState (net.minecraft.block.state.IBlockState)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 BlockPos (net.minecraft.util.math.BlockPos)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 IFlowerGenome (binnie.botany.api.genetics.IFlowerGenome)1 FlowerRenderInfo (binnie.botany.tile.FlowerRenderInfo)1 MessageNBT (binnie.core.network.packet.MessageNBT)1 GameProfile (com.mojang.authlib.GameProfile)1 IFarmable (forestry.api.farming.IFarmable)1 IOwnedTile (forestry.core.owner.IOwnedTile)1 Nullable (javax.annotation.Nullable)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1