Search in sources :

Example 1 with ItemRenderer

use of net.minecraft.client.render.item.ItemRenderer in project Skyblocker by LifeIsAParadox.

the class DummyInventory method renderPreview.

public static boolean renderPreview(MatrixStack matrices, int index, int mouseX, int mouseY) {
    if (index >= 9 && index < 18)
        index -= 9;
    else if (index >= 27 && index < 45)
        index -= 18;
    else
        return false;
    if (storage[index] == null)
        return false;
    int rows = (storage[index].size() - 9) / 9;
    Screen screen = MinecraftClient.getInstance().currentScreen;
    int x = mouseX + 184 >= screen.width ? mouseX - 188 : mouseX + 8;
    int y = Math.max(0, mouseY - 16);
    RenderSystem.disableDepthTest();
    RenderSystem.setShaderTexture(0, TEXTURE);
    instance.drawTexture(matrices, x, y, 0, 0, 176, 7);
    for (int i = 0; i < rows; ++i) instance.drawTexture(matrices, x, y + i * 18 + 7, 0, 7, 176, 18);
    instance.drawTexture(matrices, x, y + rows * 18 + 7, 0, 25, 176, 7);
    RenderSystem.enableDepthTest();
    ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
    TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
    for (int i = 9; i < storage[index].size(); ++i) {
        int itemX = x + (i - 9) % 9 * 18 + 8;
        int itemY = y + (i - 9) / 9 * 18 + 8;
        itemRenderer.zOffset = 200.0F;
        itemRenderer.renderInGui(storage[index].getStack(i), itemX, itemY);
        itemRenderer.renderGuiItemOverlay(textRenderer, storage[index].getStack(i), itemX, itemY);
        itemRenderer.zOffset = 0.0F;
    }
    return true;
}
Also used : Screen(net.minecraft.client.gui.screen.Screen) HandledScreen(net.minecraft.client.gui.screen.ingame.HandledScreen) ItemRenderer(net.minecraft.client.render.item.ItemRenderer) TextRenderer(net.minecraft.client.font.TextRenderer)

Example 2 with ItemRenderer

use of net.minecraft.client.render.item.ItemRenderer in project Polymorph by TheIllusiveC4.

the class OutputWidget method renderButton.

@Override
public void renderButton(MatrixStack matrixStack, int button_1, int button_2, float button_3) {
    MinecraftClient minecraft = MinecraftClient.getInstance();
    RenderSystem.setShader(GameRenderer::getPositionTexShader);
    RenderSystem.setShaderTexture(0, AbstractRecipesWidget.WIDGETS);
    int j = 0;
    if (this.x + 25 > button_1 && this.x <= button_1 && this.y + 25 > button_2 && this.y <= button_2) {
        j += 25;
    }
    this.drawTexture(matrixStack, this.x, this.y, this.highlighted ? 41 : 16, j, this.width, this.height);
    int k = 4;
    ItemRenderer renderer = minecraft.getItemRenderer();
    float zLevel = renderer.zOffset;
    renderer.zOffset = 700.0F;
    renderer.renderGuiItemIcon(this.getOutput(), this.x + k, this.y + k);
    renderer.renderGuiItemOverlay(minecraft.textRenderer, this.getOutput(), this.x + k, this.y + k);
    renderer.zOffset = zLevel;
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) ItemRenderer(net.minecraft.client.render.item.ItemRenderer) GameRenderer(net.minecraft.client.render.GameRenderer)

Example 3 with ItemRenderer

use of net.minecraft.client.render.item.ItemRenderer in project EdenClient by HahaOO7.

the class ContainerDisplay method renderWorld.

