Search in sources :

Example 1 with EnumAxis

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

the class TakumiWorldGenBigTree method getLogAxis.

private EnumAxis getLogAxis(BlockPos p_175938_1_, BlockPos p_175938_2_) {
    EnumAxis blocklog$enumaxis = EnumAxis.Y;
    int i = Math.abs(p_175938_2_.getX() - p_175938_1_.getX());
    int j = Math.abs(p_175938_2_.getZ() - p_175938_1_.getZ());
    int k = Math.max(i, j);
    if (k > 0) {
        if (i == k) {
            blocklog$enumaxis = EnumAxis.X;
        } else if (j == k) {
            blocklog$enumaxis = EnumAxis.Z;
        }
    }
    return blocklog$enumaxis;
}
Also used : EnumAxis(net.minecraft.block.BlockLog.EnumAxis)

Example 2 with EnumAxis

use of net.minecraft.block.BlockLog.EnumAxis in project MC-Prefab by Brian-Wuest.

the class BuildBlock method SetBlockState.

public static BuildBlock SetBlockState(StructureConfiguration configuration, World world, BlockPos originalPos, EnumFacing assumedNorth, BuildBlock block, Block foundBlock, IBlockState blockState, Structure structure) {
    try {
        if (!block.blockStateData.equals("")) {
            return BuildBlock.SetBlockStateFromTagData(configuration, world, originalPos, assumedNorth, block, foundBlock, blockState, structure);
        }
        EnumFacing vineFacing = BuildBlock.getVineFacing(configuration, foundBlock, block, structure.getClearSpace().getShape().getDirection());
        EnumAxis logFacing = BuildBlock.getLogFacing(configuration, foundBlock, block, structure.getClearSpace().getShape().getDirection());
        Axis boneFacing = BuildBlock.getBoneFacing(configuration, foundBlock, block, structure.getClearSpace().getShape().getDirection());
        BlockQuartz.EnumType quartzFacing = BuildBlock.getQuartsFacing(configuration, foundBlock, block, structure.getClearSpace().getShape().getDirection());
        EnumOrientation leverOrientation = BuildBlock.getLeverOrientation(configuration, foundBlock, block, structure.getClearSpace().getShape().getDirection());
        // If this block has custom processing for block state just continue onto the next block. The sub-class is expected to place the block.
        if (block.getProperties().size() > 0) {
            Collection<IProperty<?>> properties = blockState.getPropertyKeys();
            // applied.
            for (IProperty<?> property : properties) {
                BuildProperty buildProperty = block.getProperty(property.getName());
                // Make sure that this property exists in our file. The only way it wouldn't be there would be if a mod adds properties to vanilla blocks.
                if (buildProperty != null) {
                    try {
                        Optional<?> propertyValue = property.parseValue(buildProperty.getValue());
                        if (!propertyValue.isPresent() || propertyValue.getClass().getName().equals("com.google.common.base.Absent")) {
                            FMLLog.log.warn("Property value for property name [" + property.getName() + "] for block [" + block.getBlockName() + "] is considered Absent, figure out why.");
                            continue;
                        }
                        Comparable<?> comparable = property.getValueClass().cast(propertyValue.get());
                        if (comparable == null) {
                            continue;
                        }
                        comparable = BuildBlock.setComparable(comparable, foundBlock, property, configuration, block, assumedNorth, propertyValue, vineFacing, logFacing, boneFacing, quartzFacing, leverOrientation, structure);
                        if (comparable == null) {
                            continue;
                        }
                        try {
                            if (blockState.getValue(property) != comparable) {
                                blockState = BuildBlock.setProperty(blockState, property, comparable);
                            }
                        } catch (Exception ex) {
                            System.out.println("Error setting properly value for property name [" + property.getName() + "] property value [" + buildProperty.getValue() + "] for block [" + block.getBlockName() + "] The default value will be used.");
                        }
                    } catch (Exception ex) {
                        if (property != null && buildProperty != null) {
                            System.out.println("Error getting properly value for property name [" + property.getName() + "] property value [" + buildProperty.getValue() + "] for block [" + block.getBlockName() + "]");
                            throw ex;
                        }
                    }
                } else {
                // System.out.println("Property: [" + property.getName() + "] does not exist for Block: [" + block.getBlockName() + "] this is usually due to mods adding properties to vanilla blocks.");
                }
            }
        }
        block.setBlockState(blockState);
        return block;
    } catch (Exception ex) {
        System.out.println("Error setting block state for block [" + block.getBlockName() + "] for structure configuration class [" + configuration.getClass().getName() + "]");
        throw ex;
    }
}
Also used : EnumAxis(net.minecraft.block.BlockLog.EnumAxis) EnumFacing(net.minecraft.util.EnumFacing) BlockQuartz(net.minecraft.block.BlockQuartz) NBTException(net.minecraft.nbt.NBTException) IProperty(net.minecraft.block.properties.IProperty) EnumOrientation(net.minecraft.block.BlockLever.EnumOrientation) EnumAxis(net.minecraft.block.BlockLog.EnumAxis) Axis(net.minecraft.util.EnumFacing.Axis)

Example 3 with EnumAxis

use of net.minecraft.block.BlockLog.EnumAxis in project Minestuck by mraof.

the class LeaflessTreeDecorator method genBranch.

protected void genBranch(BlockPos pos0, BlockPos pos1, World world) {
    final int xDiff = pos1.getX() - pos0.getX();
    final int yDiff = pos1.getY() - pos0.getY();
    final int zDiff = pos1.getZ() - pos0.getZ();
    final int xLength = Math.abs(xDiff);
    final int yLength = Math.abs(yDiff);
    final int zLength = Math.abs(zDiff);
    int length;
    EnumAxis axis;
    if (xLength >= yLength && xLength >= zLength) {
        length = xLength;
        axis = EnumAxis.X;
    } else if (yLength >= xLength && yLength >= zLength) {
        length = yLength;
        axis = EnumAxis.Y;
    } else {
        length = zLength;
        axis = EnumAxis.Z;
    }
    IBlockState state = logState.withProperty(BlockLog.LOG_AXIS, axis);
    for (int i = 0; i < length; i++) {
        float f = i / (float) (length);
        BlockPos pos = pos0.add(xDiff * f, yDiff * f, zDiff * f);
        world.setBlockState(pos, state, 2);
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) EnumAxis(net.minecraft.block.BlockLog.EnumAxis) BlockPos(net.minecraft.util.math.BlockPos)

Example 4 with EnumAxis

use of net.minecraft.block.BlockLog.EnumAxis 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

EnumAxis (net.minecraft.block.BlockLog.EnumAxis)4 BlockPos (net.minecraft.util.math.BlockPos)2 EnumOrientation (net.minecraft.block.BlockLever.EnumOrientation)1 BlockLog (net.minecraft.block.BlockLog)1 BlockQuartz (net.minecraft.block.BlockQuartz)1 IProperty (net.minecraft.block.properties.IProperty)1 IBlockState (net.minecraft.block.state.IBlockState)1 NBTException (net.minecraft.nbt.NBTException)1 EnumFacing (net.minecraft.util.EnumFacing)1 Axis (net.minecraft.util.EnumFacing.Axis)1