use of net.minecraft.client.gui.widget.Widget in project iChunUtil by iChun.
the class EventHandlerClient method onGuiInit.
@SubscribeEvent
public void onGuiInit(GuiScreenEvent.InitGuiEvent.Post event) {
if ((iChunUtil.configClient.buttonOptionsShiftOpensMods || ObfHelper.isDevEnvironment()) && event.getGui() instanceof IngameMenuScreen) {
for (Widget widget : event.getWidgetList()) {
if (widget instanceof Button && widget.getMessage() instanceof TranslationTextComponent && ((TranslationTextComponent) widget.getMessage()).getKey().equals("menu.options")) {
Button.IPressable oriPress = ((Button) widget).onPress;
((Button) widget).onPress = button -> {
if (ObfHelper.isDevEnvironment() && !Screen.hasControlDown()) {
if (Screen.hasShiftDown()) {
oriPress.onPress(button);
} else {
Minecraft.getInstance().displayGuiScreen(getConfigGui(Minecraft.getInstance(), Minecraft.getInstance().currentScreen));
}
} else if (iChunUtil.configClient.buttonOptionsShiftOpensMods) {
if (Screen.hasShiftDown()) {
Minecraft.getInstance().displayGuiScreen(new net.minecraftforge.fml.client.gui.screen.ModListScreen(Minecraft.getInstance().currentScreen));
} else {
oriPress.onPress(button);
}
}
};
break;
}
}
}
}
use of net.minecraft.client.gui.widget.Widget in project Random-Things by lumien231.
the class AdvancedRedstoneTorchScreen method drawGuiContainerForegroundLayer.
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
RenderHelper.disableStandardItemLighting();
this.font.drawString(I18n.format("gui.randomthings.advanced_redstone_torch.gs"), 8, 5, 0);
this.font.drawString(I18n.format("gui.randomthings.advanced_redstone_torch.rs"), 13, 29, 0);
String signalStrengthOffString = this.container.strengthGreen.get() + "";
this.font.drawString(signalStrengthOffString, xSize / 2 - this.font.getStringWidth(signalStrengthOffString) / 2, 16, DyeColor.GREEN.getFireworkColor());
String signalStrengthOnString = this.container.strengthRed.get() + "";
this.font.drawString(signalStrengthOnString, xSize / 2 - this.font.getStringWidth(signalStrengthOnString) / 2, 40, DyeColor.RED.getFireworkColor());
for (Widget widget : this.buttons) {
if (widget.isHovered()) {
widget.renderToolTip(mouseX - this.guiLeft, mouseY - this.guiTop);
break;
}
}
RenderHelper.enableGUIStandardItemLighting();
}
use of net.minecraft.client.gui.widget.Widget in project simple-voice-chat by henkelmax.
the class CreateGroupScreen method render.
@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float delta) {
RenderSystem.color4f(1F, 1F, 1F, 1F);
minecraft.getTextureManager().bind(TEXTURE);
blit(matrixStack, guiLeft, guiTop, 0, 0, xSize, ySize, 512, 512);
playerList.drawGuiContainerBackgroundLayer(matrixStack, delta, mouseX, mouseY);
playerList.drawGuiContainerForegroundLayer(matrixStack, mouseX, mouseY);
for (Widget widget : buttons) {
widget.render(matrixStack, mouseX, mouseY, delta);
}
font.draw(matrixStack, new TranslationTextComponent("message.voicechat.join_create_group"), guiLeft + 8, guiTop + 5, FONT_COLOR);
font.draw(matrixStack, new TranslationTextComponent("message.voicechat.group_name"), guiLeft + 8, guiTop + 21, FONT_COLOR);
font.draw(matrixStack, new TranslationTextComponent("message.voicechat.join_group"), guiLeft + 8, guiTop + 38, FONT_COLOR);
}
use of net.minecraft.client.gui.widget.Widget in project BoundingBoxOutlineReloaded by irtimaled.
the class MixinOptionsScreen method initGui.
@Inject(method = "init", at = @At("RETURN"))
private void initGui(CallbackInfo ci) {
// shuffle middle buttons up by 12 px to make space
int top = this.height / 6 + 42;
int bottom = this.height / 6 + 168;
for (Widget button : buttons) {
if (button.y >= top && button.y < bottom)
button.y -= 12;
}
SettingsScreenButton button = new SettingsScreenButton(this.width / 2 - 155, top + 84, 150, "BBOR", this);
this.buttons.add(this.buttons.size() - 1, button);
this.children.add(this.children.size() - 1, button);
}
use of net.minecraft.client.gui.widget.Widget in project Mekanism by mekanism.
the class GuiMekanism method renderLabels.
@Override
protected void renderLabels(@Nonnull MatrixStack matrix, int mouseX, int mouseY) {
matrix.translate(0, 0, 300);
RenderSystem.translatef(-leftPos, -topPos, 0);
children().stream().filter(c -> c instanceof GuiElement).forEach(c -> ((GuiElement) c).onDrawBackground(matrix, mouseX, mouseY, MekanismRenderer.getPartialTick()));
RenderSystem.translatef(leftPos, topPos, 0);
drawForegroundText(matrix, mouseX, mouseY);
int xAxis = mouseX - leftPos;
int yAxis = mouseY - topPos;
// first render general foregrounds
maxZOffset = 200;
int zOffset = 200;
for (Widget widget : this.buttons) {
if (widget instanceof GuiElement) {
matrix.pushPose();
((GuiElement) widget).onRenderForeground(matrix, mouseX, mouseY, zOffset, zOffset);
matrix.popPose();
}
}
// now render overlays in reverse-order (i.e. back to front)
zOffset = maxZOffset;
for (LRU<GuiWindow>.LRUIterator iter = getWindowsDescendingIterator(); iter.hasNext(); ) {
GuiWindow overlay = iter.next();
zOffset += 150;
matrix.pushPose();
overlay.onRenderForeground(matrix, mouseX, mouseY, zOffset, zOffset);
if (iter.hasNext()) {
// if this isn't the focused window, render a 'blur' effect over it
overlay.renderBlur(matrix);
}
matrix.popPose();
}
// then render tooltips, translating above max z offset to prevent clashing
GuiElement tooltipElement = getWindowHovering(mouseX, mouseY);
if (tooltipElement == null) {
for (int i = buttons.size() - 1; i >= 0; i--) {
Widget widget = buttons.get(i);
if (widget instanceof GuiElement && widget.isMouseOver(mouseX, mouseY)) {
tooltipElement = (GuiElement) widget;
break;
}
}
}
// translate forwards using RenderSystem. this should never have to happen as we do all the necessary translations with MatrixStacks,
// but Minecraft has decided to not fully adopt MatrixStacks for many crucial ContainerScreen render operations. should be re-evaluated
// when mc updates related logic on their end (IMPORTANT)
RenderSystem.translatef(0, 0, maxZOffset);
if (tooltipElement != null) {
tooltipElement.renderToolTip(matrix, xAxis, yAxis);
}
// render item tooltips
RenderSystem.translatef(-leftPos, -topPos, 0);
renderTooltip(matrix, mouseX, mouseY);
RenderSystem.translatef(leftPos, topPos, 0);
// IMPORTANT: additional hacky translation so held items render okay. re-evaluate as discussed above
RenderSystem.translatef(0, 0, 200);
}
Aggregations