Search in sources :

Example 1 with Axis

use of net.minecraft.util.EnumFacing.Axis in project takumicraft by TNTModders.

the class BlockTakumiPortal method shouldSideBeRendered.

@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
    pos = pos.offset(side);
    Axis enumfacing$axis = null;
    if (blockState.getBlock() == this) {
        enumfacing$axis = blockState.getValue(AXIS);
        if (enumfacing$axis == null) {
            return false;
        }
        if (enumfacing$axis == Axis.Z && side != EnumFacing.EAST && side != EnumFacing.WEST) {
            return false;
        }
        if (enumfacing$axis == Axis.X && side != EnumFacing.SOUTH && side != EnumFacing.NORTH) {
            return false;
        }
    }
    boolean flag = blockAccess.getBlockState(pos.west()).getBlock() == this && blockAccess.getBlockState(pos.west(2)).getBlock() != this;
    boolean flag1 = blockAccess.getBlockState(pos.east()).getBlock() == this && blockAccess.getBlockState(pos.east(2)).getBlock() != this;
    boolean flag2 = blockAccess.getBlockState(pos.north()).getBlock() == this && blockAccess.getBlockState(pos.north(2)).getBlock() != this;
    boolean flag3 = blockAccess.getBlockState(pos.south()).getBlock() == this && blockAccess.getBlockState(pos.south(2)).getBlock() != this;
    boolean flag4 = flag || flag1 || enumfacing$axis == Axis.X;
    boolean flag5 = flag2 || flag3 || enumfacing$axis == Axis.Z;
    return flag4 && side == EnumFacing.WEST || flag4 && side == EnumFacing.EAST || flag5 && side == EnumFacing.NORTH || flag5 && side == EnumFacing.SOUTH;
}
Also used : Axis(net.minecraft.util.EnumFacing.Axis) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with Axis

use of net.minecraft.util.EnumFacing.Axis 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 Axis

use of net.minecraft.util.EnumFacing.Axis in project BuildCraft by BuildCraft.

the class VolumeSubCache method getValidConnections.

@Override
public ImmutableList<BlockPos> getValidConnections(BlockPos from) {
    VolumeConnection existing = getConnection(from);
    Set<Axis> taken = EnumSet.noneOf(EnumFacing.Axis.class);
    if (existing != null) {
        taken.addAll(existing.getConnectedAxis());
    }
    ImmutableList.Builder<BlockPos> valids = ImmutableList.builder();
    for (EnumFacing face : EnumFacing.VALUES) {
        if (taken.contains(face.getAxis()))
            continue;
        for (int i = 1; i <= BCCoreConfig.markerMaxDistance; i++) {
            BlockPos toTry = from.offset(face, i);
            if (hasLoadedOrUnloadedMarker(toTry)) {
                if (!canConnect(from, toTry))
                    break;
                valids.add(toTry);
                break;
            }
        }
    }
    return valids.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) Axis(net.minecraft.util.EnumFacing.Axis)

Example 4 with Axis

use of net.minecraft.util.EnumFacing.Axis in project BuildCraft by BuildCraft.

the class SchematicRotatedPillar method rotateLeft.

@Override
public void rotateLeft(IBuilderContext context) {
    EnumFacing.Axis axis = (Axis) state.getValue(BlockRotatedPillar.AXIS);
    EnumFacing.Axis newAxis = null;
    switch((EnumFacing.Axis) axis) {
        case X:
            {
                newAxis = EnumFacing.Axis.Z;
                break;
            }
        case Z:
            {
                newAxis = EnumFacing.Axis.X;
                break;
            }
        default:
            return;
    }
    state = state.withProperty(BlockRotatedPillar.AXIS, newAxis);
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) Axis(net.minecraft.util.EnumFacing.Axis) Axis(net.minecraft.util.EnumFacing.Axis)

Example 5 with Axis

use of net.minecraft.util.EnumFacing.Axis in project BuildCraft by BuildCraft.

the class PipeTransportRendererPower method render.

