Skip to Content
Docs模组Fizzy示例菜单

示例菜单构造类

package demo; import link.botwmcs.fizzy.menu.FizzyTestMenu; import link.botwmcs.fizzy.ui.background.BgType; import link.botwmcs.fizzy.ui.background.FizzyBg; import link.botwmcs.fizzy.ui.behind.VanillaBehind; import link.botwmcs.fizzy.ui.core.FizzyGui; import link.botwmcs.fizzy.ui.core.FizzyGuiBuilder; import link.botwmcs.fizzy.ui.core.HostType; import link.botwmcs.fizzy.ui.element.below.DoubleButtonBelow; import link.botwmcs.fizzy.ui.element.component.FizzyComponentElement; import link.botwmcs.fizzy.ui.element.slot.SlotElement; import link.botwmcs.fizzy.ui.frame.MotiveFrame; import link.botwmcs.fizzy.ui.host.FizzyMenuScreenHost; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.player.Inventory; public final class DemoMenuScreen extends FizzyMenuScreenHost<FizzyTestMenu> { public DemoMenuScreen(FizzyTestMenu menu, Inventory inv, Component title) { super(menu, inv, title, buildGui(title)); } private static FizzyGui buildGui(Component title) { int rows = FizzyTestMenu.CONTAINER_ROWS; MotiveFrame frame = new MotiveFrame(title, false); return FizzyGuiBuilder.start() .host(HostType.MENU) .sizeSlots(rows) .frame(frame) .behind(new VanillaBehind()) .background(new FizzyBg(BgType.BARRIER_BLUE)) .pad(1, 1, rows, 9) .element(new SlotElement()) .done() .padAuto(1, 1, 1, 9) .element(FizzyComponentElement.builder() .addText(Component.literal("Demo Menu")) .align(link.botwmcs.fizzy.client.util.TextRenderer.Align.CENTER) .shadow(true) .build()) .done() .split(1, 4, rows, 4) .below(new DoubleButtonBelow( Component.literal("Apply"), b -> {}, Component.literal("Close"), b -> {} )) .build(); } }
Last updated on