Java Code Examples for net.minecraft.init.Blocks.LOG

The following are Jave code examples for showing how to use LOG of the net.minecraft.init.Blocks class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Bewitchment   File: HellsWrothBrew.java   View Source Code Vote up 6 votes
@Override
void safeImpact(BlockPos pos, @Nullable EnumFacing side, World world, int amplifier) {
	int box = 1 + (int) ((float) amplifier / 2F);

	BlockPos posI = pos.add(box, box, box);
	BlockPos posF = pos.add(-box, -box, -box);

	Iterable<BlockPos> spots = BlockPos.getAllInBox(posI, posF);
	for (BlockPos spot : spots) {
		Block block = world.getBlockState(spot).getBlock();
		IBlockState state = world.getBlockState(spot);
		boolean place = amplifier > 2 || world.rand.nextBoolean();
		if (place && stateMap.containsKey(block)) {
			world.setBlockState(spot, stateMap.get(block), 3);
		} else if (state.getBlock() == Blocks.LOG) {
			world.setBlockState(spot, ModBlocks.nethersteel.getDefaultState(), 3);
		} else if (state.getBlock() == Blocks.LOG2) {
			world.setBlockState(spot, ModBlocks.nethersteel.getDefaultState(), 3);
		}
	}
}
 
Example 2
Project: harshencastle   File: HarshenUtils.java   View Source Code Vote up 6 votes
public static BlockPos getTopBlock(World world, BlockPos pos)
{
	Chunk chunk = world.getChunkFromBlockCoords(pos);
       BlockPos blockpos;
       BlockPos blockpos1;

       for (blockpos = new BlockPos(pos.getX(), chunk.getTopFilledSegment() + 16, pos.getZ()); blockpos.getY() >= 0; blockpos = blockpos1)
       {
           blockpos1 = blockpos.down();
           IBlockState state = chunk.getBlockState(blockpos1);
           if ((state.getMaterial().blocksMovement() && !state.getBlock().isLeaves(state, world, blockpos1) && !state.getBlock().isFoliage(world, blockpos1) && state.getBlock() != Blocks.LOG
           		&& state.getBlock() != Blocks.LOG2) || state.getBlock() instanceof BlockLiquid)
           	break;
       }
       return blockpos;		
}
 
Example 3
Project: Bewitchment   File: HellWorldBrew.java   View Source Code Vote up 5 votes
@Override
public void safeImpact(BlockPos pos, @Nullable EnumFacing side, World world, int amplifier) {
	int box = 1 + (int) ((float) amplifier / 2F);

	BlockPos posI = pos.add(box, box, box);
	BlockPos posF = pos.add(-box, -box, -box);

	Iterable<BlockPos> spots = BlockPos.getAllInBox(posI, posF);
	for (BlockPos spot : spots) {
		Block block = world.getBlockState(spot).getBlock();
		IBlockState state = world.getBlockState(spot);
		boolean place = amplifier > 2 || world.rand.nextBoolean();
		if (BlockStairs.isBlockStairs(state)) {
			IBlockState newState = Blocks.NETHER_BRICK_STAIRS.getDefaultState()
					.withProperty(BlockStairs.FACING, state.getValue(BlockStairs.FACING))
					.withProperty(BlockStairs.HALF, state.getValue(BlockStairs.HALF));
			world.setBlockState(spot, newState);
		} else if (place && stateMap.containsKey(block)) {
			world.setBlockState(spot, stateMap.get(block), 3);
		} else if (state.getBlock() == Blocks.LOG) {
			world.setBlockState(spot, ModBlocks.nethersteel.getDefaultState(), 3);
		} else if (state.getBlock() == Blocks.LOG2) {
			world.setBlockState(spot, ModBlocks.nethersteel.getDefaultState(), 3);
		} else if (state.getBlock() == Blocks.BRICK_BLOCK) {
			world.setBlockState(spot, ModBlocks.scorned_bricks.getDefaultState(), 3);
		} else if (state.getBlock() == Blocks.STONEBRICK) {
			world.setBlockState(spot, ModBlocks.scorned_bricks.getDefaultState(), 3);
		} else if (state.getBlock() == Blocks.END_BRICKS) {
			world.setBlockState(spot, ModBlocks.scorned_bricks.getDefaultState(), 3);
		} else if (state.getBlock() == ModBlocks.embittered_bricks) {
			world.setBlockState(spot, ModBlocks.scorned_bricks.getDefaultState(), 3);
		} else if (state.getBlock() == ModBlocks.fake_ice_fence) {
			world.setBlockState(spot, Blocks.NETHER_BRICK_FENCE.getDefaultState(), 3);
		}
	}
}
 
Example 4
Project: modName   File: VillageBlocks.java   View Source Code Vote up 5 votes
@SubscribeEvent
public void onVillageBlocks(BiomeEvent.GetVillageBlockID event) {
    IBlockState original = event.getOriginal();

    if (event.getBiome() == ATGBiomes.TUNDRA) {
        if (original.getBlock() == Blocks.LOG || original.getBlock() == Blocks.LOG2) {
            event.setResult(Event.Result.DENY);
            event.setReplacement(Blocks.LOG.getDefaultState().withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.SPRUCE).withProperty(BlockLog.LOG_AXIS, original.getValue(BlockLog.LOG_AXIS)));
        } else if (original.getBlock() == Blocks.PLANKS) {
            event.setResult(Event.Result.DENY);
            event.setReplacement(Blocks.PLANKS.getDefaultState().withProperty(BlockPlanks.VARIANT, BlockPlanks.EnumType.SPRUCE));
        } else if (original.getBlock() == Blocks.OAK_STAIRS) {
            event.setResult(Event.Result.DENY);
            event.setReplacement(Blocks.SPRUCE_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, original.getValue(BlockStairs.FACING)));
        } else if (original.getBlock() == Blocks.OAK_FENCE) {
            event.setResult(Event.Result.DENY);
            event.setReplacement(Blocks.SPRUCE_FENCE.getDefaultState());
        }
    }
    else if (event.getBiome() == ATGBiomes.SCRUBLAND) {
        if (original.getBlock() == Blocks.LOG || original.getBlock() == Blocks.LOG2) {
            event.setResult(Event.Result.DENY);
            event.setReplacement(Blocks.LOG2.getDefaultState().withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.ACACIA).withProperty(BlockLog.LOG_AXIS, original.getValue(BlockLog.LOG_AXIS)));
        } else if (original.getBlock() == Blocks.PLANKS) {
            event.setResult(Event.Result.DENY);
            event.setReplacement(Blocks.PLANKS.getDefaultState().withProperty(BlockPlanks.VARIANT, BlockPlanks.EnumType.ACACIA));
        } else if (original.getBlock() == Blocks.OAK_STAIRS) {
            event.setResult(Event.Result.DENY);
            event.setReplacement(Blocks.ACACIA_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, original.getValue(BlockStairs.FACING)));
        } else if (original.getBlock() == Blocks.OAK_FENCE) {
            event.setResult(Event.Result.DENY);
            event.setReplacement(Blocks.ACACIA_FENCE.getDefaultState());
        }
    }
}
 
Example 5
Project: Backmemed   File: WorldGenBigTree.java   View Source Code Vote up 5 votes
/**
 * Places the trunk for the big tree that is being generated. Able to generate double-sized trunks by changing a
 * field that is always 1 to 2.
 */
void generateTrunk()
{
    BlockPos blockpos = this.basePos;
    BlockPos blockpos1 = this.basePos.up(this.height);
    Block block = Blocks.LOG;
    this.limb(blockpos, blockpos1, block);

    if (this.trunkSize == 2)
    {
        this.limb(blockpos.east(), blockpos1.east(), block);
        this.limb(blockpos.east().south(), blockpos1.east().south(), block);
        this.limb(blockpos.south(), blockpos1.south(), block);
    }
}
 
Example 6
Project: CustomWorldGen   File: WorldGenBigTree.java   View Source Code Vote up 5 votes
/**
 * Places the trunk for the big tree that is being generated. Able to generate double-sized trunks by changing a
 * field that is always 1 to 2.
 */
void generateTrunk()
{
    BlockPos blockpos = this.basePos;
    BlockPos blockpos1 = this.basePos.up(this.height);
    Block block = Blocks.LOG;
    this.limb(blockpos, blockpos1, block);

    if (this.trunkSize == 2)
    {
        this.limb(blockpos.east(), blockpos1.east(), block);
        this.limb(blockpos.east().south(), blockpos1.east().south(), block);
        this.limb(blockpos.south(), blockpos1.south(), block);
    }
}
 
Example 7
Project: Got-Wood   File: WorldGenBamboo.java   View Source Code Vote up 4 votes
protected boolean func_150523_a(Block block) {
	return (block.getMaterial(null) == Material.AIR) || (block.getMaterial(null) == Material.LEAVES) || (block == Blocks.GRASS) || (block == Blocks.DIRT) || (block == Blocks.LOG) || (block == Blocks.LOG2) || (block == Blocks.SAPLING) || (block == Blocks.VINE);
}
 
Example 8
Project: CharcoalPit   File: ItemsRegistry.java   View Source Code Vote up 4 votes
public static void initStacks(){
	coke_stack=new ItemStack(coke);
	ash_stack=new ItemStack(ash);
	wood_stack=new ItemStack(Blocks.LOG);
	thatch_stack=new ItemStack(Blocks.HAY_BLOCK);
}
 
Example 9
Project: Backmemed   File: WorldGenAbstractTree.java   View Source Code Vote up 4 votes
/**
 * returns whether or not a tree can grow into a block
 * For example, a tree will not grow into stone
 */
protected boolean canGrowInto(Block blockType)
{
    Material material = blockType.getDefaultState().getMaterial();
    return material == Material.AIR || material == Material.LEAVES || blockType == Blocks.GRASS || blockType == Blocks.DIRT || blockType == Blocks.LOG || blockType == Blocks.LOG2 || blockType == Blocks.SAPLING || blockType == Blocks.VINE;
}
 
