Search in sources :

Example 96 with Direction

use of net.minecraft.util.math.Direction in project wildmod by Osmiooo.

the class SculkPatchFeature method veins.

public static void veins(BlockPos blockpos, StructureWorldAccess world) {
    if (world.isChunkLoaded(blockpos)) {
        for (Direction direction : Direction.values()) {
            BlockPos pos1 = blockpos.offset(direction);
            if (world.isChunkLoaded(pos1)) {
                BlockState state = world.getBlockState(pos1);
                Block block = state.getBlock();
                if (SculkTags.ALWAYS_WATER.contains(block) || state == Blocks.WATER.getDefaultState()) {
                    world.setBlockState(pos1, RegisterBlocks.SCULK_VEIN.getDefaultState().with(waterLogged, true).with(getOpposite(direction), true), 0);
                } else if (block != waterBlock) {
                    if (block == veinBlock) {
                        world.setBlockState(pos1, state.with(getOpposite(direction), true), 0);
                    } else if (SculkTags.SCULK_VEIN_REPLACEABLE.contains(block) || state.isAir()) {
                        world.setBlockState(pos1, RegisterBlocks.SCULK_VEIN.getDefaultState().with(getOpposite(direction), true), 0);
                    }
                }
            }
        }
    }
}
Also used : BlockState(net.minecraft.block.BlockState) SculkVeinBlock(frozenblock.wild.mod.blocks.SculkVeinBlock) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) Direction(net.minecraft.util.math.Direction)

Example 97 with Direction

use of net.minecraft.util.math.Direction in project SinoCate by EverlastSino.

the class CuttingBoardBlockEntityRenderer method render.

@Override
public void render(CuttingBoardBlockEntity entity, float f, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j) {
    Direction direction = entity.getCachedState().get(CampfireBlock.FACING);
    ItemStack itemStack = entity.itemStack.copy();
    int k = (int) entity.getPos().asLong();
    if (itemStack == ItemStack.EMPTY)
        return;
    matrixStack.push();
    matrixStack.translate(0.5, 0.1, 0.5);
    Direction direction2 = Direction.fromHorizontal(direction.getHorizontal() % 4);
    float g = -direction2.asRotation();
    matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(g));
    matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90.0f));
    matrixStack.scale(0.5f, 0.5f, 0.5f);
    MinecraftClient.getInstance().getItemRenderer().renderItem(itemStack, ModelTransformation.Mode.FIXED, i, j, matrixStack, vertexConsumerProvider, k);
    matrixStack.pop();
}
Also used : ItemStack(net.minecraft.item.ItemStack) Direction(net.minecraft.util.math.Direction)

Example 98 with Direction

use of net.minecraft.util.math.Direction in project SeedcrackerX by 19MisterX98.

the class OutpostFinder method reloadSearchPositions.

