Search in sources :

Example 11 with Direction

use of net.minecraft.util.math.Direction in project bewitchment by MoriyaShiine.

the class PoppetShelfBlockEntityRenderer method render.

@Override
public void render(PoppetShelfBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
    Direction direction = entity.getCachedState().get(Properties.HORIZONTAL_FACING);
    float rotation = -direction.asRotation();
    matrices.translate(0.5f, 0, 0.5f);
    matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(rotation));
    matrices.scale(1 / 5f, 1 / 5f, 1 / 5f);
    renderRow(entity.clientInventory.get(0), entity.clientInventory.get(1), entity.clientInventory.get(2), 0.8f, matrices, vertexConsumers, light, overlay);
    renderRow(entity.clientInventory.get(3), entity.clientInventory.get(4), entity.clientInventory.get(5), 0.5f, matrices, vertexConsumers, light, overlay);
    renderRow(entity.clientInventory.get(6), entity.clientInventory.get(7), entity.clientInventory.get(8), 0.2f, matrices, vertexConsumers, light, overlay);
}
Also used : Direction(net.minecraft.util.math.Direction)

Example 12 with Direction

use of net.minecraft.util.math.Direction in project WK by witches-kitchen.

the class WitchesOvenBlockEntityRender method render.

@Override
public void render(WitchesOvenBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
    final Direction facing = entity.getCachedState().get(WitchesOvenBlock.FACING);
    final DefaultedList<ItemStack> extraInventory = entity.getStacksOnTop();
    final int pos = (int) entity.getPos().asLong();
    for (int i = 0; i < extraInventory.size(); i++) {
        final ItemStack food = extraInventory.get(i);
        if (food.isEmpty()) {
            return;
        }
        matrices.push();
        matrices.translate(0.5D, 1.02, 0.5D);
        final Direction dir = Direction.fromHorizontal((i + facing.getHorizontal()) % 4);
        final float rotation = -dir.asRotation();
        matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(rotation));
        matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90.0F));
        matrices.translate(-0.20D, -0.20D, 0.0D);
        matrices.scale(0.375F, 0.375F, 0.375F);
        MinecraftClient.getInstance().getItemRenderer().renderItem(food, ModelTransformation.Mode.FIXED, light, overlay, matrices, vertexConsumers, pos + i);
        matrices.pop();
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) Direction(net.minecraft.util.math.Direction)

Example 13 with Direction

use of net.minecraft.util.math.Direction in project EdenClient by HahaOO7.

the class WorldEditReplaceHelper method registerCommand.

private void registerCommand(String command) {
    LiteralArgumentBuilder<ClientCommandSource> node = literal(command);
    node.then(literal("replace").then(argument("from", StringArgumentType.word()).suggests(this::suggestValidBlocks).then(argument("to", StringArgumentType.word()).suggests(this::suggestValidBlocks).executes(c -> {
        Optional<Block> fromBlockOpt = Registry.BLOCK.getOrEmpty(new Identifier(c.getArgument("from", String.class)));
        Optional<Block> toBlockOpt = Registry.BLOCK.getOrEmpty(new Identifier(c.getArgument("to", String.class)));
        if (fromBlockOpt.isEmpty() || toBlockOpt.isEmpty()) {
            sendModMessage("One of your block-inputs doesn't exist.");
            return 0;
        }
        Block fromBlock = fromBlockOpt.get();
        Block toBlock = toBlockOpt.get();
        if (fromBlock.equals(toBlock)) {
            sendModMessage("Both input-blocks can't be the same!");
            return 0;
        }
        String[] currentOperation = new String[] { getBlockIDFromBlock(toBlock), getBlockIDFromBlock(fromBlock) };
        undoCommandStack.add(currentOperation);
        return replaceCommandRequest(fromBlock, toBlock, delay, true);
    }))));
    node.then(literal("undo").executes(c -> {
        if (undoCommandStack.size() == 0) {
            sendModMessage("Nothing left to undo.");
            return 0;
        }
        replaceUndoRequest(Registry.BLOCK.get(new Identifier(undoCommandStack.peek()[0])), Registry.BLOCK.get(new Identifier(undoCommandStack.peek()[1])), delay);
        redoCommandStack.add(new String[] { undoCommandStack.peek()[1], undoCommandStack.peek()[0] });
        undoCommandStack.pop();
        return 1;
    }));
    node.then(literal("redo").executes(c -> {
        if (redoCommandStack.size() == 0) {
            sendModMessage("Nothing left to redo.");
            return 0;
        }
        replaceRedoRequest(Registry.BLOCK.get(new Identifier(redoCommandStack.peek()[0])), Registry.BLOCK.get(new Identifier(redoCommandStack.peek()[1])), delay);
        undoCommandStack.add(new String[] { redoCommandStack.peek()[1], redoCommandStack.peek()[0] });
        redoCommandStack.pop();
        return 1;
    }));
    node.then(literal("delay").then(argument("delay", IntegerArgumentType.integer(0, 40)).executes(c -> {
        this.delay = c.getArgument("delay", Integer.class);
        sendModMessage(ChatColor.GOLD + "Set delay to " + ChatColor.AQUA + delay + ChatColor.GOLD + " ticks.");
        return 1;
    })));
    node.then(literal("togglemessages").executes(c -> {
        ClientPlayerEntity entityPlayer = PlayerUtils.getPlayer();
        entityPlayer.sendChatMessage("/eignoremessage predefined worldedit");
        return 1;
    }));
    register(node, "The WorldEditReplaceHelper helps you replace blocks that have specific properties which normal WorldEdit doesn't take into consideration when replacing blocks.", "Blocks like stairs, slabs, panes, walls, trapdoors, etc. can be replaced by other blocks of their type with their properties (waterlogged, shape, direction, etc.) unaffected.");
}
Also used : net.minecraft.block.enums(net.minecraft.block.enums) PerWorldConfig(at.haha007.edenclient.utils.config.PerWorldConfig) ChatColor(at.haha007.edenclient.utils.ChatColor) CompletableFuture(java.util.concurrent.CompletableFuture) Stack(java.util.Stack) ArrayList(java.util.ArrayList) Direction(net.minecraft.util.math.Direction) DefaultedRegistry(net.minecraft.util.registry.DefaultedRegistry) StringArgumentType(com.mojang.brigadier.arguments.StringArgumentType) net.minecraft.block(net.minecraft.block) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CommandManager(at.haha007.edenclient.command.CommandManager) PlayerUtils.sendModMessage(at.haha007.edenclient.utils.PlayerUtils.sendModMessage) Scheduler(at.haha007.edenclient.utils.Scheduler) SuggestionsBuilder(com.mojang.brigadier.suggestion.SuggestionsBuilder) ClientCommandSource(net.minecraft.client.network.ClientCommandSource) Suggestions(com.mojang.brigadier.suggestion.Suggestions) CommandContext(com.mojang.brigadier.context.CommandContext) Collectors(java.util.stream.Collectors) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) Registry(net.minecraft.util.registry.Registry) List(java.util.List) ConfigSubscriber(at.haha007.edenclient.utils.config.ConfigSubscriber) Identifier(net.minecraft.util.Identifier) Optional(java.util.Optional) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) IntegerArgumentType(com.mojang.brigadier.arguments.IntegerArgumentType) PlayerUtils(at.haha007.edenclient.utils.PlayerUtils) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Identifier(net.minecraft.util.Identifier) Optional(java.util.Optional) ClientCommandSource(net.minecraft.client.network.ClientCommandSource) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity)