private void renderWorld(MatrixStack matrixStack, VertexConsumerProvider.Immediate vertexConsumerProvider, float v) {
    if (!enabled)
        return;
    // calculate looking direction, rendering offset and rendering angle
    final Direction direction = Direction.getEntityFacingOrder(PlayerUtils.getPlayer())[5];
    final Vec3d offset = Vec3d.of(direction.getVector().add(1, 1, 1)).multiply(.5);
    final Quaternion rotation = direction.getRotationQuaternion();
    if (direction.getAxis() == Direction.Axis.Y) {
        Quaternion horizontal = getPlayer().getHorizontalFacing().getRotationQuaternion();
        horizontal.hamiltonProduct(Direction.NORTH.getRotationQuaternion());
        rotation.hamiltonProduct(horizontal);
    }
    rotation.hamiltonProduct(Direction.NORTH.getRotationQuaternion());
    RenderSystem.enableDepthTest();
    // get the item renderer
    ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
    // rendering
    entries.forEach((pos, items) -> {
        matrixStack.push();
        // move matrix to rendering position
        matrixStack.translate(pos.getX() + offset.getX(), pos.getY() + offset.getY(), pos.getZ() + offset.getZ());
        // rotate to look outwards
        matrixStack.multiply(rotation);
        // scale item down
        int loopCount = Math.min(items.size(), 9);
        if (loopCount > 1) {
            // multiple items -> render 3x3 items
            matrixStack.scale(.3f, .3f, .3f);
            // loop over items, max 9 times
            for (int i = 0; i < loopCount; i++) {
                Item item = items.get(i);
                int x = i / 3;
                int y = i % 3;
                matrixStack.push();
                matrixStack.translate(1 - y, 1 - x, 0);
                matrixStack.scale(.8f, .8f, .8f);
                itemRenderer.renderItem(item.getDefaultStack(), ModelTransformation.Mode.NONE, false, matrixStack, vertexConsumerProvider, 255, OverlayTexture.DEFAULT_UV, itemRenderer.getModels().getModel(item));
                matrixStack.pop();
            }
        } else {
            // one item -> render it BIG!
            matrixStack.scale(.6f, .6f, .6f);
            Item item = items.get(0);
            itemRenderer.renderItem(item.getDefaultStack(), ModelTransformation.Mode.NONE, false, matrixStack, vertexConsumerProvider, 255, OverlayTexture.DEFAULT_UV, itemRenderer.getModels().getModel(item));
        }
        matrixStack.pop();
    });
}
Also used : Item(net.minecraft.item.Item) ItemRenderer(net.minecraft.client.render.item.ItemRenderer)

Example 4 with ItemRenderer

use of net.minecraft.client.render.item.ItemRenderer in project frame-fabric by moddingplayground.

the class TabWidget method renderButtonStack.

public void renderButtonStack(GUIIcon<?> icon, boolean hovered, boolean selected, int x, int y) {
    GUIIcon.optional(icon, hovered, selected, ItemStack.class).ifPresent(stack -> {
        MinecraftClient client = MinecraftClient.getInstance();
        ItemRenderer itemRenderer = client.getItemRenderer();
        itemRenderer.renderInGui(stack, x, y);
    });
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) ItemRenderer(net.minecraft.client.render.item.ItemRenderer) ItemStack(net.minecraft.item.ItemStack)

Example 5 with ItemRenderer

use of net.minecraft.client.render.item.ItemRenderer in project KiwiClient by TangyKiwi.

the class InventoryViewer method onDrawOverlay.

@Subscribe
public void onDrawOverlay(DrawOverlayEvent e) {
    ItemRenderer itemRenderer = mc.getItemRenderer();
    ClientPlayerEntity player = mc.player;
    int scaledWidth = mc.getWindow().getScaledWidth();
    int scaledHeight = mc.getWindow().getScaledHeight();
    ColorUtil.fillGradient(new MatrixStack(), scaledWidth - (9 * 18 + 4), scaledHeight - (3 * 18 + 4), scaledWidth, scaledHeight, -1072689136, -804253680);
    for (int i = 1; i <= 4; i++) {
        for (int j = 0; j < 9; j++) {
            int slot = i * 9 + j;
            ItemStack itemStack = player.getInventory().getStack(slot);
            boolean isEmpty = itemStack.isEmpty();
            if (!isEmpty) {
                int x = scaledWidth - (9 * 18 + 4) + j * 18 + 2;
                int y = scaledHeight - (3 * 18 + 4) + (i - 1) * 18 + 2;
                itemRenderer.renderGuiItemIcon(itemStack, x, y);
                itemRenderer.renderGuiItemOverlay(mc.textRenderer, itemStack, x, y);
            }
        }
    }
}
Also used : MatrixStack(net.minecraft.client.util.math.MatrixStack) ItemRenderer(net.minecraft.client.render.item.ItemRenderer) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) ItemStack(net.minecraft.item.ItemStack) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

ItemRenderer (net.minecraft.client.render.item.ItemRenderer)6 MinecraftClient (net.minecraft.client.MinecraftClient)2 ItemStack (net.minecraft.item.ItemStack)2 Subscribe (com.google.common.eventbus.Subscribe)1 TextRenderer (net.minecraft.client.font.TextRenderer)1 Screen (net.minecraft.client.gui.screen.Screen)1 HandledScreen (net.minecraft.client.gui.screen.ingame.HandledScreen)1 ClientPlayerEntity (net.minecraft.client.network.ClientPlayerEntity)1 GameRenderer (net.minecraft.client.render.GameRenderer)1 ModelIdentifier (net.minecraft.client.util.ModelIdentifier)1 MatrixStack (net.minecraft.client.util.math.MatrixStack)1 Item (net.minecraft.item.Item)1