-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Description
This code will cause hovered tooltips in the containerscreen gui to have no text rendered:
private fun chestCloseButtonInitializer(instance: Layer<ContainerScreen, FlowLayout>.Instance) {
val closeButton = Components.button(
net.minecraft.network.chat.Component.literal("Close")
) {
Minecraft.getInstance().setScreen(null)
}.sizing(Sizing.content(), Sizing.fixed(16))
// Wrap in a fixed-width container to center it
val buttonContainer = Containers.horizontalFlow(Sizing.fixed(176), Sizing.content())
.child(closeButton)
.horizontalAlignment(HorizontalAlignment. CENTER)
instance.adapter.rootComponent.child(buttonContainer)
// Position at x=0 (left edge of GUI), y=-18 (above GUI)
instance.alignComponentToHandledScreenCoordinates(buttonContainer, 0, -18)
}
override fun onInitializeClient() {
// make the instanceInitializer reference a class method so hot reload works.
Layers.add(
Containers::verticalFlow,
::chestCloseButtonInitializer,
ContainerScreen::class.java
)
}This mixin fixes that issue:
package dev.u9g.utils.mixin.client;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.inventory.ContainerScreen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ContainerScreen.class)
public class ContainerScreenMixin {
@Inject(method = "render", at = @At("TAIL"))
private void flushTooltipBuffer(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick, CallbackInfo ci) {
// Force the text vertices buffered during renderTooltip to draw NOW
// before the method returns and the RenderSystem state changes.
guiGraphics.flush();
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels