@Override public void onChangeSliderValue(GuiSlider slider) { if (slider.id == 5) { colourR = (int) Math.round( slider.sliderValue * (slider.maxValue - slider.minValue) + slider.minValue); stand.colourR = colourR; } else if (slider.id == 6) { colourG = (int) Math.round( slider.sliderValue * (slider.maxValue - slider.minValue) + slider.minValue); stand.colourG = colourG; } else if (slider.id == 7) { colourB = (int) Math.round( slider.sliderValue * (slider.maxValue - slider.minValue) + slider.minValue); stand.colourB = colourB; } else if (slider.id == 15) { alpha = (int) Math.round( slider.sliderValue * (slider.maxValue - slider.minValue) + slider.minValue); stand.alpha = alpha; } }
public void exitWithoutUpdate() { mc.displayGuiScreen(null); stand.hatName = prevHatName; stand.colourR = prevColourR; stand.colourG = prevColourG; stand.colourB = prevColourB; stand.head = prevHead; stand.gameProfile = prevGameProfile; stand.hasBase = prevBase; stand.hasStand = prevStandPost; stand.getWorld().markBlockForUpdate(stand.getPos()); }
public void randomize() { if (view == VIEW_HATS) { if (hatsToShow.size() > 0) { int randVal = rand.nextInt(hatsToShow.size()); String hatName = (String) hatsToShow.get(randVal); stand.hatName = hatName.toLowerCase(); colourR = colourG = colourB = alpha = 255; stand.colourR = 255; stand.colourG = 255; stand.colourB = 255; stand.alpha = 255; pageNumber = randVal / 6; if (isShiftKeyDown()) { view = VIEW_COLOURIZER; updateButtonList(); randomizeColour(); view = VIEW_HATS; } updateButtonList(); } } else if (view == VIEW_COLOURIZER) { if (isShiftKeyDown()) { colourR = colourG = colourB = alpha = 255; stand.colourR = 255; stand.colourG = 255; stand.colourB = 255; stand.alpha = 255; updateButtonList(); } else { randomizeColour(); } } }
public void exitAndUpdate() { confirmed = true; mc.displayGuiScreen(null); HatStand.channel.sendToServer( new PacketStandHatInfo( stand.getPos(), stand.hatName, colourR, colourG, colourB, alpha, head, base, standPost)); }
public void drawPlayerOnGui(int par1, int par2, int par3, float par4, float par5) { if (stand != null) { RenderHelper.enableGUIStandardItemLighting(); GlStateManager.enableColorMaterial(); GlStateManager.pushMatrix(); // GlStateManager.disableAlpha(); GlStateManager.translate((float) par1, (float) par2, 50.0F); GlStateManager.translate(23F, -20.0F, 0.0F); GlStateManager.scale((float) (-par3), (float) par3, (float) par3); GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F); GlStateManager.rotate(-80.0F, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(-10.0F, 0.0F, 0.0F, 1.0F); // GlStateManager.rotate(-((float)Math.atan((double)(0.0F / 40.0F))) * 20.0F, 1.0F, // 0.0F, 0.0F); Minecraft.getMinecraft().getRenderManager().playerViewY = 180.0F; GlStateManager.translate(0.5D, 0.5D, 0.5D); GlStateManager.translate(0.0D, -0.5D, 0.0D); GlStateManager.rotate( -((float) Math.atan((double) (par4 / 40.0F))) * 20.0F, 0.0F, 1.0F, 0.0F); GlStateManager.rotate( -((float) Math.atan((double) (par5 / 40.0F))) * 20.0F, 0.0F, 0.0F, -1.0F); GlStateManager.translate(0.0D, 0.5D, 0.0D); if (stand.orientation == 0) { GlStateManager.rotate(180F, 0.0F, 1.0F, 0.0F); } else if (stand.orientation == 1) { GlStateManager.rotate(-90F, 0.0F, 1.0F, 0.0F); } else if (stand.orientation == 3) { GlStateManager.rotate(90F, 0.0F, 1.0F, 0.0F); } GlStateManager.enableNormalize(); this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); IBlockState state = HatStand.blockHatStand .getDefaultState() .withProperty( BlockHatStand.TYPE, stand.hasBase ? stand.hasStand ? stand.hatName.isEmpty() ? 0 : 1 : stand.isOnFloor ? 2 : EnumFacing.getFront(stand.sideOn).ordinal() + 2 : 3); RendererHelper.renderBakedModel( mc.getBlockRendererDispatcher().getBlockModelShapes().getModelForState(state), -1, null); GlStateManager.translate(-0.5D, -0.5D, -0.5D); HatInfoClient info = stand.info; if (tempInfo == null || info == null || !(tempInfo.hatName.equalsIgnoreCase(stand.hatName) && tempInfo.colourR == stand.colourR && tempInfo.colourG == stand.colourG && tempInfo.colourB == stand.colourB && tempInfo.alpha == stand.alpha)) { tempInfo = new HatInfoClient( stand.hatName, stand.colourR, stand.colourG, stand.colourB, stand.alpha); } stand.info = tempInfo; TileRendererHatStand.renderer.renderHatStand(stand, 0, 0, 0, 1.0F, -1, stand.gameProfile); stand.info = info; // GlStateManager.enableAlpha(); GlStateManager.popMatrix(); GlStateManager.disableRescaleNormal(); OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); GlStateManager.disableTexture2D(); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); RenderHelper.disableStandardItemLighting(); } }
public void removeHat() { stand.hatName = ""; updateButtonList(); }
@Override protected void actionPerformed(GuiButton btn) { if (!justClickedButton) { if (btn.id == ID_DONE_SELECT) { exitAndUpdate(); } if (btn.id == ID_PAGE_LEFT) { switchPage(true); } else if (btn.id == ID_PAGE_RIGHT) { switchPage(false); } else if (btn.id == ID_CLOSE) { exitWithoutUpdate(); } else if (btn.id == ID_NONE) { removeHat(); } else if (btn.id == ID_HAT_COLOUR_SWAP) { toggleHatsColourizer(); } else if (btn.id == ID_RANDOM) { randomize(); } else if (btn.id == ID_HEAD) { stand.head++; if (stand.head == TileEntityHatStand.headNames.length) { stand.head = 0; } if (stand.head == 4) { stand.gameProfile = Minecraft.getMinecraft().thePlayer.getGameProfile(); } head = stand.head; justClickedButton = true; updateButtonList(); } else if (btn.id == ID_BASE) { base = !base; stand.hasBase = base; justClickedButton = true; if (!base) { stand.hasStand = standPost = false; } stand.getWorld().markBlockForUpdate(stand.getPos()); updateButtonList(); } else if (btn.id == ID_STAND) { standPost = !standPost; stand.hasStand = standPost; justClickedButton = true; stand.getWorld().markBlockForUpdate(stand.getPos()); updateButtonList(); } else if (btn.id >= ID_HAT_START_ID) { justClickedButton = true; stand.hatName = btn.displayString.toLowerCase(); colourR = colourG = colourB = alpha = 255; stand.colourR = 255; stand.colourG = 255; stand.colourB = 255; stand.alpha = 255; updateButtonList(); } } }
@Override public void onGuiClosed() { if (!confirmed) { stand.hatName = prevHatName; stand.colourR = prevColourR; stand.colourG = prevColourG; stand.colourB = prevColourB; stand.alpha = prevAlpha; stand.head = prevHead; stand.gameProfile = prevGameProfile; stand.hasBase = prevBase; stand.hasStand = prevStandPost; stand.getWorld().markBlockForUpdate(stand.getPos()); } Keyboard.enableRepeatEvents(false); }