Search in sources :

Example 1 with MiniCube

use of riskyken.armourersWorkshop.common.data.MiniCube in project Armourers-Workshop by RiskyKen.

the class MessageClientGuiMiniArmourerCubeEdit method fromBytes.

@Override
public void fromBytes(ByteBuf buf) {
    String partName = ByteBufUtils.readUTF8String(buf);
    this.skinPartType = SkinTypeRegistry.INSTANCE.getSkinPartFromRegistryName(partName);
    byte cubeId = buf.readByte();
    this.cube = new MiniCube(buf);
    this.remove = buf.readBoolean();
}
Also used : MiniCube(riskyken.armourersWorkshop.common.data.MiniCube)

Example 2 with MiniCube

use of riskyken.armourersWorkshop.common.data.MiniCube in project Armourers-Workshop by RiskyKen.

the class GuiMiniArmourerBuildingModel method cubeClicked.

private void cubeClicked(int cubeId, int cubeFace, int button) {
    if (renderCubes != null && cubeId - 1 < renderCubes.size() & cubeId - 1 >= 0) {
        MiniCube tarCube = renderCubes.get(cubeId - 1);
        if (button == 0) {
            MiniCube newCube = new MiniCube(CubeRegistry.INSTANCE.getCubeFormId((byte) 0));
            newCube.setColour(0xFFFFFFFF);
            ForgeDirection dir = GuiMiniArmourerHelper.getDirectionForCubeFace(cubeFace);
            newCube.setX((byte) (tarCube.getX() + dir.offsetX));
            newCube.setY((byte) (tarCube.getY() + dir.offsetY));
            newCube.setZ((byte) (tarCube.getZ() + dir.offsetZ));
            cubes.add(newCube);
        // newCube.setId((byte) 0);
        /*
                MessageClientGuiMiniArmourerCubeEdit message;
                message = new MessageClientGuiMiniArmourerCubeEdit(currentSkinPartType, newCube, false);
                PacketHandler.networkWrapper.sendToServer(message);
                */
        }
        if (button == 1) {
            for (int i = 0; i < cubes.size(); i++) {
                MiniCube mc = cubes.get(i);
                if (mc.getX() == tarCube.getX()) {
                    if (mc.getY() == tarCube.getY()) {
                        if (mc.getZ() == tarCube.getZ()) {
                            cubes.remove(i);
                            return;
                        }
                    }
                }
            }
        /*
                if (tarCube.getId() == -1) {
                    return;
                }
                */
        /*
                MessageClientGuiMiniArmourerCubeEdit message;
                message = new MessageClientGuiMiniArmourerCubeEdit(currentSkinPartType, tarCube, true);
                PacketHandler.networkWrapper.sendToServer(message);
                */
        }
    }
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) MiniCube(riskyken.armourersWorkshop.common.data.MiniCube)

Example 3 with MiniCube

use of riskyken.armourersWorkshop.common.data.MiniCube in project Armourers-Workshop by RiskyKen.

the class GuiMiniArmourerBuildingModel method renderModels.

private void renderModels(int mouseX, int mouseY) {
    float scale = 0.0625F;
    GL11.glPushMatrix();
    GL11.glTranslatef(parent.width / 2, parent.height / 2, 500.0F);
    GL11.glScalef((float) (-zoom), (float) zoom, (float) zoom);
    GL11.glRotatef(180F, 0F, 1F, 0F);
    GL11.glRotatef(pitch, 1.0F, 0.0F, 0.0F);
    GL11.glRotatef(rotation, 0F, 1F, 0F);
    GL11.glTranslated(0, 1 * scale, 0);
    GL11.glScalef(-1, -1, 1);
    if (hoverCubeId != 0 && renderCubes != null) {
        int cubeId = (int) Math.ceil((double) hoverCubeId / 6);
        int cubeFace = cubeId * 6 - hoverCubeId;
        if (cubeId - 1 < renderCubes.size() & cubeId - 1 >= 0) {
            MiniCube tarCube = renderCubes.get(cubeId - 1);
            MiniCube newCube = new MiniCube(CubeRegistry.INSTANCE.getCubeFormId((byte) 0));
            ForgeDirection dir = GuiMiniArmourerHelper.getDirectionForCubeFace(cubeFace);
            newCube.setX((byte) (tarCube.getX() + dir.offsetX));
            newCube.setY((byte) (tarCube.getY() + dir.offsetY));
            newCube.setZ((byte) (tarCube.getZ() + dir.offsetZ));
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            IRenderBuffer buff = RenderBridge.INSTANCE;
            buff.startDrawingQuads();
            renderArmourBlock((byte) newCube.getX(), (byte) newCube.getY(), (byte) newCube.getZ(), newCube.getColour(), scale, true);
            buff.draw();
            GL11.glEnable(GL11.GL_TEXTURE_2D);
            GL11.glDisable(GL11.GL_BLEND);
        }
    }
    // Gui.drawRect(0, 0, parent.width, parent.height, 0xFF000000);
    drawBuildingCubes(false);
    GL11.glScalef(-1, -1, 1);
    RenderHelper.enableStandardItemLighting();
    mc.renderEngine.bindTexture(mc.thePlayer.getLocationSkin());
    if (skinPointer != null) {
        Skin skin = ClientSkinCache.INSTANCE.getSkin(skinPointer);
        if (skin != null) {
            for (int i = 0; i < skin.getParts().size(); i++) {
                SkinPart part = skin.getParts().get(i);
                if (part.getPartType() == currentSkinPartType) {
                    SkinPartRenderer.INSTANCE.renderPart(part, scale, skinPointer.getSkinDye(), null, false);
                }
            }
        }
    }
    if (currentSkinPartType != null) {
        GL11.glTranslated(0, -currentSkinPartType.getBuildingSpace().getY() * scale, 0);
        currentSkinPartType.renderBuildingGuide(scale, true, false);
    // SkinRenderHelper.renderBuildingGrid(currentSkinPartType, scale);
    }
    /*
        if (currentSkinType != null) {
            SkinRenderHelper.renderBuildingGuide(currentSkinType, scale, true, false);
            SkinRenderHelper.renderBuildingGrid(currentSkinType, scale);
        }
        */
    GL11.glPopMatrix();
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) MiniCube(riskyken.armourersWorkshop.common.data.MiniCube) IRenderBuffer(riskyken.armourersWorkshop.client.render.IRenderBuffer) Skin(riskyken.armourersWorkshop.common.skin.data.Skin) SkinPart(riskyken.armourersWorkshop.common.skin.data.SkinPart)

Example 4 with MiniCube

use of riskyken.armourersWorkshop.common.data.MiniCube 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

MiniCube (riskyken.armourersWorkshop.common.data.MiniCube)4 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)2 IRenderBuffer (riskyken.armourersWorkshop.client.render.IRenderBuffer)2 IRectangle3D (riskyken.armourersWorkshop.api.common.IRectangle3D)1 ICubeColour (riskyken.armourersWorkshop.api.common.skin.cubes.ICubeColour)1 CubeColour (riskyken.armourersWorkshop.common.skin.cubes.CubeColour)1 Skin (riskyken.armourersWorkshop.common.skin.data.Skin)1 SkinPart (riskyken.armourersWorkshop.common.skin.data.SkinPart)1