Example 10
Project: Backmemed   File: ItemDye.java   View Source Code Vote up 4 votes
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
    ItemStack itemstack = stack.getHeldItem(pos);

    if (!stack.canPlayerEdit(worldIn.offset(hand), hand, itemstack))
    {
        return EnumActionResult.FAIL;
    }
    else
    {
        EnumDyeColor enumdyecolor = EnumDyeColor.byDyeDamage(itemstack.getMetadata());

        if (enumdyecolor == EnumDyeColor.WHITE)
        {
            if (applyBonemeal(itemstack, playerIn, worldIn))
            {
                if (!playerIn.isRemote)
                {
                    playerIn.playEvent(2005, worldIn, 0);
                }

                return EnumActionResult.SUCCESS;
            }
        }
        else if (enumdyecolor == EnumDyeColor.BROWN)
        {
            IBlockState iblockstate = playerIn.getBlockState(worldIn);
            Block block = iblockstate.getBlock();

            if (block == Blocks.LOG && iblockstate.getValue(BlockOldLog.VARIANT) == BlockPlanks.EnumType.JUNGLE)
            {
                if (hand == EnumFacing.DOWN || hand == EnumFacing.UP)
                {
                    return EnumActionResult.FAIL;
                }

                worldIn = worldIn.offset(hand);

                if (playerIn.isAirBlock(worldIn))
                {
                    IBlockState iblockstate1 = Blocks.COCOA.onBlockPlaced(playerIn, worldIn, hand, facing, hitX, hitY, 0, stack);
                    playerIn.setBlockState(worldIn, iblockstate1, 10);

                    if (!stack.capabilities.isCreativeMode)
                    {
                        itemstack.func_190918_g(1);
                    }

                    return EnumActionResult.SUCCESS;
                }
            }

            return EnumActionResult.FAIL;
        }

        return EnumActionResult.PASS;
    }
}
 
Example 11
Project: Backmemed   File: BlockCocoa.java   View Source Code Vote up 4 votes
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
    pos = pos.offset((EnumFacing)state.getValue(FACING));
    IBlockState iblockstate = worldIn.getBlockState(pos);
    return iblockstate.getBlock() == Blocks.LOG && iblockstate.getValue(BlockOldLog.VARIANT) == BlockPlanks.EnumType.JUNGLE;
}
 
Example 12
Project: CustomWorldGen   File: WorldGenAbstractTree.java   View Source Code Vote up 4 votes
/**
 * returns whether or not a tree can grow into a block
 * For example, a tree will not grow into stone
 */
protected boolean canGrowInto(Block blockType)
{
    Material material = blockType.getDefaultState().getMaterial();
    return material == Material.AIR || material == Material.LEAVES || blockType == Blocks.GRASS || blockType == Blocks.DIRT || blockType == Blocks.LOG || blockType == Blocks.LOG2 || blockType == Blocks.SAPLING || blockType == Blocks.VINE;
}
 
Example 13
Project: CustomWorldGen   File: ItemDye.java   View Source Code Vote up 4 votes
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    if (!playerIn.canPlayerEdit(pos.offset(facing), facing, stack))
    {
        return EnumActionResult.FAIL;
    }
    else
    {
        EnumDyeColor enumdyecolor = EnumDyeColor.byDyeDamage(stack.getMetadata());

        if (enumdyecolor == EnumDyeColor.WHITE)
        {
            if (applyBonemeal(stack, worldIn, pos, playerIn))
            {
                if (!worldIn.isRemote)
                {
                    worldIn.playEvent(2005, pos, 0);
                }

                return EnumActionResult.SUCCESS;
            }
        }
        else if (enumdyecolor == EnumDyeColor.BROWN)
        {
            IBlockState iblockstate = worldIn.getBlockState(pos);
            Block block = iblockstate.getBlock();

            if (block == Blocks.LOG && iblockstate.getValue(BlockOldLog.VARIANT) == BlockPlanks.EnumType.JUNGLE)
            {
                if (facing != EnumFacing.DOWN && facing != EnumFacing.UP)
                {
                    pos = pos.offset(facing);

                    if (worldIn.isAirBlock(pos))
                    {
                        IBlockState iblockstate1 = Blocks.COCOA.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, 0, playerIn, stack);
                        worldIn.setBlockState(pos, iblockstate1, 10);

                        if (!playerIn.capabilities.isCreativeMode)
                        {
                            --stack.stackSize;
                        }
                    }

                    return EnumActionResult.SUCCESS;
                }

                return EnumActionResult.FAIL;
            }

            return EnumActionResult.FAIL;
        }

        return EnumActionResult.PASS;
    }
}
 
Example 14
Project: CustomWorldGen   File: BlockCocoa.java   View Source Code Vote up 4 votes
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
    pos = pos.offset((EnumFacing)state.getValue(FACING));
    IBlockState iblockstate = worldIn.getBlockState(pos);
    return iblockstate.getBlock() == Blocks.LOG && iblockstate.getValue(BlockOldLog.VARIANT) == BlockPlanks.EnumType.JUNGLE;
}