Search in sources :

Example 6 with BlockLog

use of net.minecraft.block.BlockLog in project GregTech by GregTechCE.

the class TreeChopTask method isLogBlock.

public static int isLogBlock(IBlockState blockState) {
    if (blockState.getMaterial() == Material.AIR) {
        return 0;
    }
    if (blockState.getBlock() instanceof BlockLog) {
        return 1;
    } else if (blockState.getBlock() instanceof BlockLeaves) {
        return 2;
    }
    Item itemBlock = Item.getItemFromBlock(blockState.getBlock());
    ItemStack blockStack = new ItemStack(itemBlock, 1, blockState.getBlock().damageDropped(blockState));
    Set<String> blocks = OreDictUnifier.getOreDictionaryNames(blockStack);
    if (blocks.contains("logWood")) {
        return 1;
    } else if (blocks.contains("treeLeaves")) {
        return 2;
    } else
        return 0;
}
Also used : MetaToolValueItem(gregtech.api.items.toolitem.ToolMetaItem.MetaToolValueItem) Item(net.minecraft.item.Item) ToolMetaItem(gregtech.api.items.toolitem.ToolMetaItem) BlockLeaves(net.minecraft.block.BlockLeaves) BlockLog(net.minecraft.block.BlockLog) ItemStack(net.minecraft.item.ItemStack)

Example 7 with BlockLog

use of net.minecraft.block.BlockLog in project BetterWithAddons by DaedalusGame.

the class StumpingHandler method breakBlock.

@SubscribeEvent
public void breakBlock(PlayerEvent.BreakSpeed breakEvent) {
    World world = breakEvent.getEntity().getEntityWorld();
    BlockPos breakpos = breakEvent.getPos();
    IBlockState state = world.getBlockState(breakpos);
    Block block = state.getBlock();
    float speed = breakEvent.getNewSpeed();
    float multiplier = 1f;
    if (InteractionBTWTweak.HARD_STUMPS) {
        if (block instanceof BlockLog && state.getValue(BlockLog.LOG_AXIS) == BlockLog.EnumAxis.Y) {
            IBlockState bottomstate = world.getBlockState(breakpos.down());
            Material material = bottomstate.getMaterial();
            if (material == Material.GROUND || material == Material.GRASS)
                multiplier = (float) InteractionBTWTweak.HARD_STUMPS_MODIFIER;
        }
    }
    if (InteractionBTWTweak.SOFT_WOODS) {
        WoodHardness wood = getSoftWood(block, block.damageDropped(state));
        if (wood != null)
            multiplier = wood.hardness / state.getBlockHardness(world, breakpos);
    }
    breakEvent.setNewSpeed(speed * multiplier);
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) BlockLog(net.minecraft.block.BlockLog) Material(net.minecraft.block.material.Material) World(net.minecraft.world.World) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 8 with BlockLog

use of net.minecraft.block.BlockLog in project Realistic-Terrain-Generation by Team-RTG.

the class TreeRTGQuercusRobur method func_175937_a.

void func_175937_a(BlockPos p_175937_1_, BlockPos p_175937_2_, IBlockState p_175937_3_) {
    BlockPos blockpos = p_175937_2_.add(-p_175937_1_.getX(), -p_175937_1_.getY(), -p_175937_1_.getZ());
    int i = this.getGreatestDistance(blockpos);
    float f = (float) blockpos.getX() / (float) i;
    float f1 = (float) blockpos.getY() / (float) i;
    float f2 = (float) blockpos.getZ() / (float) i;
    for (int j = 0; j <= i; ++j) {
        BlockPos blockpos1 = p_175937_1_.add((double) (0.5F + (float) j * f), (double) (0.5F + (float) j * f1), (double) (0.5F + (float) j * f2));
        BlockLog.EnumAxis blocklog$enumaxis = this.func_175938_b(p_175937_1_, blockpos1);
        this.setBlockAndNotifyAdequately(this.world, blockpos1, p_175937_3_.withProperty(BlockLog.LOG_AXIS, blocklog$enumaxis));
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) BlockLog(net.minecraft.block.BlockLog)

Example 9 with BlockLog

use of net.minecraft.block.BlockLog in project takumicraft by TNTModders.

the class TakumiWorldGenBigTree method limb.

void limb(BlockPos p_175937_1_, BlockPos p_175937_2_, Block p_175937_3_) {
    BlockPos blockpos = p_175937_2_.add(-p_175937_1_.getX(), -p_175937_1_.getY(), -p_175937_1_.getZ());
    int i = this.getGreatestDistance(blockpos);
    float f = (float) blockpos.getX() / (float) i;
    float f1 = (float) blockpos.getY() / (float) i;
    float f2 = (float) blockpos.getZ() / (float) i;
    for (int j = 0; j <= i; ++j) {
        BlockPos blockpos1 = p_175937_1_.add((double) (0.5F + (float) j * f), (double) (0.5F + (float) j * f1), (double) (0.5F + (float) j * f2));
        if (this.log.getBlock() instanceof BlockLog) {
            EnumAxis blocklog$enumaxis = this.getLogAxis(p_175937_1_, blockpos1);
            this.setBlockAndNotifyAdequately(this.world, blockpos1, p_175937_3_.getDefaultState().withProperty(BlockLog.LOG_AXIS, blocklog$enumaxis));
        } else {
            this.setBlockAndNotifyAdequately(this.world, blockpos1, p_175937_3_.getDefaultState());
        }
    }
}
Also used : EnumAxis(net.minecraft.block.BlockLog.EnumAxis) BlockPos(net.minecraft.util.math.BlockPos) BlockLog(net.minecraft.block.BlockLog)

Aggregations

BlockLog (net.minecraft.block.BlockLog)9 BlockPos (net.minecraft.util.math.BlockPos)5 Block (net.minecraft.block.Block)4 BlockLeaves (net.minecraft.block.BlockLeaves)3 IBlockState (net.minecraft.block.state.IBlockState)2 ToolMetaItem (gregtech.api.items.toolitem.ToolMetaItem)1 MetaToolValueItem (gregtech.api.items.toolitem.ToolMetaItem.MetaToolValueItem)1 BlockBone (net.minecraft.block.BlockBone)1 BlockCrops (net.minecraft.block.BlockCrops)1 BlockDoor (net.minecraft.block.BlockDoor)1 BlockFence (net.minecraft.block.BlockFence)1 BlockFlower (net.minecraft.block.BlockFlower)1 BlockGrass (net.minecraft.block.BlockGrass)1 BlockIce (net.minecraft.block.BlockIce)1 BlockLever (net.minecraft.block.BlockLever)1 BlockLiquid (net.minecraft.block.BlockLiquid)1 EnumAxis (net.minecraft.block.BlockLog.EnumAxis)1 BlockMushroom (net.minecraft.block.BlockMushroom)1 BlockOre (net.minecraft.block.BlockOre)1 BlockPlanks (net.minecraft.block.BlockPlanks)1