Example 14 with Direction

use of net.minecraft.util.math.Direction in project fabric by FabricMC.

the class ItemRenderContext method fallbackConsumer.

private void fallbackConsumer(BakedModel model) {
    if (hasTransform()) {
        // if there's a transform in effect, convert to mesh-based quads so that we can apply it
        for (int i = 0; i < 7; i++) {
            random.setSeed(42L);
            final Direction cullFace = ModelHelper.faceFromIndex(i);
            renderFallbackWithTransform(bufferBuilder, model.getQuads((BlockState) null, cullFace, random), color, itemStack, cullFace);
        }
    } else {
        for (int i = 0; i < 7; i++) {
            random.setSeed(42L);
            vanillaHandler.accept(bufferBuilder, model.getQuads((BlockState) null, ModelHelper.faceFromIndex(i), random), color, itemStack);
        }
    }
}
Also used : BlockState(net.minecraft.block.BlockState) Direction(net.minecraft.util.math.Direction)

Example 15 with Direction

use of net.minecraft.util.math.Direction in project fabric by FabricMC.

the class TerrainFallbackConsumer method renderQuad.

private void renderQuad(BakedQuad quad, Direction cullFace, Value defaultMaterial) {
    final int[] vertexData = quad.getVertexData();
    if (!CompatibilityHelper.canRender(vertexData)) {
        return;
    }
    final MutableQuadViewImpl editorQuad = this.editorQuad;
    System.arraycopy(vertexData, 0, editorBuffer, 0, 28);
    editorQuad.cullFace(cullFace);
    final Direction lightFace = quad.getFace();
    editorQuad.lightFace(lightFace);
    editorQuad.nominalFace(lightFace);
    editorQuad.colorIndex(quad.getColorIndex());
    editorQuad.material(defaultMaterial);
    if (!transform.transform(editorQuad)) {
        return;
    }
    if (editorQuad.material().hasAo) {
        // needs to happen before offsets are applied
        editorQuad.invalidateShape();
        aoCalc.compute(editorQuad, true);
        chunkInfo.applyOffsets(editorQuad);
        tesselateSmooth(editorQuad, blockInfo.defaultLayerIndex, editorQuad.colorIndex());
    } else {
        // For flat lighting, cull face drives everything and light face is ignored.
        if (cullFace == null) {
            editorQuad.invalidateShape();
            // Can't rely on lazy computation in tesselateFlat() because needs to happen before offsets are applied
            editorQuad.geometryFlags();
        } else {
            editorQuad.geometryFlags(GeometryHelper.LIGHT_FACE_FLAG);
            editorQuad.lightFace(cullFace);
        }
        chunkInfo.applyOffsets(editorQuad);
        tesselateFlat(editorQuad, blockInfo.defaultLayerIndex, editorQuad.colorIndex());
    }
}
Also used : MutableQuadViewImpl(net.fabricmc.indigo.renderer.mesh.MutableQuadViewImpl) 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