|
2 | 2 |
|
3 | 3 | import com.mojang.blaze3d.platform.GlStateManager; |
4 | 4 | import com.mojang.blaze3d.systems.RenderSystem; |
| 5 | +import com.mojang.blaze3d.vertex.PoseStack; |
5 | 6 | import net.minecraft.client.Minecraft; |
6 | 7 | import net.minecraft.client.gui.Font; |
7 | 8 | import net.minecraft.client.gui.GuiGraphics; |
8 | 9 | import net.minecraft.client.gui.components.Button; |
9 | 10 | import net.minecraft.client.gui.components.EditBox; |
10 | 11 | import net.minecraft.client.gui.components.ObjectSelectionList; |
| 12 | +import net.minecraft.client.renderer.RenderType; |
11 | 13 | import net.minecraft.client.renderer.entity.ItemRenderer; |
12 | 14 | import net.minecraft.client.resources.language.I18n; |
13 | 15 | import net.minecraft.locale.Language; |
@@ -87,6 +89,7 @@ public void init() { |
87 | 89 |
|
88 | 90 | this.search = new EditBox(getFontRender(), getWidth() / 2 - 137, getHeight() / 2 - 105, 202, 18, Component.empty()); |
89 | 91 | this.search.setCanLoseFocus(true); |
| 92 | + addRenderableWidget(this.search); |
90 | 93 |
|
91 | 94 | // side bar buttons |
92 | 95 | addRenderableWidget(new SupportButtonInner((getWidth() / 2) + 79, getHeight() / 2 - 60, 120, 20, I18n.get("xray.input.add"), "xray.tooltips.add_block", button -> { |
@@ -222,11 +225,17 @@ public boolean mouseClicked(double x, double y, int mouse) { |
222 | 225 |
|
223 | 226 | @Override |
224 | 227 | public void renderExtra(GuiGraphics graphics, int x, int y, float partialTicks) { |
225 | | - this.search.render(graphics, x, y, partialTicks); |
226 | | - this.scrollList.render(graphics, x, y, partialTicks); |
227 | | - |
228 | 228 | if (!search.isFocused() && search.getValue().equals("")) |
229 | 229 | graphics.drawString(getFontRender(), I18n.get("xray.single.search"), getWidth() / 2 - 130, getHeight() / 2 - 101, Color.GRAY.getRGB()); |
| 230 | + |
| 231 | + PoseStack pose = graphics.pose(); |
| 232 | + pose.pushPose(); |
| 233 | + pose.translate(this.getWidth() / 2f - 140, ((this.getHeight() / 2f) - 3) + 120, 0); |
| 234 | + pose.scale(0.75f, 0.75f, 0.75f); |
| 235 | + graphics.drawString(this.font, Component.translatable("xray.tooltips.edit1"), 0, 0, Color.GRAY.getRGB()); |
| 236 | + pose.translate(0, 12, 0); |
| 237 | + graphics.drawString(this.font, Component.translatable("xray.tooltips.edit2"), 0, 0, Color.GRAY.getRGB()); |
| 238 | + pose.popPose(); |
230 | 239 | } |
231 | 240 |
|
232 | 241 | @Override |
@@ -310,27 +319,15 @@ public void render(GuiGraphics guiGraphics, int entryIdx, int top, int left, int |
310 | 319 | guiGraphics.renderItem(blockData.getItemStack(), left, top + 7); |
311 | 320 | guiGraphics.renderItemDecorations(font, blockData.getItemStack(), left, top + 7); // TODO: verify |
312 | 321 |
|
313 | | - if (mouseX > left && mouseX < (left + entryWidth) && mouseY > top && mouseY < (top + entryHeight) && mouseY < (this.parent.getY() + this.parent.getHeight()) && mouseY > this.parent.getY()) { |
314 | | - guiGraphics.renderTooltip( |
315 | | - font, |
316 | | - Language.getInstance().getVisualOrder(Arrays.asList(Component.translatable("xray.tooltips.edit1"), Component.translatable("xray.tooltips.edit2"))), |
317 | | - left + 15, |
318 | | - (entryIdx == this.parent.children().size() - 1 ? (top - (entryHeight - 20)) : (top + (entryHeight + 15))) |
319 | | - ); |
320 | | - } |
321 | | - |
322 | | - Color color = new Color(blockData.getColor()); |
323 | | - |
324 | 322 | var stack = guiGraphics.pose(); |
325 | 323 | stack.pushPose(); |
326 | 324 | RenderSystem.enableBlend(); |
327 | 325 | RenderSystem.blendFunc( |
328 | 326 | GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); |
329 | | - RenderSystem.setShaderColor(0, 0, 0, .5f); |
330 | | - guiGraphics.blit(GuiSelectionScreen.CIRCLE, (left + entryWidth) - 23, (int) (top + (entryHeight / 2f) - 9), 0, 0, 14, 14, 14, 14); |
331 | | - RenderSystem.setShaderColor(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, 1); |
332 | | - guiGraphics.blit(GuiSelectionScreen.CIRCLE, (left + entryWidth) - 21, (int) (top + (entryHeight / 2f) - 7), 0, 0, 10, 10, 10, 10); |
333 | | - RenderSystem.setShaderColor(1F, 1F, 1F, 1F); |
| 327 | + |
| 328 | + guiGraphics.blit(RenderType::guiTextured, GuiSelectionScreen.CIRCLE, (left + entryWidth) - 23, (int) (top + (entryHeight / 2f) - 9), 0, 0, 14, 14, 14, 14, 0x7F000000); |
| 329 | + guiGraphics.blit(RenderType::guiTextured, GuiSelectionScreen.CIRCLE, (left + entryWidth) - 21, (int) (top + (entryHeight / 2f) - 7), 0, 0, 10, 10, 10, 10, 0xFF000000 | blockData.getColor()); |
| 330 | + |
334 | 331 | RenderSystem.disableBlend(); |
335 | 332 | stack.popPose(); |
336 | 333 | } |
|
0 commit comments