@SideOnly(Side.CLIENT) private void sendSyncPacket(byte type_, int value_) { ByteArrayOutputStream bos = new ByteArrayOutputStream(42); DataOutputStream outputStream = new DataOutputStream(bos); int x = tile.xCoord; int y = tile.yCoord; int z = tile.zCoord; int d = tile.getWorldObj().provider.dimensionId; System.out.println("Sending Colour:" + value_); try { outputStream.writeByte(type_); outputStream.writeInt(value_); outputStream.writeInt(x); outputStream.writeInt(y); outputStream.writeInt(z); outputStream.writeInt(d); } catch (Exception e_) { e_.printStackTrace(); } // Packet250CustomPayload packet = new Packet250CustomPayload(); // packet.channel = "DD_FLAG_SYNC"; // packet.data = bos.toByteArray(); // packet.length = bos.size(); // PacketDispatcher.sendPacketToServer(packet); }
@SideOnly(Side.CLIENT) private void colorClicked(int hitx_, int hity_, int btn_) { hitx_ += 4; hity_ += 105; hitx_ = Math.abs(hitx_); hity_ = hity_ * -1; System.out.println("THR:" + hitx_ + "," + hity_); // hitx_ -= 119; // hity_ -= 124; // odd numbers rounded down if (hitx_ % 2 != 0) { hitx_ -= 1; } if (hity_ % 2 != 0) { hity_ -= 1; } hity_ /= 2; hitx_ /= 2; System.out.println("CLICKED:" + hitx_ + "," + hity_); double[] xshift = this.shiftColoursX(hitx_, hity_); double[] yshift = this.shiftColoursY(hity_, xshift); double r = yshift[0]; double g = yshift[1]; double b = yshift[2]; // System.out.println("YSHIFT\tR:" + r + "\tG:" + g + "\tB:" + b); if (tile != null) { tile.setPrimaryPaintColour(this.compressColourFloats((float) r, (float) g, (float) b)); } this.sendSyncPacket((byte) 0, this.compressColourFloats(r, g, b)); }
@Override @SideOnly(Side.CLIENT) protected void drawGuiContainerBackgroundLayer(float f_, int i_, int j_) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.renderEngine.bindTexture(texture); int x = (this.width - this.xSize) / 2; int y = (this.height - this.ySize) / 2; // int x = 115; // int y = 20; this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); this.mc.renderEngine.bindTexture(flagSquare); if (tile != null) { int col = tile.getPrimaryPaintColour(); double[] colourFloats = this.decompressColourFloats(col); this.setColour((float) colourFloats[0], (float) colourFloats[1], (float) colourFloats[2]); this.drawTexturedModalRect(x + 4, y + 50, 0, 0, 20, 20); } float r = 0.0F; float b = 0.0F; float g = 0.0F; int xinc = 2; int yinc = 2; int xpos = x + 4; int ypos = y + 104; int shades = 16; int brights = 12; int darks = 12; // Draws a textured rectangle at the stored z-value. Args: x, y, u, v, width, height // RED ADDING GREEN r = 1.0F; g = 0.0F; b = 0.0F; for (int i = 0; i < shades; i++) { this.setColour(r, g, b); this.drawTexturedModalRect(xpos, ypos, 0, 0, colourXSize, colourYSize); this.drawColourBrights(xpos, ypos, brights, r, g, b); this.drawColourDarks(xpos, ypos, darks, r, g, b); g += colInc; xpos += xinc; } g = 1.0F; r = 1.0F; b = 0.0F; // GREEN SUBTRACTING RED for (int i = 0; i < shades; i++) { this.setColour(r, g, b); this.drawTexturedModalRect(xpos, ypos, 0, 0, colourXSize, colourYSize); this.drawColourBrights(xpos, ypos, brights, r, g, b); this.drawColourDarks(xpos, ypos, darks, r, g, b); r -= colInc; xpos += xinc; } g = 1.0F; r = 0.0F; b = 0.0F; // GREEN ADDING BLUE for (int i = 0; i < shades; i++) { this.setColour(r, g, b); this.drawTexturedModalRect(xpos, ypos, 0, 0, colourXSize, colourYSize); this.drawColourBrights(xpos, ypos, brights, r, g, b); this.drawColourDarks(xpos, ypos, darks, r, g, b); b += colInc; xpos += xinc; } g = 1.0F; b = 1.0F; r = 0.0F; // BLUE SUBTRACTING GREEN for (int i = 0; i < shades; i++) { this.setColour(r, g, b); this.drawTexturedModalRect(xpos, ypos, 0, 0, colourXSize, colourYSize); this.drawColourBrights(xpos, ypos, brights, r, g, b); this.drawColourDarks(xpos, ypos, darks, r, g, b); g -= colInc; xpos += xinc; } b = 1.0F; r = 0.0F; g = 0.0F; // BLUE ADDING RED for (int i = 0; i < shades; i++) { this.setColour(r, g, b); this.drawTexturedModalRect(xpos, ypos, 0, 0, colourXSize, colourYSize); this.drawColourBrights(xpos, ypos, brights, r, g, b); this.drawColourDarks(xpos, ypos, darks, r, g, b); r += colInc; xpos += xinc; } r = 1.0f; b = 1.0f; g = 0.0F; // RED SUBTRACTING BLUE for (int i = 0; i < shades; i++) { this.setColour(r, g, b); this.drawTexturedModalRect(xpos, ypos, 0, 0, colourXSize, colourYSize); this.drawColourBrights(xpos, ypos, brights, r, g, b); this.drawColourDarks(xpos, ypos, darks, r, g, b); b -= colInc; xpos += xinc; } }