Search in sources :

Example 1 with DynamicTextureBC

use of buildcraft.lib.client.sprite.DynamicTextureBC in project BuildCraft by BuildCraft.

the class RenderZonePlan method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileZonePlan zonePlan, double tx, double ty, double tz, float partialTicks, int arg) {
    boolean rendered = true;
    TileZonePlan tile = zonePlan;
    if (!TEXTURES.containsKey(zonePlan)) {
        DynamicTextureBC textureBC = new DynamicTextureBC(16, 16);
        TEXTURES.put(zonePlan, textureBC);
        rendered = false;
    }
    DynamicTextureBC textureBC = TEXTURES.get(zonePlan);
    // FIXME! All of this is wrong!
    // FakeIcon fakeIcon = new FakeIcon(0, 1, 0, 1, 16, 16);
    byte[] previewColors = zonePlan.getPreviewTexture(!rendered);
    if (previewColors != null) {
        for (int y = 0; y < 8; y++) {
            for (int x = 0; x < 10; x++) {
                int col = MapColor.mapColorArray[previewColors[y * 10 + x]].colorValue;
                if ((x & 1) != (y & 1)) {
                    int ocol = col;
                    col = (ocol & 0xFF) * 15 / 16 | (((ocol & 0xFF00) >> 8) * 15 / 16) << 8 | (((ocol & 0xFF0000) >> 16) * 15 / 16) << 16;
                }
                textureBC.setColor(x + 3, y + 3, 0xFF000000 | col);
            }
        }
    }
    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT);
    GL11.glTranslatef((float) tx + 0.5F, (float) ty + 0.5F, (float) tz + 0.5F);
    GL11.glScalef(Z_OFFSET, Z_OFFSET, Z_OFFSET);
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
    textureBC.updateTexture();
    // RenderEntityBlock.RenderInfo renderBox = new RenderEntityBlock.RenderInfo();
    // renderBox.setRenderSingleSide(((BlockBuildCraft)
    // zonePlan.getBlockType()).getFrontSide(zonePlan.getBlockMetadata()));
    // renderBox.texture = fakeIcon;
    // renderBox.light = 15;
    // RenderEntityBlock.INSTANCE.renderBlock(renderBox);
    GL11.glPopAttrib();
    GL11.glPopMatrix();
}
Also used : DynamicTextureBC(buildcraft.lib.client.sprite.DynamicTextureBC) TileZonePlan(buildcraft.robotics.TileZonePlan)

Example 2 with DynamicTextureBC

use of buildcraft.lib.client.sprite.DynamicTextureBC in project BuildCraft by BuildCraft.

the class RenderZonePlanner method createTexture.

private static DynamicTextureBC createTexture(TileZonePlanner tile, EnumFacing side) {
    DynamicTextureBC texture = new DynamicTextureBC(TEXTURE_WIDTH, TEXTURE_HEIGHT);
    for (int textureX = 0; textureX < TEXTURE_WIDTH; textureX++) {
        for (int textureY = 0; textureY < TEXTURE_HEIGHT; textureY++) {
            int posX;
            int posZ;
            int scale = 4;
            int offset1 = (textureX - TEXTURE_WIDTH / 2) * scale;
            int offset2 = (textureY - TEXTURE_HEIGHT / 2) * scale;
            switch(side) {
                case NORTH:
                    posX = tile.getPos().getX() + offset1;
                    posZ = tile.getPos().getZ() - offset2;
                    break;
                case EAST:
                    posX = tile.getPos().getX() + offset2;
                    posZ = tile.getPos().getZ() + offset1;
                    break;
                case SOUTH:
                    posX = tile.getPos().getX() + offset1;
                    posZ = tile.getPos().getZ() + offset2;
                    break;
                case WEST:
                default:
                    posX = tile.getPos().getX() - offset2;
                    posZ = tile.getPos().getZ() + offset1;
                    break;
            }
            ChunkPos chunkPos = new ChunkPos(posX >> 4, posZ >> 4);
            texture.setColor(textureX, textureY, -1);
            ZonePlannerMapChunkKey key = new ZonePlannerMapChunkKey(chunkPos, tile.getWorld().provider.getDimension(), tile.getLevel());
            ZonePlannerMapChunk zonePlannerMapChunk = ZonePlannerMapDataClient.INSTANCE.getChunk(tile.getWorld(), key);
            if (zonePlannerMapChunk != null) {
                texture.setColor(textureX, textureY, zonePlannerMapChunk.getColour(posX, posZ) | 0xFF_00_00_00);
            } else {
                return null;
            }
        }
    }
    return texture;
}
Also used : DynamicTextureBC(buildcraft.lib.client.sprite.DynamicTextureBC) ZonePlannerMapChunkKey(buildcraft.robotics.zone.ZonePlannerMapChunkKey) ChunkPos(net.minecraft.util.math.ChunkPos) ZonePlannerMapChunk(buildcraft.robotics.zone.ZonePlannerMapChunk)

Example 3 with DynamicTextureBC

use of buildcraft.lib.client.sprite.DynamicTextureBC in project BuildCraft by BuildCraft.

the class RenderZonePlanner method render.

