Search in sources :

Example 1 with TileLeaves

use of forestry.arboriculture.tiles.TileLeaves in project ForestryMC by ForestryMC.

the class ModelLeaves method getWorldKey.

@Override
protected Key getWorldKey(IBlockState state) {
    IExtendedBlockState stateExtended = (IExtendedBlockState) state;
    IBlockAccess world = stateExtended.getValue(UnlistedBlockAccess.BLOCKACCESS);
    BlockPos pos = stateExtended.getValue(UnlistedBlockPos.POS);
    boolean fancy = Proxies.render.fancyGraphicsEnabled();
    TextureMap map = Minecraft.getMinecraft().getTextureMapBlocks();
    if (world == null || pos == null) {
        return createEmptyKey(map, fancy);
    }
    TileLeaves tile = TileUtil.getTile(world, pos, TileLeaves.class);
    if (tile == null) {
        return createEmptyKey(map, fancy);
    }
    ResourceLocation leafLocation = tile.getLeaveSprite(fancy);
    ResourceLocation fruitLocation = tile.getFruitSprite();
    return new Key(map.getAtlasSprite(leafLocation.toString()), fruitLocation != null ? map.getAtlasSprite(fruitLocation.toString()) : null, fancy);
}
Also used : TextureMap(net.minecraft.client.renderer.texture.TextureMap) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) TileLeaves(forestry.arboriculture.tiles.TileLeaves) ResourceLocation(net.minecraft.util.ResourceLocation) IBlockAccess(net.minecraft.world.IBlockAccess) BlockPos(net.minecraft.util.math.BlockPos) UnlistedBlockPos(forestry.core.blocks.properties.UnlistedBlockPos)

Example 2 with TileLeaves

use of forestry.arboriculture.tiles.TileLeaves in project ForestryMC by ForestryMC.

the class ModelLeaves method getInventoryKey.

@Override
protected Key getInventoryKey(ItemStack itemStack) {
    TextureMap map = Minecraft.getMinecraft().getTextureMapBlocks();
    TileLeaves leaves = new TileLeaves();
    if (itemStack.getTagCompound() != null) {
        leaves.readFromNBT(itemStack.getTagCompound());
    } else {
        leaves.setTree(TreeRoot.treeTemplates.get(0));
    }
    boolean fancy = Proxies.render.fancyGraphicsEnabled();
    ResourceLocation leafLocation = leaves.getLeaveSprite(fancy);
    ResourceLocation fruitLocation = leaves.getFruitSprite();
    return new Key(map.getAtlasSprite(leafLocation.toString()), fruitLocation != null ? map.getAtlasSprite(fruitLocation.toString()) : null, fancy);
}
Also used : TextureMap(net.minecraft.client.renderer.texture.TextureMap) TileLeaves(forestry.arboriculture.tiles.TileLeaves) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 3 with TileLeaves

use of forestry.arboriculture.tiles.TileLeaves in project ForestryMC by ForestryMC.

the class ItemBlockLeaves method getColorFromItemstack.

@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemstack(ItemStack itemStack, int renderPass) {
    if (itemStack.getTagCompound() == null) {
        return ModuleArboriculture.proxy.getFoliageColorBasic();
    }
    TileLeaves tileLeaves = new TileLeaves();
    tileLeaves.readFromNBT(itemStack.getTagCompound());
    if (renderPass == BlockAbstractLeaves.FRUIT_COLOR_INDEX) {
        return tileLeaves.getFruitColour();
    } else {
        EntityPlayer player = Minecraft.getMinecraft().player;
        return tileLeaves.getFoliageColour(player);
    }
}
Also used : TileLeaves(forestry.arboriculture.tiles.TileLeaves) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with TileLeaves

use of forestry.arboriculture.tiles.TileLeaves in project ForestryMC by ForestryMC.

the class ItemBlockLeaves method getItemStackDisplayName.

@Override
public String getItemStackDisplayName(ItemStack itemstack) {
    if (itemstack.getTagCompound() == null) {
        return Translator.translateToLocal("trees.grammar.leaves.type");
    }
    TileLeaves tileLeaves = new TileLeaves();
    tileLeaves.readFromNBT(itemstack.getTagCompound());
    String unlocalizedName = tileLeaves.getUnlocalizedName();
    return getDisplayName(unlocalizedName);
}
Also used : TileLeaves(forestry.arboriculture.tiles.TileLeaves)

Example 5 with TileLeaves

use of forestry.arboriculture.tiles.TileLeaves in project ForestryMC by ForestryMC.

the class BlockForestryLeaves method onBlockActivated.

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    TileLeaves leaves = TileUtil.getTile(worldIn, pos, TileLeaves.class);
    if (leaves != null) {
        IButterfly caterpillar = leaves.getCaterpillar();
        ItemStack heldItem = playerIn.getHeldItem(hand);
        if (heldItem.getItem() instanceof IToolScoop && caterpillar != null) {
            ItemStack butterfly = ButterflyManager.butterflyRoot.getMemberStack(caterpillar, EnumFlutterType.CATERPILLAR);
            ItemStackUtil.dropItemStackAsEntity(butterfly, worldIn, pos);
            leaves.setCaterpillar(null);
            return true;
        }
    }
    return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
}
Also used : IButterfly(forestry.api.lepidopterology.IButterfly) TileLeaves(forestry.arboriculture.tiles.TileLeaves) IToolScoop(forestry.api.core.IToolScoop) ItemStack(net.minecraft.item.ItemStack)

Aggregations

TileLeaves (forestry.arboriculture.tiles.TileLeaves)7 TextureMap (net.minecraft.client.renderer.texture.TextureMap)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 ITree (forestry.api.arboriculture.ITree)1 IToolScoop (forestry.api.core.IToolScoop)1 IButterfly (forestry.api.lepidopterology.IButterfly)1 UnlistedBlockPos (forestry.core.blocks.properties.UnlistedBlockPos)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 BlockPos (net.minecraft.util.math.BlockPos)1 IBlockAccess (net.minecraft.world.IBlockAccess)1 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1