use of net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen in project LightmansCurrency by Lightman314.
the class ClientEvents method onInventoryGuiInit.
// Add the wallet button to the gui
@SubscribeEvent
public static void onInventoryGuiInit(ScreenEvent.InitScreenEvent.Post event) {
if (!Config.CLIENT.renderWalletButton.get())
return;
Screen screen = event.getScreen();
if (screen instanceof InventoryScreen || screen instanceof CreativeModeInventoryScreen) {
AbstractContainerScreen<?> gui = (AbstractContainerScreen<?>) screen;
boolean isCreative = screen instanceof CreativeModeInventoryScreen;
int xPos = isCreative ? Config.CLIENT.walletButtonCreativeX.get() : Config.CLIENT.walletButtonX.get();
int yPos = isCreative ? Config.CLIENT.walletButtonCreativeY.get() : Config.CLIENT.walletButtonY.get();
;
event.addListener(new WalletButton(gui, xPos, yPos, button -> LightmansCurrencyPacketHandler.instance.sendToServer(new MessageOpenWallet())));
}
}
use of net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen in project LightmansCurrency by Lightman314.
the class WalletButton method render.
@Override
public void render(PoseStack poseStack, int mouseX, int mouseY, float partialTicks) {
// Reposition the button based on the containers top/left most position
this.x = this.parent.getGuiLeft() + this.xOffset;
this.y = this.parent.getGuiTop() + this.yOffset;
if (this.parent instanceof CreativeModeInventoryScreen) {
CreativeModeInventoryScreen creativeScreen = (CreativeModeInventoryScreen) this.parent;
boolean isInventoryTab = creativeScreen.getSelectedTab() == CreativeModeTab.TAB_INVENTORY.getId();
this.active = isInventoryTab;
// Hide if we're not in the inventory tab of the creative screen
if (!isInventoryTab) {
return;
}
}
super.render(poseStack, mouseX, mouseY, partialTicks);
}
Aggregations