@Override
public void render(Pipe<PipeTransportPower> pipe, double x, double y, double z, float f) {
    PipeTransportPower pow = pipe.transport;
    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GlStateManager.disableLighting();
    // GL11.glEnable(GL11.GL_BLEND);
    GL11.glTranslatef((float) x, (float) y, (float) z);
    Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    // Used for the centre rendering
    double centerPower = 0;
    double[] power = new double[6];
    short[] flow = pow.displayFlow;
    for (int i = 0; i < 6; i++) {
        power[i] = pow.displayPowerAverage[i].getAverage();
        double d = power[i];
        if (d > centerPower) {
            centerPower = d;
        }
    }
    if (centerPower > 0) {
        long ms = System.currentTimeMillis();
        long diff = ms - pow.clientLastDisplayTime;
        if (pow.clientLastDisplayTime == 0 || diff <= 0) {
            diff = 1;
        }
        pow.clientLastDisplayTime = ms;
        for (int i = 0; i < 6; i++) {
            EnumFacing face = EnumFacing.values()[i];
            if (!pipe.getTile().isPipeConnected(face)) {
                continue;
            }
            double actualDiff = flow[i] * diff * FLOW_MULTIPLIER;
            double connectionDiff = face.getAxisDirection() == AxisDirection.POSITIVE ? actualDiff : -actualDiff;
            pow.clientDisplayFlow[i] += connectionDiff;
            while (pow.clientDisplayFlow[i] < 0) {
                pow.clientDisplayFlow[i] += 16;
            }
            while (pow.clientDisplayFlow[i] > 16) {
                pow.clientDisplayFlow[i] -= 16;
            }
            pow.clientDisplayFlowCentre = pow.clientDisplayFlowCentre.add(Utils.convert(face, actualDiff / 2));
            renderSidePower(face, power[i], pow.clientDisplayFlow[i], centerPower);
        }
        for (Axis axis : Axis.values()) {
            double value = VecUtil.getValue(pow.clientDisplayFlowCentre, axis);
            while (value < 0) {
                value += 16;
            }
            while (value > 16) {
                value -= 16;
            }
            pow.clientDisplayFlowCentre = VecUtil.replaceValue(pow.clientDisplayFlowCentre, axis, value);
        }
        renderCenterPower(centerPower, pow.clientDisplayFlowCentre);
    }
    GlStateManager.enableLighting();
    GL11.glPopAttrib();
    GL11.glPopMatrix();
}
Also used : PipeTransportPower(buildcraft.transport.PipeTransportPower) EnumFacing(net.minecraft.util.EnumFacing) Axis(net.minecraft.util.EnumFacing.Axis)

Aggregations

Axis (net.minecraft.util.EnumFacing.Axis)17 EnumFacing (net.minecraft.util.EnumFacing)13 Vec3d (net.minecraft.util.math.Vec3d)6 BlockPos (net.minecraft.util.math.BlockPos)4 ImmutableList (com.google.common.collect.ImmutableList)3 MutableQuad (buildcraft.lib.client.model.MutableQuad)2 AxisDirection (net.minecraft.util.EnumFacing.AxisDirection)2 PipeWire (buildcraft.api.transport.PipeWire)1 PatternParameterFacing (buildcraft.builders.snapshot.pattern.parameter.PatternParameterFacing)1 PatternParameterHollow (buildcraft.builders.snapshot.pattern.parameter.PatternParameterHollow)1 PatternParameterRotation (buildcraft.builders.snapshot.pattern.parameter.PatternParameterRotation)1 VolumeConnection (buildcraft.core.marker.VolumeConnection)1 UvFaceData (buildcraft.lib.client.model.ModelUtil.UvFaceData)1 PipeTransportPower (buildcraft.transport.PipeTransportPower)1 CaveVein (cavern.config.manager.CaveVein)1 ArrayList (java.util.ArrayList)1 BitSet (java.util.BitSet)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Tuple3f (javax.vecmath.Tuple3f)1