diff --git a/build.gradle.kts b/build.gradle.kts index b1e738cb..3e39f97d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -200,7 +200,7 @@ dependencies { "testmodImplementation"(sourceSets.main.get().output) "modTestmodImplementation"("net.fabricmc.fabric-api:fabric-api:$fabric") -// modRuntimeOnly("me.shedaniel:RoughlyEnoughItems-fabric:$rei") + modRuntimeOnly("me.shedaniel:RoughlyEnoughItems-fabric:$rei") modRuntimeOnly("mcp.mobius.waila:wthit:fabric-$wthit") } diff --git a/src/main/java/dev/galacticraft/machinelib/client/api/screen/MachineScreen.java b/src/main/java/dev/galacticraft/machinelib/client/api/screen/MachineScreen.java index 560e54e2..eeb970da 100644 --- a/src/main/java/dev/galacticraft/machinelib/client/api/screen/MachineScreen.java +++ b/src/main/java/dev/galacticraft/machinelib/client/api/screen/MachineScreen.java @@ -100,12 +100,13 @@ public class MachineScreen lines) { */ protected void drawConfigurationPanels(@NotNull GuiGraphics graphics, int mouseX, int mouseY) { assert this.minecraft != null; - boolean secondary = false; PoseStack poseStack = graphics.pose(); + int leftX = this.leftPos; + int rightX = this.leftPos + this.imageWidth; + int leftY = this.topPos + SPACING; + int rightY = this.topPos + SPACING; + int width; + int height; for (Tab tab : Tab.values()) { // 0, 1, 2, 3 poseStack.pushPose(); - if (secondary) poseStack.translate(0, SPACING, 0); - graphics.blit(Constant.ScreenTexture.MACHINE_CONFIG_PANELS, this.leftPos + (tab.isLeft() ? tab.isOpen() ? -PANEL_WIDTH : -22 : this.imageWidth), this.topPos + (secondary ? Tab.values()[tab.ordinal() - 1].isOpen() ? PANEL_HEIGHT : TAB_HEIGHT : 0) + SPACING, tab.getU(), tab.getV(), tab.isOpen() ? PANEL_WIDTH : TAB_WIDTH, tab.isOpen() ? PANEL_HEIGHT : TAB_HEIGHT); - if (!tab.isOpen()) { - graphics.renderFakeItem(tab.getItem(), this.leftPos + (tab.isLeft() ? -22 : this.imageWidth) + (tab.isLeft() ? 4 : 2), this.topPos + (secondary ? Tab.values()[tab.ordinal() - 1].isOpen() ? PANEL_HEIGHT : TAB_HEIGHT : 0) + SPACING + 3); + width = tab.isOpen() ? PANEL_WIDTH : TAB_WIDTH; + height = tab.isOpen() ? PANEL_HEIGHT : TAB_HEIGHT; + if (tab.isLeft()) { + graphics.blit(Constant.ScreenTexture.MACHINE_CONFIG_PANELS, leftX - width, leftY, tab.getU(), tab.getV(), width, height); + if (!tab.isOpen()) { + graphics.renderFakeItem(tab.getItem(), leftX - TAB_WIDTH + 4, leftY + 3); + } + leftY += height + SPACING; + } else { + graphics.blit(Constant.ScreenTexture.MACHINE_CONFIG_PANELS, rightX, rightY, tab.getU(), tab.getV(), width, height); + if (!tab.isOpen()) { + graphics.renderFakeItem(tab.getItem(), rightX + 2, rightY + 3); + } + rightY += height + SPACING; } - secondary = !secondary; poseStack.popPose(); } poseStack.pushPose(); @@ -290,13 +308,13 @@ protected void drawConfigurationPanels(@NotNull GuiGraphics graphics, int mouseX this.drawButton(graphics, REDSTONE_IGNORE_X, REDSTONE_IGNORE_Y, mouseX + PANEL_WIDTH - this.leftPos, mouseY - SPACING - this.topPos, menu.redstoneMode == RedstoneMode.IGNORE); this.drawButton(graphics, REDSTONE_LOW_X, REDSTONE_LOW_Y, mouseX + PANEL_WIDTH - this.leftPos, mouseY - SPACING - this.topPos, menu.redstoneMode == RedstoneMode.LOW); this.drawButton(graphics, REDSTONE_HIGH_X, REDSTONE_HIGH_Y, mouseX + PANEL_WIDTH - this.leftPos, mouseY - SPACING - this.topPos, menu.redstoneMode == RedstoneMode.HIGH); - graphics.renderFakeItem(REDSTONE, PANEL_ICON_X, PANEL_ICON_Y); + graphics.renderFakeItem(REDSTONE, (Tab.REDSTONE.isLeft() ? PANEL_ICON_X_LEFT : PANEL_ICON_X_RIGHT), PANEL_ICON_Y); graphics.renderFakeItem(GUNPOWDER, REDSTONE_IGNORE_X, REDSTONE_IGNORE_Y); graphics.renderFakeItem(UNLIT_TORCH, REDSTONE_LOW_X, REDSTONE_LOW_Y - 2); graphics.renderFakeItem(REDSTONE_TORCH, REDSTONE_HIGH_X, REDSTONE_HIGH_Y - 2); - graphics.drawString(this.font, Component.translatable(Constant.TranslationKey.REDSTONE_MODE) - .setStyle(Constant.Text.GRAY_STYLE), PANEL_TITLE_X, PANEL_TITLE_Y, 0xFFFFFFFF); + graphics.drawString(this.font, Component.translatable(Constant.TranslationKey.REDSTONE_MODE).setStyle(Constant.Text.GRAY_STYLE), + (Tab.REDSTONE.isLeft() ? PANEL_ICON_X_LEFT : PANEL_ICON_X_RIGHT) + PANEL_TITLE_X - 1, PANEL_TITLE_Y, 0xFFFFFFFF); graphics.drawString(this.font, Component.translatable(Constant.TranslationKey.REDSTONE_STATE, menu.redstoneMode.getName()).setStyle(Constant.Text.GRAY_STYLE), REDSTONE_STATE_TEXT_X, REDSTONE_STATE_TEXT_Y, 0xFFFFFFFF); graphics.drawString(this.font, Component.translatable(Constant.TranslationKey.REDSTONE_STATUS, @@ -307,12 +325,13 @@ protected void drawConfigurationPanels(@NotNull GuiGraphics graphics, int mouseX poseStack.popPose(); } + if (Tab.CONFIGURATION.isOpen()) { poseStack.pushPose(); - poseStack.translate(-PANEL_WIDTH, TAB_HEIGHT + SPACING + SPACING, 0); - graphics.renderFakeItem(WRENCH, PANEL_ICON_X, PANEL_ICON_Y); - graphics.drawString(this.font, Component.translatable(Constant.TranslationKey.CONFIGURATION) - .setStyle(Constant.Text.GRAY_STYLE), PANEL_TITLE_X, PANEL_TITLE_Y, 0xFFFFFFFF); + poseStack.translate(-PANEL_WIDTH, TAB_HEIGHT + SPACING * 2, 0); + graphics.renderFakeItem(WRENCH, (Tab.CONFIGURATION.isLeft() ? PANEL_ICON_X_LEFT : PANEL_ICON_X_RIGHT), PANEL_ICON_Y); + graphics.drawString(this.font, Component.translatable(Constant.TranslationKey.CONFIGURATION).setStyle(Constant.Text.GRAY_STYLE), + (Tab.CONFIGURATION.isLeft() ? PANEL_ICON_X_LEFT : PANEL_ICON_X_RIGHT) + PANEL_TITLE_X, PANEL_TITLE_Y, 0xFFFFFFFF); RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS); this.drawMachineFace(graphics, TOP_FACE_X, TOP_FACE_Y, this.menu.configuration, BlockFace.TOP); @@ -323,36 +342,37 @@ protected void drawConfigurationPanels(@NotNull GuiGraphics graphics, int mouseX this.drawMachineFace(graphics, BOTTOM_FACE_X, BOTTOM_FACE_Y, this.menu.configuration, BlockFace.BOTTOM); poseStack.popPose(); } + if (Tab.STATS.isOpen()) { poseStack.pushPose(); poseStack.translate(this.imageWidth, SPACING, 0); - graphics.renderFakeItem(ALUMINUM_WIRE, PANEL_ICON_X, PANEL_ICON_Y); + graphics.renderFakeItem(ALUMINUM_WIRE, (Tab.STATS.isLeft() ? PANEL_ICON_X_LEFT : PANEL_ICON_X_RIGHT), PANEL_ICON_Y); PlayerFaceRenderer.draw(graphics, this.ownerSkin.getNow(DefaultPlayerSkin.get(this.menu.security.getOwner() == null ? this.menu.player.getUUID() : this.menu.security.getOwner())), OWNER_FACE_X, OWNER_FACE_Y, OWNER_FACE_SIZE); - graphics.drawString(this.font, Component.translatable(Constant.TranslationKey.STATISTICS) - .setStyle(Constant.Text.GREEN_STYLE), PANEL_TITLE_X, PANEL_TITLE_Y, 0xFFFFFFFF); - List text = this.font.split(this.menu.be.getBlockState().getBlock().getName(), 64); - int offsetY = 0; - for (FormattedCharSequence orderedText : text) { - graphics.drawString(this.font, orderedText, 40, 22 + offsetY, 0xFFFFFFFF, false); - offsetY += this.font.lineHeight + 2; - } + graphics.drawString(this.font, Component.translatable(Constant.TranslationKey.STATISTICS).setStyle(Constant.Text.GRAY_STYLE), + (Tab.STATS.isLeft() ? PANEL_ICON_X_LEFT : PANEL_ICON_X_RIGHT) + PANEL_TITLE_X, PANEL_TITLE_Y, 0xFFFFFFFF); + // List text = this.font.split(this.menu.be.getBlockState().getBlock().getName(), 64); + // int offsetY = 0; + // for (FormattedCharSequence orderedText : text) { + // graphics.drawString(this.font, orderedText, STATS_TEXT_X, STATS_TEXT_Y + offsetY, 0xFFFFFFFF, false); + // offsetY += this.font.lineHeight + 2; + // } poseStack.popPose(); } if (Tab.SECURITY.isOpen()) { poseStack.pushPose(); - poseStack.translate(this.imageWidth, TAB_HEIGHT + SPACING + SPACING, 0); - graphics.blit(Constant.ScreenTexture.MACHINE_CONFIG_PANELS, PANEL_ICON_X, PANEL_ICON_Y, ICON_LOCK_PRIVATE_U, ICON_LOCK_PRIVATE_V, ICON_WIDTH, ICON_HEIGHT); + poseStack.translate(this.imageWidth, TAB_HEIGHT + SPACING * 2, 0); + graphics.renderFakeItem(IRON_CHESTPLATE, (Tab.SECURITY.isLeft() ? PANEL_ICON_X_LEFT : PANEL_ICON_X_RIGHT), PANEL_ICON_Y); - this.drawButton(graphics, SECURITY_PUBLIC_X, SECURITY_PUBLIC_Y, mouseX - this.imageWidth - this.leftPos, mouseY - (TAB_HEIGHT + SPACING + SPACING) - this.topPos, this.menu.security.getAccessLevel() == AccessLevel.PUBLIC || !this.menu.security.isOwner(this.menu.player)); - this.drawButton(graphics, SECURITY_TEAM_X, SECURITY_TEAM_Y, mouseX - this.imageWidth - this.leftPos, mouseY - (TAB_HEIGHT + SPACING + SPACING) - this.topPos, this.menu.security.getAccessLevel() == AccessLevel.TEAM || !this.menu.security.isOwner(this.menu.player)); - this.drawButton(graphics, SECURITY_PRIVATE_X, SECURITY_PRIVATE_Y, mouseX - this.imageWidth - this.leftPos, mouseY - (TAB_HEIGHT + SPACING + SPACING) - this.topPos, this.menu.security.getAccessLevel() == AccessLevel.PRIVATE || !this.menu.security.isOwner(this.menu.player)); + this.drawButton(graphics, SECURITY_PUBLIC_X, SECURITY_PUBLIC_Y, mouseX - this.imageWidth - this.leftPos, mouseY - (TAB_HEIGHT + SPACING * 2) - this.topPos, this.menu.security.getAccessLevel() == AccessLevel.PUBLIC || !this.menu.security.isOwner(this.menu.player)); + this.drawButton(graphics, SECURITY_TEAM_X, SECURITY_TEAM_Y, mouseX - this.imageWidth - this.leftPos, mouseY - (TAB_HEIGHT + SPACING * 2) - this.topPos, this.menu.security.getAccessLevel() == AccessLevel.TEAM || !this.menu.security.isOwner(this.menu.player)); + this.drawButton(graphics, SECURITY_PRIVATE_X, SECURITY_PRIVATE_Y, mouseX - this.imageWidth - this.leftPos, mouseY - (TAB_HEIGHT + SPACING * 2) - this.topPos, this.menu.security.getAccessLevel() == AccessLevel.PRIVATE || !this.menu.security.isOwner(this.menu.player)); graphics.blit(Constant.ScreenTexture.MACHINE_CONFIG_PANELS, SECURITY_PUBLIC_X, SECURITY_PUBLIC_Y, ICON_LOCK_PRIVATE_U, ICON_LOCK_PRIVATE_V, ICON_WIDTH, ICON_HEIGHT); graphics.blit(Constant.ScreenTexture.MACHINE_CONFIG_PANELS, SECURITY_TEAM_X, SECURITY_TEAM_Y, ICON_LOCK_PARTY_U, ICON_LOCK_PARTY_V, ICON_WIDTH, ICON_HEIGHT); graphics.blit(Constant.ScreenTexture.MACHINE_CONFIG_PANELS, SECURITY_PRIVATE_X, SECURITY_PRIVATE_Y, ICON_LOCK_PUBLIC_U, ICON_LOCK_PUBLIC_V, ICON_WIDTH, ICON_HEIGHT); - graphics.drawString(this.font, Component.translatable(Constant.TranslationKey.SECURITY) - .setStyle(Constant.Text.GRAY_STYLE), PANEL_TITLE_X, PANEL_TITLE_Y, 0xFFFFFFFF); + graphics.drawString(this.font, Component.translatable(Constant.TranslationKey.SECURITY).setStyle(Constant.Text.GRAY_STYLE), + (Tab.SECURITY.isLeft() ? PANEL_ICON_X_LEFT : PANEL_ICON_X_RIGHT) + PANEL_TITLE_X, PANEL_TITLE_Y, 0xFFFFFFFF); graphics.drawString(this.font, Component.translatable(Constant.TranslationKey.ACCESS_LEVEL, this.menu.security.getAccessLevel().getName()).setStyle(Constant.Text.GRAY_STYLE), SECURITY_STATE_TEXT_X, SECURITY_STATE_TEXT_Y, 0xFFFFFFFF); @@ -462,7 +482,7 @@ public boolean checkConfigurationPanelClick(double mouseX, double mouseY, int bu mouseY = mY - this.topPos; if (Tab.CONFIGURATION.isOpen()) { mouseX += PANEL_WIDTH; - mouseY -= TAB_HEIGHT + SPACING + SPACING; + mouseY -= TAB_HEIGHT + SPACING * 2; if (mouseIn(mouseX, mouseY, 0, 0, PANEL_WIDTH, PANEL_UPPER_HEIGHT)) { Tab.CONFIGURATION.toggle(); return true; @@ -491,9 +511,9 @@ public boolean checkConfigurationPanelClick(double mouseX, double mouseY, int bu } else { mouseX += TAB_WIDTH; if (Tab.REDSTONE.isOpen()) { - mouseY -= PANEL_HEIGHT + SPACING + SPACING; + mouseY -= PANEL_HEIGHT + SPACING * 2; } else { - mouseY -= TAB_HEIGHT + SPACING + SPACING; + mouseY -= TAB_HEIGHT + SPACING * 2; } if (mouseIn(mouseX, mouseY, 0, 0, TAB_WIDTH, TAB_HEIGHT)) { Tab.CONFIGURATION.toggle(); @@ -519,7 +539,7 @@ public boolean checkConfigurationPanelClick(double mouseX, double mouseY, int bu mouseY = mY - this.topPos; mouseX -= this.imageWidth; if (Tab.SECURITY.isOpen()) { - mouseY -= TAB_HEIGHT + SPACING + SPACING; + mouseY -= TAB_HEIGHT + SPACING * 2; if (mouseIn(mouseX, mouseY, 0, 0, PANEL_WIDTH, PANEL_UPPER_HEIGHT)) { Tab.SECURITY.toggle(); return true; @@ -544,9 +564,9 @@ public boolean checkConfigurationPanelClick(double mouseX, double mouseY, int bu } } else { if (Tab.STATS.isOpen()) { - mouseY -= PANEL_HEIGHT + SPACING + SPACING; + mouseY -= PANEL_HEIGHT + SPACING * 2; } else { - mouseY -= TAB_HEIGHT + SPACING + SPACING; + mouseY -= TAB_HEIGHT + SPACING * 2; } if (mouseIn(mouseX, mouseY, 0, 0, TAB_WIDTH, TAB_HEIGHT)) { Tab.SECURITY.toggle(); @@ -609,7 +629,7 @@ protected void drawConfigurationPanelTooltips(GuiGraphics graphics, int mouseX, mouseY = mY - this.topPos; if (Tab.CONFIGURATION.isOpen()) { mouseX += PANEL_WIDTH; - mouseY -= TAB_HEIGHT + SPACING + SPACING; + mouseY -= TAB_HEIGHT + SPACING * 2; if (mouseIn(mouseX, mouseY, TOP_FACE_X, TOP_FACE_Y, MACHINE_FACE_SIZE, MACHINE_FACE_SIZE)) { this.renderFaceTooltip(graphics, BlockFace.TOP, mX, mY); } @@ -660,7 +680,7 @@ protected void drawConfigurationPanelTooltips(GuiGraphics graphics, int mouseX, mouseY = mY - this.topPos; if (Tab.SECURITY.isOpen()) { mouseX -= this.imageWidth; - mouseY -= TAB_HEIGHT + SPACING + SPACING; + mouseY -= TAB_HEIGHT + SPACING * 2; if (this.menu.security.isOwner(this.menu.player)) { if (mouseIn(mouseX, mouseY, REDSTONE_IGNORE_X, REDSTONE_IGNORE_Y, BUTTON_WIDTH, BUTTON_HEIGHT)) { @@ -682,12 +702,12 @@ protected void drawConfigurationPanelTooltips(GuiGraphics graphics, int mouseX, } else { mouseX -= this.imageWidth; if (Tab.STATS.isOpen()) { - mouseY -= PANEL_HEIGHT + SPACING + SPACING; + mouseY -= PANEL_HEIGHT + SPACING * 2; } else { - mouseY -= TAB_HEIGHT + SPACING + SPACING; + mouseY -= TAB_HEIGHT + SPACING * 2; } if (mouseIn(mouseX, mouseY, 0, 0, TAB_WIDTH, TAB_HEIGHT)) { - graphics.renderTooltip(this.font, Component.translatable(Constant.TranslationKey.SECURITY).setStyle(Constant.Text.BLUE_STYLE), mX, mY); + graphics.renderTooltip(this.font, Component.translatable(Constant.TranslationKey.SECURITY).setStyle(Constant.Text.GREEN_STYLE), mX, mY); } } } @@ -826,7 +846,7 @@ protected void drawTanks(GuiGraphics graphics, int mouseX, int mouseY) { private void handleSlotHighlight(GuiGraphics graphics, int mouseX, int mouseY) { if (Tab.CONFIGURATION.isOpen()) { mouseX -= (this.leftPos - PANEL_WIDTH); - mouseY -= (this.topPos + (TAB_HEIGHT + SPACING + SPACING)); + mouseY -= (this.topPos + (TAB_HEIGHT + SPACING * 2)); IOFace config = null; if (mouseIn(mouseX, mouseY, TOP_FACE_X, TOP_FACE_Y, MACHINE_FACE_SIZE, MACHINE_FACE_SIZE)) { config = this.menu.configuration.get(BlockFace.TOP); diff --git a/src/main/java/dev/galacticraft/machinelib/client/impl/compat/MachineLibREIClientPlugin.java b/src/main/java/dev/galacticraft/machinelib/client/impl/compat/MachineLibREIClientPlugin.java index da67395d..325b67fa 100644 --- a/src/main/java/dev/galacticraft/machinelib/client/impl/compat/MachineLibREIClientPlugin.java +++ b/src/main/java/dev/galacticraft/machinelib/client/impl/compat/MachineLibREIClientPlugin.java @@ -25,6 +25,7 @@ import dev.architectury.event.CompoundEventResult; import dev.galacticraft.machinelib.client.api.screen.MachineScreen; import dev.galacticraft.machinelib.impl.Constant; +import dev.galacticraft.machinelib.impl.Constant.TextureCoordinate; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.client.registry.screen.ExclusionZones; @@ -49,13 +50,30 @@ public void registerScreens(ScreenRegistry registry) { @Override public void registerExclusionZones(ExclusionZones zones) { - zones.register(MachineScreen.class, screen -> { + zones.register(MachineScreen.class, provider -> { List areas = new ArrayList<>(); - if (MachineScreen.Tab.STATS.isOpen() || MachineScreen.Tab.SECURITY.isOpen()) { - areas.add(new Rectangle(screen.getX() + screen.getImageWidth(), screen.getY() + (MachineScreen.Tab.STATS.isOpen() ? 0 : Constant.TextureCoordinate.TAB_HEIGHT), Constant.TextureCoordinate.PANEL_WIDTH, Constant.TextureCoordinate.PANEL_HEIGHT)); - areas.add(new Rectangle(screen.getX() + screen.getImageWidth(), screen.getY() + Constant.TextureCoordinate.TAB_HEIGHT, Constant.TextureCoordinate.TAB_WIDTH, Constant.TextureCoordinate.PANEL_HEIGHT)); + int leftX = provider.getX(); + int rightX = provider.getX() + provider.getImageWidth(); + int leftY = provider.getY() + MachineScreen.SPACING; + int rightY = provider.getY() + MachineScreen.SPACING; + int width; + int height; + for (MachineScreen.Tab tab : MachineScreen.Tab.values()) { + if (tab.isOpen()) { + width = TextureCoordinate.PANEL_WIDTH; + height = TextureCoordinate.PANEL_HEIGHT; + } else { + width = TextureCoordinate.TAB_WIDTH; + height = TextureCoordinate.TAB_HEIGHT; + } + if (tab.isLeft()) { + areas.add(new Rectangle(leftX - width, leftY, width, height)); + leftY += height + MachineScreen.SPACING; + } else { + areas.add(new Rectangle(rightX, rightY, width, height)); + rightY += height + MachineScreen.SPACING; + } } - areas.add(new Rectangle(screen.getX() + screen.getImageWidth(), screen.getY(), Constant.TextureCoordinate.TAB_WIDTH, Constant.TextureCoordinate.TAB_HEIGHT * 2)); return areas; }); } diff --git a/src/main/java/dev/galacticraft/machinelib/impl/Constant.java b/src/main/java/dev/galacticraft/machinelib/impl/Constant.java index 7ee6c738..f27dc68f 100644 --- a/src/main/java/dev/galacticraft/machinelib/impl/Constant.java +++ b/src/main/java/dev/galacticraft/machinelib/impl/Constant.java @@ -102,7 +102,7 @@ interface TextureCoordinate { /** * The height of a configuration panel. */ - int PANEL_HEIGHT = 93; + int PANEL_HEIGHT = 92; /** * The width of a configuration tab. */ diff --git a/src/main/resources/assets/machinelib/textures/gui/machine_panels.png b/src/main/resources/assets/machinelib/textures/gui/machine_panels.png index 92d23a2d..b28d8602 100644 Binary files a/src/main/resources/assets/machinelib/textures/gui/machine_panels.png and b/src/main/resources/assets/machinelib/textures/gui/machine_panels.png differ