Search in sources :

Example 11 with TileEntityFlower

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

the class BlockFlower method canBlockStay.

public boolean canBlockStay(World world, BlockPos pos) {
    TileEntity tile = world.getTileEntity(pos);
    IBlockState downState = world.getBlockState(pos.down());
    if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).getSection() > 0) {
        return downState.getBlock() == ModuleFlowers.flower;
    }
    return canPlaceBlockOn(downState.getBlock());
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) TileEntityFlower(binnie.botany.tile.TileEntityFlower)

Example 12 with TileEntityFlower

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

the class BlockFlower method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
    super.onBlockPlacedBy(world, pos, state, placer, stack);
    IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
    TileEntity flower = world.getTileEntity(pos);
    if (world.isRemote) {
        if (flower != null && flower instanceof TileEntityFlower) {
            IFlower f = flowerRoot.getMember(stack);
            if (f != null) {
                ((TileEntityFlower) flower).setRender(new FlowerRenderInfo(f, (TileEntityFlower) flower));
            }
        }
        return;
    }
    TileEntity below = world.getTileEntity(pos.down());
    if (flower != null && flower instanceof TileEntityFlower) {
        if (below instanceof TileEntityFlower) {
            ((TileEntityFlower) flower).setSection(((TileEntityFlower) below).getSection());
        } else {
            GameProfile owner = (placer instanceof EntityPlayer) ? ((EntityPlayer) placer).getGameProfile() : null;
            ((TileEntityFlower) flower).create(stack, owner);
        }
    }
    flowerRoot.tryGrowSection(world, pos);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FlowerRenderInfo(binnie.botany.tile.FlowerRenderInfo) IFlower(binnie.botany.api.genetics.IFlower) GameProfile(com.mojang.authlib.GameProfile) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TileEntityFlower(binnie.botany.tile.TileEntityFlower) IFlowerRoot(binnie.botany.api.genetics.IFlowerRoot)

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