Search in sources :

Example 6 with Axis

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

the class RenderResizableCuboid method bakeCuboidFace.

private static void bakeCuboidFace(List<MutableQuad> quads, EntityResizableCuboid cuboid, EnumFacing face, TextureAtlasSprite[] sprites, int[] flips, Vec3d textureStart, Vec3d textureSize, Vec3d size, Vec3d textureOffset, boolean out, boolean in) {
    int ordinal = face.ordinal();
    if (sprites[ordinal] == null) {
        return;
    }
    Vec3d textureEnd = textureStart.add(textureSize);
    float[] uv = getUVArray(sprites[ordinal], flips[ordinal], face, textureStart, textureEnd);
    List<RenderInfo> renderInfoList = getRenderInfos(uv, face, size, textureSize, textureOffset);
    Axis u = face.getAxis() == Axis.X ? Axis.Z : Axis.X;
    Axis v = face.getAxis() == Axis.Y ? Axis.Z : Axis.Y;
    double other = face.getAxisDirection() == AxisDirection.POSITIVE ? VecUtil.getValue(size, face.getAxis()) : 0;
    /* Swap the face if this is positive: the renderer returns indexes that ALWAYS are for the negative face, so
         * light it properly this way */
    // face = face.getAxisDirection() == AxisDirection.NEGATIVE ? face : face.getOpposite();
    EnumFacing opposite = face.getOpposite();
    boolean flip = ModelUtil.shouldInvertForRender(face);
    for (RenderInfo ri : renderInfoList) {
        ri = ri.offset(cuboid, face.getAxis());
        double otherMoved = other + VecUtil.getValue(cuboid.getPositionVector(), face.getAxis());
        if (flip ? out : in) {
            MutableQuad mutable = new MutableQuad(-1, face);
            bakePoint(mutable.vertex_0, face, u, v, otherMoved, ri, true, false);
            bakePoint(mutable.vertex_1, face, u, v, otherMoved, ri, true, true);
            bakePoint(mutable.vertex_2, face, u, v, otherMoved, ri, false, true);
            bakePoint(mutable.vertex_3, face, u, v, otherMoved, ri, false, false);
            quads.add(mutable);
        }
        if (flip ? in : out) {
            MutableQuad mutable = new MutableQuad(-1, face);
            bakePoint(mutable.vertex_0, opposite, u, v, otherMoved, ri, false, false);
            bakePoint(mutable.vertex_1, opposite, u, v, otherMoved, ri, false, true);
            bakePoint(mutable.vertex_2, opposite, u, v, otherMoved, ri, true, true);
            bakePoint(mutable.vertex_3, opposite, u, v, otherMoved, ri, true, false);
            quads.add(mutable);
        }
    }
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) Vec3d(net.minecraft.util.math.Vec3d) Axis(net.minecraft.util.EnumFacing.Axis) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 7 with Axis

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

the class RenderMarkerVolume method render.

@Override
public void render(TileMarkerVolume marker, double tileX, double tileY, double tileZ, float partialTicks, int destroyStage, float alpha) {
    if (marker == null || !marker.isShowingSignals())
        return;
    Minecraft.getMinecraft().mcProfiler.startSection("bc");
    Minecraft.getMinecraft().mcProfiler.startSection("marker");
    Minecraft.getMinecraft().mcProfiler.startSection("volume");
    DetachedRenderer.fromWorldOriginPre(Minecraft.getMinecraft().player, partialTicks);
    RenderHelper.disableStandardItemLighting();
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    VolumeConnection volume = marker.getCurrentConnection();
    Set<Axis> taken = volume == null ? ImmutableSet.of() : volume.getConnectedAxis();
    Vec3d start = VecUtil.add(VEC_HALF, marker.getPos());
    for (EnumFacing face : EnumFacing.VALUES) {
        if (taken.contains(face.getAxis())) {
            continue;
        }
        Vec3d end = VecUtil.offset(start, face, BCCoreConfig.markerMaxDistance);
        renderLaser(start, end, face.getAxis());
    }
    RenderHelper.enableStandardItemLighting();
    DetachedRenderer.fromWorldOriginPost();
    Minecraft.getMinecraft().mcProfiler.endSection();
    Minecraft.getMinecraft().mcProfiler.endSection();
    Minecraft.getMinecraft().mcProfiler.endSection();
}
Also used : VolumeConnection(buildcraft.core.marker.VolumeConnection) EnumFacing(net.minecraft.util.EnumFacing) Axis(net.minecraft.util.EnumFacing.Axis) Vec3d(net.minecraft.util.math.Vec3d)

