Search in sources :

Example 1 with MapState

use of net.minecraft.item.map.MapState in project Skyblocker by LifeIsAParadox.

the class DungeonMap method render.

public static void render(MatrixStack matrices) {
    MinecraftClient client = MinecraftClient.getInstance();
    if (client.player == null && client.world == null)
        return;
    ItemStack item = client.player.getInventory().main.get(8);
    NbtCompound tag = item.getNbt();
    if (tag != null && tag.contains("map")) {
        String tag2 = tag.asString();
        tag2 = StringUtils.substringBetween(tag2, "map:", "}");
        int mapid = Integer.parseInt(tag2);
        VertexConsumerProvider.Immediate vertices = client.getBufferBuilders().getEffectVertexConsumers();
        MapRenderer map = client.gameRenderer.getMapRenderer();
        MapState state = FilledMapItem.getMapState(mapid, client.world);
        if (state == null)
            return;
        matrices.push();
        matrices.translate(2, 2, 0);
        matrices.scale(1, 1, 0);
        map.draw(matrices, vertices, mapid, state, false, 15728880);
        vertices.draw();
        matrices.pop();
    }
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) MapRenderer(net.minecraft.client.render.MapRenderer) MinecraftClient(net.minecraft.client.MinecraftClient) MapState(net.minecraft.item.map.MapState) ItemStack(net.minecraft.item.ItemStack) VertexConsumerProvider(net.minecraft.client.render.VertexConsumerProvider)

Example 2 with MapState

use of net.minecraft.item.map.MapState in project BleachHack by BleachDrinker420.

the class Peek method drawMapToolTip.

public void drawMapToolTip(MatrixStack matrices, Slot slot, int mouseX, int mouseY) {
    if (slot.getStack().getItem() != Items.FILLED_MAP) {
        return;
    }
    Integer id = FilledMapItem.getMapId(slot.getStack());
    MapState mapState = FilledMapItem.getMapState(id, mc.world);
    if (mapState == null) {
        return;
    }
    float scale = getSetting(2).asToggle().getChild(0).asSlider().getValueFloat() / 1.25f;
    matrices.push();
    matrices.translate(mouseX + 14, mouseY - 18 - 135 * scale, 0);
    matrices.scale(scale, scale, 0.0078125f);
    VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer());
    VertexConsumer backgroundVertexer = immediate.getBuffer(MAP_BACKGROUND_CHECKERBOARD);
    Matrix4f matrix4f = matrices.peek().getModel();
    backgroundVertexer.vertex(matrix4f, -7f, 135f, -10f).color(255, 255, 255, 255).texture(0f, 1f).light(0xf000f0).next();
    backgroundVertexer.vertex(matrix4f, 135f, 135f, -10f).color(255, 255, 255, 255).texture(1f, 1f).light(0xf000f0).next();
    backgroundVertexer.vertex(matrix4f, 135f, -7f, -10f).color(255, 255, 255, 255).texture(1f, 0f).light(0xf000f0).next();
    backgroundVertexer.vertex(matrix4f, -7f, -7f, -10f).color(255, 255, 255, 255).texture(0f, 0f).light(0xf000f0).next();
    mc.gameRenderer.getMapRenderer().draw(matrices, immediate, id, mapState, false, 0xf000f0);
    immediate.draw();
    matrices.pop();
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) MapState(net.minecraft.item.map.MapState) VertexConsumer(net.minecraft.client.render.VertexConsumer) VertexConsumerProvider(net.minecraft.client.render.VertexConsumerProvider)

Example 3 with MapState

use of net.minecraft.item.map.MapState in project meteor-client by MeteorDevelopment.

the class SaveMapCommand method getMapState.

private MapState getMapState() {
    ItemStack map = getMap();
    if (map == null)
        return null;
    MapState state = FilledMapItem.getMapState(FilledMapItem.getMapId(map), mc.world);
    if (state == null)
        return null;
    return state;
}
Also used : MapState(net.minecraft.item.map.MapState) ItemStack(net.minecraft.item.ItemStack)

