Search in sources :

Example 1 with CubeColour

use of riskyken.armourersWorkshop.common.skin.cubes.CubeColour in project Armourers-Workshop by RiskyKen.

the class ArmourerWorldHelper method loadSkinBlockIntoWorld.

private static void loadSkinBlockIntoWorld(World world, int x, int y, int z, int xOrigin, int yOrigin, int zOrigin, ICube blockData, ForgeDirection direction, int meta, SkinCubeData cubeData, int index, boolean mirror) {
    byte[] loc = cubeData.getCubeLocation(index);
    int shiftX = -loc[0] - 1;
    int shiftY = loc[1] + 1;
    int shiftZ = loc[2];
    if (mirror) {
        shiftX = loc[0];
    }
    int targetX = x + shiftX + xOrigin;
    int targetY = y + yOrigin - shiftY;
    int targetZ = z + shiftZ + zOrigin;
    if (world.getBlock(targetX, targetY, targetZ) == ModBlocks.boundingBox) {
        world.setBlockToAir(targetX, targetY, targetZ);
        world.removeTileEntity(targetX, targetY, targetZ);
    }
    if (world.isAirBlock(targetX, targetY, targetZ)) {
        Block targetBlock = blockData.getMinecraftBlock();
        world.setBlock(targetX, targetY, targetZ, targetBlock);
        world.setBlockMetadataWithNotify(targetX, targetY, targetZ, meta, 2);
        TileEntity te = world.getTileEntity(targetX, targetY, targetZ);
        if (te != null && te instanceof TileEntityColourable) {
            CubeColour cc = new CubeColour();
            for (int i = 0; i < 6; i++) {
                byte[] c = cubeData.getCubeColour(index, i);
                byte paintType = cubeData.getCubePaintType(index, i);
                if (mirror) {
                    if (i == 4) {
                        c = cubeData.getCubeColour(index, 5);
                        paintType = cubeData.getCubePaintType(index, 5);
                    }
                    if (i == 5) {
                        c = cubeData.getCubeColour(index, 4);
                        paintType = cubeData.getCubePaintType(index, 4);
                    }
                }
                cc.setRed(c[0], i);
                cc.setGreen(c[1], i);
                cc.setBlue(c[2], i);
                cc.setPaintType(paintType, i);
            }
            ((TileEntityColourable) te).setColour(cc);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Block(net.minecraft.block.Block) SkinBlock(riskyken.armourersWorkshop.common.skin.type.block.SkinBlock) ICubeColour(riskyken.armourersWorkshop.api.common.skin.cubes.ICubeColour) CubeColour(riskyken.armourersWorkshop.common.skin.cubes.CubeColour) TileEntityColourable(riskyken.armourersWorkshop.common.tileentities.TileEntityColourable)

Example 2 with CubeColour

use of riskyken.armourersWorkshop.common.skin.cubes.CubeColour in project Armourers-Workshop by RiskyKen.

the class GuiMiniArmourerBuildingModel method drawBuildingCubes.

private void drawBuildingCubes(boolean fake) {
    if (cubes == null) {
    // return;
    }
    renderCubes.clear();
    fakeCubeRenders = 0;
    // GL11.glDisable(GL11.GL_NORMALIZE);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    if (fake) {
        GL11.glDisable(GL11.GL_LIGHTING);
        IRectangle3D guideSpace = currentSkinPartType.getGuideSpace();
        for (int ix = 0; ix < guideSpace.getWidth(); ix++) {
            for (int iy = 0; iy < guideSpace.getHeight(); iy++) {
                for (int iz = 0; iz < guideSpace.getDepth(); iz++) {
                    byte x = (byte) (ix + guideSpace.getX());
                    byte y = (byte) (iy + guideSpace.getY());
                    byte z = (byte) (iz + guideSpace.getZ());
                    MiniCube cube = new MiniCube(CubeRegistry.INSTANCE.getCubeFormId((byte) 0));
                    cube.setX(x);
                    cube.setY(y);
                    cube.setZ(z);
                    renderCubes.add(cube);
                }
            }
        }
        fakeCubeRenders = renderCubes.size();
    }
    float scale = 0.0625F;
    int colourId = 1;
    renderCubes.addAll(cubes);
    IRenderBuffer buff = RenderBridge.INSTANCE;
    buff.startDrawingQuads();
    for (int i = 0; i < renderCubes.size(); i++) {
        MiniCube cube = renderCubes.get(i);
        if (cube != null) {
            if (cube.isGlowing() & !fake) {
                GL11.glDisable(GL11.GL_LIGHTING);
                ModRenderHelper.disableLighting();
            }
            ICubeColour colour = new CubeColour();
            if (fake) {
                colour.setColour(GuiMiniArmourerHelper.getColourFromId(colourId).getRGB(), 0);
                colour.setColour(GuiMiniArmourerHelper.getColourFromId(colourId + 1).getRGB(), 1);
                colour.setColour(GuiMiniArmourerHelper.getColourFromId(colourId + 2).getRGB(), 2);
                colour.setColour(GuiMiniArmourerHelper.getColourFromId(colourId + 3).getRGB(), 3);
                colour.setColour(GuiMiniArmourerHelper.getColourFromId(colourId + 4).getRGB(), 4);
                colour.setColour(GuiMiniArmourerHelper.getColourFromId(colourId + 5).getRGB(), 5);
            } else {
                colour = cube.getCubeColour();
            }
            renderArmourBlock((byte) cube.getX(), (byte) cube.getY(), (byte) cube.getZ(), colour, scale, false);
            if (cube.isGlowing() & !fake) {
                ModRenderHelper.enableLighting();
                GL11.glEnable(GL11.GL_LIGHTING);
            }
        }
        colourId += 6;
    }
    buff.draw();
    if (fake) {
        GL11.glEnable(GL11.GL_LIGHTING);
    }
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}
Also used : IRectangle3D(riskyken.armourersWorkshop.api.common.IRectangle3D) ICubeColour(riskyken.armourersWorkshop.api.common.skin.cubes.ICubeColour) MiniCube(riskyken.armourersWorkshop.common.data.MiniCube) IRenderBuffer(riskyken.armourersWorkshop.client.render.IRenderBuffer) ICubeColour(riskyken.armourersWorkshop.api.common.skin.cubes.ICubeColour) CubeColour(riskyken.armourersWorkshop.common.skin.cubes.CubeColour)

Aggregations

ICubeColour (riskyken.armourersWorkshop.api.common.skin.cubes.ICubeColour)2 CubeColour (riskyken.armourersWorkshop.common.skin.cubes.CubeColour)2 Block (net.minecraft.block.Block)1 TileEntity (net.minecraft.tileentity.TileEntity)1 IRectangle3D (riskyken.armourersWorkshop.api.common.IRectangle3D)1 IRenderBuffer (riskyken.armourersWorkshop.client.render.IRenderBuffer)1 MiniCube (riskyken.armourersWorkshop.common.data.MiniCube)1 SkinBlock (riskyken.armourersWorkshop.common.skin.type.block.SkinBlock)1 TileEntityColourable (riskyken.armourersWorkshop.common.tileentities.TileEntityColourable)1