public static void reloadSearchPositions() {
    SEARCH_POSITIONS = JigsawFinder.getSearchPositions(0, 0, 0, 0, size);
    Map<Direction, List<BlockPos>> additional = JigsawFinder.getSearchPositions(0, 0, 1, 0, size);
    for (Direction direction : Direction.Type.HORIZONTAL) {
        SEARCH_POSITIONS.get(direction).addAll(additional.get(direction));
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Direction(net.minecraft.util.math.Direction)

Example 99 with Direction

use of net.minecraft.util.math.Direction in project Indium by comp500.

the class AoCalculator method calcVanilla.

private void calcVanilla(MutableQuadViewImpl quad, float[] aoDest, int[] lightDest) {
    vanillaAoControlBits.clear();
    final Direction face = quad.lightFace();
    quad.toVanilla(0, vertexData, 0, false);
    VanillaAoHelper.updateShape(blockInfo.blockView, blockInfo.blockState, blockInfo.blockPos, vertexData, face, vanillaAoData, vanillaAoControlBits);
    vanillaCalc.fabric_apply(blockInfo.blockView, blockInfo.blockState, blockInfo.blockPos, quad.lightFace(), vanillaAoData, vanillaAoControlBits, quad.hasShade());
    System.arraycopy(vanillaCalc.fabric_colorMultiplier(), 0, aoDest, 0, 4);
    System.arraycopy(vanillaCalc.fabric_brightness(), 0, lightDest, 0, 4);
}
Also used : Direction(net.minecraft.util.math.Direction)

Example 100 with Direction

use of net.minecraft.util.math.Direction in project Indium by comp500.

the class AoCalculator method irregularFace.

private void irregularFace(MutableQuadViewImpl quad) {
    final Vector3f faceNorm = quad.faceNormal();
    Vector3f normal;
    final float[] w = this.w;
    final float[] aoResult = this.ao;
    final int[] lightResult = this.light;
    for (int i = 0; i < 4; i++) {
        normal = quad.hasNormal(i) ? quad.copyNormal(i, vertexNormal) : faceNorm;
        float ao = 0, sky = 0, block = 0, maxAo = 0;
        int maxSky = 0, maxBlock = 0;
        final float x = normal.getX();
        if (!MathHelper.approximatelyEquals(0f, x)) {
            final Direction face = x > 0 ? Direction.EAST : Direction.WEST;
            final AoFaceData fd = gatherInsetFace(quad, i, face);
            AoFace.get(face).weightFunc.apply(quad, i, w);
            final float n = x * x;
            final float a = fd.weigtedAo(w);
            final int s = fd.weigtedSkyLight(w);
            final int b = fd.weigtedBlockLight(w);
            ao += n * a;
            sky += n * s;
            block += n * b;
            maxAo = a;
            maxSky = s;
            maxBlock = b;
        }
        final float y = normal.getY();
        if (!MathHelper.approximatelyEquals(0f, y)) {
            final Direction face = y > 0 ? Direction.UP : Direction.DOWN;
            final AoFaceData fd = gatherInsetFace(quad, i, face);
            AoFace.get(face).weightFunc.apply(quad, i, w);
            final float n = y * y;
            final float a = fd.weigtedAo(w);
            final int s = fd.weigtedSkyLight(w);
            final int b = fd.weigtedBlockLight(w);
            ao += n * a;
            sky += n * s;
            block += n * b;
            maxAo = Math.max(maxAo, a);
            maxSky = Math.max(maxSky, s);
            maxBlock = Math.max(maxBlock, b);
        }
        final float z = normal.getZ();
        if (!MathHelper.approximatelyEquals(0f, z)) {
            final Direction face = z > 0 ? Direction.SOUTH : Direction.NORTH;
            final AoFaceData fd = gatherInsetFace(quad, i, face);
            AoFace.get(face).weightFunc.apply(quad, i, w);
            final float n = z * z;
            final float a = fd.weigtedAo(w);
            final int s = fd.weigtedSkyLight(w);
            final int b = fd.weigtedBlockLight(w);
            ao += n * a;
            sky += n * s;
            block += n * b;
            maxAo = Math.max(maxAo, a);
            maxSky = Math.max(maxSky, s);
            maxBlock = Math.max(maxBlock, b);
        }
        aoResult[i] = (ao + maxAo) * 0.5f;
        lightResult[i] = (((int) ((sky + maxSky) * 0.5f) & 0xF0) << 16) | ((int) ((block + maxBlock) * 0.5f) & 0xF0);
    }
}
Also used : Vector3f(net.minecraft.client.util.math.Vector3f) Direction(net.minecraft.util.math.Direction)

Aggregations

Direction (net.minecraft.util.math.Direction)184 BlockPos (net.minecraft.util.math.BlockPos)89 BlockState (net.minecraft.block.BlockState)46 Vec3d (net.minecraft.util.math.Vec3d)19 Block (net.minecraft.block.Block)14 BlockHitResult (net.minecraft.util.hit.BlockHitResult)13 Box (net.minecraft.util.math.Box)11 VoxelShape (net.minecraft.util.shape.VoxelShape)8 SculkVeinBlock (frozenblock.wild.mod.blocks.SculkVeinBlock)7 Inject (org.spongepowered.asm.mixin.injection.Inject)7 ArrayList (java.util.ArrayList)6 World (net.minecraft.world.World)6 Random (java.util.Random)5 Environment (net.fabricmc.api.Environment)5 BakedQuad (net.minecraft.client.render.model.BakedQuad)5 Nullable (org.jetbrains.annotations.Nullable)5 List (java.util.List)4 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 EventHandler (meteordevelopment.orbit.EventHandler)4