Example 4 with MapState

use of net.minecraft.item.map.MapState in project meteor-client by MeteorDevelopment.

the class MapTooltipComponent method drawItems.

@Override
public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) {
    double scale = Modules.get().get(BetterTooltips.class).mapsScale.get();
    // Background
    matrices.push();
    matrices.translate(x, y, z);
    matrices.scale((float) (scale) * 2, (float) (scale) * 2, 0);
    matrices.scale((64 + 8) / 64f, (64 + 8) / 64f, 0);
    RenderSystem.setShader(GameRenderer::getPositionTexShader);
    RenderSystem.setShaderTexture(0, TEXTURE_MAP_BACKGROUND);
    DrawableHelper.drawTexture(matrices, 0, 0, 0, 0, 0, 64, 64, 64, 64);
    matrices.pop();
    // Contents
    VertexConsumerProvider.Immediate consumer = mc.getBufferBuilders().getEntityVertexConsumers();
    MapState mapState = FilledMapItem.getMapState(this.mapId, mc.world);
    if (mapState == null)
        return;
    matrices.push();
    matrices.translate(x, y, z);
    matrices.scale((float) scale, (float) scale, 0);
    matrices.translate(8, 8, 0);
    mc.gameRenderer.getMapRenderer().draw(matrices, consumer, this.mapId, mapState, false, 0xF000F0);
    consumer.draw();
    matrices.pop();
}
Also used : GameRenderer(net.minecraft.client.render.GameRenderer) MapState(net.minecraft.item.map.MapState) VertexConsumerProvider(net.minecraft.client.render.VertexConsumerProvider)

Example 5 with MapState

use of net.minecraft.item.map.MapState in project Client by MatHax.

the class MapTooltipComponent method drawItems.

@Override
public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) {
    double scale = Modules.get().get(BetterTooltips.class).mapsScale.get();
    // Background
    matrices.push();
    matrices.translate(x, y, z);
    matrices.scale((float) (scale) * 2, (float) (scale) * 2, 0);
    matrices.scale((64 + 8) / 64f, (64 + 8) / 64f, 0);
    RenderSystem.setShader(GameRenderer::getPositionTexShader);
    RenderSystem.setShaderTexture(0, TEXTURE_MAP_BACKGROUND);
    DrawableHelper.drawTexture(matrices, 0, 0, 0, 0, 0, 64, 64, 64, 64);
    matrices.pop();
    // Contents
    VertexConsumerProvider.Immediate consumer = mc.getBufferBuilders().getEntityVertexConsumers();
    MapState mapState = FilledMapItem.getMapState(this.mapId, mc.world);
    if (mapState == null)
        return;
    matrices.push();
    matrices.translate(x, y, z);
    matrices.scale((float) scale, (float) scale, 0);
    matrices.translate(8, 8, 0);
    mc.gameRenderer.getMapRenderer().draw(matrices, consumer, this.mapId, mapState, false, 0xF000F0);
    consumer.draw();
    matrices.pop();
}
Also used : GameRenderer(net.minecraft.client.render.GameRenderer) MapState(net.minecraft.item.map.MapState) VertexConsumerProvider(net.minecraft.client.render.VertexConsumerProvider)

Aggregations

MapState (net.minecraft.item.map.MapState)6 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)4 ItemStack (net.minecraft.item.ItemStack)3 GameRenderer (net.minecraft.client.render.GameRenderer)2 MinecraftClient (net.minecraft.client.MinecraftClient)1 MapRenderer (net.minecraft.client.render.MapRenderer)1 VertexConsumer (net.minecraft.client.render.VertexConsumer)1 NbtCompound (net.minecraft.nbt.NbtCompound)1 Matrix4f (net.minecraft.util.math.Matrix4f)1