Example 8 with Axis

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

the class VolumeConnection method canMergeWith.

public boolean canMergeWith(VolumeConnection other) {
    EnumSet<Axis> us = getConnectedAxis();
    EnumSet<Axis> them = other.getConnectedAxis();
    if (us.size() != 1 || them.size() != 1) {
        return false;
    }
    if (us.equals(them)) {
        return false;
    }
    Set<Axis> blacklisted = EnumSet.copyOf(us);
    blacklisted.addAll(them);
    for (BlockPos from : makeup) {
        for (BlockPos to : other.makeup) {
            EnumFacing offset = PositionUtil.getDirectFacingOffset(from, to);
            if (offset != null && !blacklisted.contains(offset.getAxis())) {
                return true;
            }
        }
    }
    return false;
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) Axis(net.minecraft.util.EnumFacing.Axis)

Example 9 with Axis

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

the class TileFloodGate method buildQueue.

private void buildQueue() {
    world.profiler.startSection("prepare");
    queue.clear();
    paths.clear();
    if (tank.isEmpty()) {
        world.profiler.endSection();
        return;
    }
    Set<BlockPos> checked = new HashSet<>();
    checked.add(pos);
    List<BlockPos> nextPosesToCheck = new ArrayList<>();
    for (EnumFacing face : openSides) {
        BlockPos offset = pos.offset(face);
        nextPosesToCheck.add(offset);
        paths.put(offset, ImmutableList.of(offset));
    }
    world.profiler.endStartSection("build");
    outer: while (!nextPosesToCheck.isEmpty()) {
        List<BlockPos> nextPosesToCheckCopy = new ArrayList<>(nextPosesToCheck);
        nextPosesToCheck.clear();
        for (BlockPos toCheck : nextPosesToCheckCopy) {
            if (toCheck.distanceSq(pos) > 64 * 64) {
                continue;
            }
            if (checked.add(toCheck)) {
                if (canSearch(toCheck)) {
                    if (canFill(toCheck)) {
                        queue.push(toCheck);
                        if (queue.size() >= 4096) {
                            break outer;
                        }
                    }
                    List<BlockPos> checkPath = paths.get(toCheck);
                    for (EnumFacing side : SEARCH_DIRECTIONS) {
                        BlockPos next = toCheck.offset(side);
                        if (!openSides.contains(side)) {
                            Axis axis = side.getAxis();
                            int dist = VecUtil.getValue(next, axis) - VecUtil.getValue(getPos(), axis);
                            if (side.getAxisDirection() == AxisDirection.NEGATIVE) {
                                dist = -dist;
                            }
                            if (dist > 0) {
                                continue;
                            }
                        }
                        if (checked.contains(next)) {
                            continue;
                        }
                        ImmutableList.Builder<BlockPos> pathBuilder = ImmutableList.builder();
                        pathBuilder.addAll(checkPath);
                        pathBuilder.add(next);
                        paths.put(next, pathBuilder.build());
                        nextPosesToCheck.add(next);
                    }
                }
            }
        }
    }
    world.profiler.endSection();
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) ArrayList(java.util.ArrayList) BlockPos(net.minecraft.util.math.BlockPos) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) Axis(net.minecraft.util.EnumFacing.Axis) HashSet(java.util.HashSet)

Example 10 with Axis

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

the class PipeWireRenderer method getQuads.