@Override
public final void render(TileZonePlanner tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    Minecraft.getMinecraft().mcProfiler.startSection("bc");
    Minecraft.getMinecraft().mcProfiler.startSection("zone");
    double offset = 0.001;
    double minX = 3 / 16D - offset;
    double maxX = 13 / 16D + offset;
    double minY = 5 / 16D - offset;
    double maxY = 13 / 16D + offset;
    double minZ = -offset;
    double maxZ = 1 + offset;
    IBlockState state = tile.getWorld().getBlockState(tile.getPos());
    if (state.getBlock() != BCRoboticsBlocks.zonePlanner) {
        return;
    }
    EnumFacing side = state.getValue(BuildCraftProperties.BLOCK_FACING).getOpposite();
    DynamicTextureBC texture = getTexture(tile, side);
    if (texture == null) {
        return;
    }
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();
    texture.updateTexture();
    texture.bindGlTexture();
    GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
    GlStateManager.disableTexture2D();
    GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
    GlStateManager.disableBlend();
    GlStateManager.disableCull();
    if (Minecraft.isAmbientOcclusionEnabled()) {
        GlStateManager.shadeModel(GL11.GL_SMOOTH);
    } else {
        GlStateManager.shadeModel(GL11.GL_FLAT);
    }
    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    buffer.setTranslation(x, y, z);
    Vec3d min;
    Vec3d max;
    float minU = 0;
    float maxU = texture.getMaxU();
    float minV = 0;
    float maxV = texture.getMaxV();
    switch(side) {
        case NORTH:
            min = new Vec3d(minX, minY, maxZ);
            max = new Vec3d(maxX, maxY, maxZ);
            break;
        case EAST:
            min = new Vec3d(minZ, minY, minX);
            max = new Vec3d(minZ, maxY, maxX);
            break;
        case SOUTH:
            min = new Vec3d(minX, minY, minZ);
            max = new Vec3d(maxX, maxY, minZ);
            break;
        case WEST:
        default:
            min = new Vec3d(maxZ, minY, minX);
            max = new Vec3d(maxZ, maxY, maxX);
            break;
    }
    MutableVertex vertex = new MutableVertex();
    vertex.colouri(-1);
    vertex.lighti(0xF, 0xF);
    vertex.positiond(min.x, min.y, min.z).texf(minU, minV).render(buffer);
    vertex.positiond(max.x, min.y, max.z).texf(maxU, minV).render(buffer);
    vertex.positiond(max.x, max.y, max.z).texf(maxU, maxV).render(buffer);
    vertex.positiond(min.x, max.y, min.z).texf(minU, maxV).render(buffer);
    buffer.setTranslation(0, 0, 0);
    tessellator.draw();
    RenderHelper.enableStandardItemLighting();
    Minecraft.getMinecraft().mcProfiler.endSection();
    Minecraft.getMinecraft().mcProfiler.endSection();
}
Also used : MutableVertex(buildcraft.lib.client.model.MutableVertex) DynamicTextureBC(buildcraft.lib.client.sprite.DynamicTextureBC) IBlockState(net.minecraft.block.state.IBlockState) Tessellator(net.minecraft.client.renderer.Tessellator) EnumFacing(net.minecraft.util.EnumFacing) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) Vec3d(net.minecraft.util.math.Vec3d)

Example 4 with DynamicTextureBC

use of buildcraft.lib.client.sprite.DynamicTextureBC in project BuildCraft by BuildCraft.

the class GuiZonePlan method toFullscreen.

private void toFullscreen() {
    if (blocksPerPixel > 4.0f) {
        blocksPerPixel = 4.0f;
    }
    mapWidth = this.mc.displayWidth;
    mapHeight = this.mc.displayHeight;
    getContainer().mapTexture = new DynamicTextureBC(mapWidth, mapHeight);
    currentSelection = new DynamicTextureBC(mapWidth, mapHeight);
    uploadMap();
    refreshSelectedArea();
    container.inventorySlots = new LinkedList<>();
    buttonList = new LinkedList<>();
}
Also used : DynamicTextureBC(buildcraft.lib.client.sprite.DynamicTextureBC)

Example 5 with DynamicTextureBC

use of buildcraft.lib.client.sprite.DynamicTextureBC in project BuildCraft by BuildCraft.

the class GuiZonePlan method toWindowed.

private void toWindowed() {
    mapWidth = 213;
    mapHeight = 100;
    getContainer().mapTexture = new DynamicTextureBC(mapWidth, mapHeight);
    currentSelection = new DynamicTextureBC(mapWidth, mapHeight);
    uploadMap();
    refreshSelectedArea();
    container.inventorySlots = inventorySlots;
    buttonList = savedButtonList;
}
Also used : DynamicTextureBC(buildcraft.lib.client.sprite.DynamicTextureBC)

Aggregations

DynamicTextureBC (buildcraft.lib.client.sprite.DynamicTextureBC)5 MutableVertex (buildcraft.lib.client.model.MutableVertex)1 TileZonePlan (buildcraft.robotics.TileZonePlan)1 ZonePlannerMapChunk (buildcraft.robotics.zone.ZonePlannerMapChunk)1 ZonePlannerMapChunkKey (buildcraft.robotics.zone.ZonePlannerMapChunkKey)1 IBlockState (net.minecraft.block.state.IBlockState)1 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)1 Tessellator (net.minecraft.client.renderer.Tessellator)1 EnumFacing (net.minecraft.util.EnumFacing)1 ChunkPos (net.minecraft.util.math.ChunkPos)1 Vec3d (net.minecraft.util.math.Vec3d)1