private static MutableQuad[] getQuads(EnumWireBetween between) {
    // 4 rather than 6 -- don't render the end caps
    MutableQuad[] quads = new MutableQuad[4];
    int i = 0;
    Vec3d center;
    Vec3d radius;
    boolean ax = between.mainAxis == Axis.X;
    boolean ay = between.mainAxis == Axis.Y;
    boolean az = between.mainAxis == Axis.Z;
    if (between.to == null) {
        double cL = 0.5f - 4.51f / 16f;
        double cU = 0.5f + 4.51f / 16f;
        center = new // 
        Vec3d(// 
        ax ? 0.5f : (between.xy ? cU : cL), // 
        ay ? 0.5f : ((ax ? between.xy : between.yz) ? cU : cL), // 
        az ? 0.5f : (between.yz ? cU : cL));
        double rC = 4.01f / 16f;
        double rN = 1f / 16f / 2;
        radius = new // 
        Vec3d(// 
        ax ? rC : rN, // 
        ay ? rC : rN, // 
        az ? rC : rN);
    } else {
        // we are a connection
        double cL = (8 - 4.51) / 16;
        double cU = (8 + 4.51) / 16;
        radius = new // 
        Vec3d(// 
        ax ? 2.99 / 32 : 1 / 32.0, // 
        ay ? 2.99 / 32 : 1 / 32.0, // 
        az ? 2.99 / 32 : 1 / 32.0);
        center = new // 
        Vec3d(// 
        ax ? (0.5 + 6.505 / 16 * between.to.getFrontOffsetX()) : (between.xy ? cU : cL), // 
        ay ? (0.5 + 6.505 / 16 * between.to.getFrontOffsetY()) : ((ax ? between.xy : between.yz) ? cU : cL), // 
        az ? (0.5 + 6.505 / 16 * between.to.getFrontOffsetZ()) : (between.yz ? cU : cL));
    }
    UvFaceData uvBase = new UvFaceData();
    uvBase.minU = (float) VecUtil.getValue(center.subtract(radius), between.mainAxis);
    uvBase.maxU = (float) VecUtil.getValue(center.add(radius), between.mainAxis);
    uvBase.minV = 0;
    uvBase.maxV = 1 / 16f;
    Tuple3f centerFloat = VecUtil.convertFloat(center);
    Tuple3f radiusFloat = VecUtil.convertFloat(radius);
    for (EnumFacing face : EnumFacing.VALUES) {
        if (face.getAxis() == between.mainAxis) {
            continue;
        }
        UvFaceData uvs = new UvFaceData(uvBase);
        Axis aAxis = between.mainAxis;
        Axis fAxis = face.getAxis();
        boolean fPositive = face.getAxisDirection() == AxisDirection.POSITIVE;
        int rotations = 0;
        boolean swapU = false;
        boolean swapV = false;
        if (aAxis == Axis.X) {
            swapV = fPositive;
        } else if (aAxis == Axis.Y) {
            rotations = 1;
            swapU = (fAxis == Axis.X) != fPositive;
            swapV = fAxis == Axis.Z;
        } else {
            // aAxis == Axis.Z
            if (fAxis == Axis.Y) {
                rotations = 1;
            }
            swapU = face == EnumFacing.DOWN;
            swapV = face != EnumFacing.EAST;
        }
        if (swapU) {
            float t = uvs.minU;
            uvs.minU = uvs.maxU;
            uvs.maxU = t;
        }
        if (swapV) {
            float t = uvs.minV;
            uvs.minV = uvs.maxV;
            uvs.maxV = t;
        }
        MutableQuad quad = ModelUtil.createFace(face, centerFloat, radiusFloat, uvs);
        if (rotations > 0)
            quad.rotateTextureUp(rotations);
        quads[i++] = quad;
    }
    return quads;
}
Also used : UvFaceData(buildcraft.lib.client.model.ModelUtil.UvFaceData) Tuple3f(javax.vecmath.Tuple3f) EnumFacing(net.minecraft.util.EnumFacing) Vec3d(net.minecraft.util.math.Vec3d) Axis(net.minecraft.util.EnumFacing.Axis) MutableQuad(buildcraft.lib.client.model.MutableQuad)

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