From 90bcfe2fb9933b4f4db92a43580c36a8466f21c1 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sat, 13 May 2023 15:02:03 +0100 Subject: [PATCH] Cleanup and fix slot/fluid config popup --- .../elements/AbstractConfigPopupElement.java | 139 ++++++++++++++++++ .../elements/FluidConfigPopupElement.java | 108 +------------- .../slot/elements/SlotConfigPopupElement.java | 116 +-------------- 3 files changed, 150 insertions(+), 213 deletions(-) create mode 100644 RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/AbstractConfigPopupElement.java diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/AbstractConfigPopupElement.java b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/AbstractConfigPopupElement.java new file mode 100644 index 000000000..5a900ecda --- /dev/null +++ b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/AbstractConfigPopupElement.java @@ -0,0 +1,139 @@ +/* + * This file is part of RebornCore, licensed under the MIT License (MIT). + * + * Copyright (c) 2021 TeamReborn + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package reborncore.client.gui.builder.slot.elements; + +import net.minecraft.block.BlockState; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.render.OverlayTexture; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.Tessellator; +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.block.BlockRenderManager; +import net.minecraft.client.render.model.BakedModel; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.screen.PlayerScreenHandler; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.util.math.RotationAxis; +import net.minecraft.world.World; +import org.joml.Quaternionf; +import reborncore.client.gui.builder.GuiBase; +import reborncore.common.blockentity.MachineBaseBlockEntity; +import reborncore.common.util.MachineFacing; + +public abstract class AbstractConfigPopupElement extends ElementBase { + public boolean filter = false; + + public AbstractConfigPopupElement(int x, int y, ISprite... sprites) { + super(x, y, sprites); + } + + @Override + public final void draw(DrawContext drawContext, GuiBase gui) { + drawDefaultBackground(drawContext, gui, adjustX(gui, getX() - 8), adjustY(gui, getY() - 7), 84, 105 + (filter ? 15 : 0)); + super.draw(drawContext, gui); + + MachineBaseBlockEntity machine = ((MachineBaseBlockEntity) gui.be); + World world = machine.getWorld(); + BlockPos pos = machine.getPos(); + BlockState state = world.getBlockState(pos); + BlockState actualState = state.getBlock().getDefaultState(); + BlockRenderManager dispatcher = MinecraftClient.getInstance().getBlockRenderManager(); + BakedModel model = dispatcher.getModels().getModel(state.getBlock().getDefaultState()); + MinecraftClient.getInstance().getTextureManager().bindTexture(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE); + drawState(drawContext, gui, world, model, actualState, pos, dispatcher, 4, 23, RotationAxis.POSITIVE_Y.rotationDegrees(90F)); //left + drawState(drawContext, gui, world, model, actualState, pos, dispatcher, 23, 4, RotationAxis.NEGATIVE_X.rotationDegrees(90F)); //top + drawState(drawContext, gui, world, model, actualState, pos, dispatcher, 23, 23, null); //centre + drawState(drawContext, gui, world, model, actualState, pos, dispatcher, 23, 26, RotationAxis.POSITIVE_X.rotationDegrees(90F)); //bottom + drawState(drawContext, gui, world, model, actualState, pos, dispatcher, 42, 23, RotationAxis.POSITIVE_Y.rotationDegrees(90F)); //right + drawState(drawContext, gui, world, model, actualState, pos, dispatcher, 26, 42, RotationAxis.POSITIVE_Y.rotationDegrees(180F)); //back + + drawSateColor(drawContext, gui, MachineFacing.UP.getFacing(machine), 22, -1); + drawSateColor(drawContext, gui, MachineFacing.FRONT.getFacing(machine), 22, 18); + drawSateColor(drawContext, gui, MachineFacing.DOWN.getFacing(machine), 22, 37); + drawSateColor(drawContext, gui, MachineFacing.RIGHT.getFacing(machine), 41, 18); + drawSateColor(drawContext, gui, MachineFacing.BACK.getFacing(machine), 41, 37); + drawSateColor(drawContext, gui, MachineFacing.LEFT.getFacing(machine), 3, 18); + } + + @Override + public final boolean onRelease(MachineBaseBlockEntity provider, GuiBase gui, double mouseX, double mouseY) { + if (isInBox(23, 4, 16, 16, mouseX, mouseY, gui)) { + cycleConfig(MachineFacing.UP.getFacing(provider), gui); + } else if (isInBox(23, 23, 16, 16, mouseX, mouseY, gui)) { + cycleConfig(MachineFacing.FRONT.getFacing(provider), gui); + } else if (isInBox(42, 23, 16, 16, mouseX, mouseY, gui)) { + cycleConfig(MachineFacing.RIGHT.getFacing(provider), gui); + } else if (isInBox(4, 23, 16, 16, mouseX, mouseY, gui)) { + cycleConfig(MachineFacing.LEFT.getFacing(provider), gui); + } else if (isInBox(23, 42, 16, 16, mouseX, mouseY, gui)) { + cycleConfig(MachineFacing.DOWN.getFacing(provider), gui); + } else if (isInBox(42, 42, 16, 16, mouseX, mouseY, gui)) { + cycleConfig(MachineFacing.BACK.getFacing(provider), gui); + } else { + return false; + } + return true; + } + + protected abstract void cycleConfig(Direction side, GuiBase guiBase); + + protected abstract void drawSateColor(DrawContext drawContext, GuiBase gui, Direction side, int inx, int iny); + + protected boolean isInBox(int rectX, int rectY, int rectWidth, int rectHeight, double pointX, double pointY, GuiBase guiBase) { + rectX += getX(); + rectY += getY(); + return isInRect(guiBase, rectX, rectY, rectWidth, rectHeight, pointX, pointY); + //return (pointX - guiBase.getGuiLeft()) >= rectX - 1 && (pointX - guiBase.getGuiLeft()) < rectX + rectWidth + 1 && (pointY - guiBase.getGuiTop()) >= rectY - 1 && (pointY - guiBase.getGuiTop()) < rectY + rectHeight + 1; + } + + protected void drawState(DrawContext drawContext, + GuiBase gui, + World world, + BakedModel model, + BlockState actualState, + BlockPos pos, + BlockRenderManager dispatcher, + int x, + int y, + Quaternionf quaternion) { + MatrixStack matrixStack = drawContext.getMatrices(); + matrixStack.push(); + matrixStack.translate(8 + gui.getGuiLeft() + this.x + x, 8 + gui.getGuiTop() + this.y + y, 512); + matrixStack.scale(16F, 16F, 16F); + matrixStack.translate(0.5F, 0.5F, 0.5F); + matrixStack.scale(-1, -1, -1); + + if (quaternion != null) { + matrixStack.multiply(quaternion); + } + + VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer()); + dispatcher.getModelRenderer().render(matrixStack.peek(), immediate.getBuffer(RenderLayer.getSolid()), actualState, model, 1F, 1F, 1F, OverlayTexture.getU(15F), OverlayTexture.DEFAULT_UV); + immediate.draw(); + matrixStack.pop(); + } +} diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/FluidConfigPopupElement.java b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/FluidConfigPopupElement.java index 1fe8bbfb2..f2f555180 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/FluidConfigPopupElement.java +++ b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/FluidConfigPopupElement.java @@ -25,22 +25,8 @@ package reborncore.client.gui.builder.slot.elements; import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.block.BlockState; -import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.render.OverlayTexture; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.Tessellator; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.block.BlockRenderManager; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.screen.PlayerScreenHandler; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; -import net.minecraft.util.math.RotationAxis; -import net.minecraft.world.World; -import org.joml.Quaternionf; import reborncore.RebornCore; import reborncore.client.ClientNetworkManager; import reborncore.client.gui.GuiUtil; @@ -50,11 +36,8 @@ import reborncore.common.blockentity.MachineBaseBlockEntity; import reborncore.common.network.IdentifiedPacket; import reborncore.common.network.ServerBoundPackets; import reborncore.common.util.Color; -import reborncore.common.util.MachineFacing; - -public class FluidConfigPopupElement extends ElementBase { - public boolean filter = false; +public class FluidConfigPopupElement extends AbstractConfigPopupElement { ConfigFluidElement fluidElement; double lastMouseX, lastMouseY; @@ -64,54 +47,7 @@ public class FluidConfigPopupElement extends ElementBase { } @Override - public void draw(DrawContext drawContext, GuiBase gui) { - drawDefaultBackground(drawContext, gui, adjustX(gui, getX() - 8), adjustY(gui, getY() - 7), 84, 105 + (filter ? 15 : 0)); - super.draw(drawContext, gui); - - MachineBaseBlockEntity machine = ((MachineBaseBlockEntity) gui.be); - World world = machine.getWorld(); - BlockPos pos = machine.getPos(); - BlockState state = world.getBlockState(pos); - BlockState actualState = state.getBlock().getDefaultState(); - BlockRenderManager dispatcher = MinecraftClient.getInstance().getBlockRenderManager(); - BakedModel model = dispatcher.getModels().getModel(state.getBlock().getDefaultState()); - MinecraftClient.getInstance().getTextureManager().bindTexture(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE); - drawState(gui, world, model, actualState, pos, dispatcher, 4, 23, RotationAxis.POSITIVE_Y.rotationDegrees(90F)); //left - drawState(gui, world, model, actualState, pos, dispatcher, 23, 4, RotationAxis.NEGATIVE_X.rotationDegrees(90F)); //top - drawState(gui, world, model, actualState, pos, dispatcher, 23, 23, null); //centre - drawState(gui, world, model, actualState, pos, dispatcher, 23, 26, RotationAxis.POSITIVE_X.rotationDegrees(90F)); //bottom - drawState(gui, world, model, actualState, pos, dispatcher, 42, 23, RotationAxis.POSITIVE_Y.rotationDegrees(90F)); //right - drawState(gui, world, model, actualState, pos, dispatcher, 26, 42, RotationAxis.POSITIVE_Y.rotationDegrees(180F)); //back - - drawSateColor(drawContext, gui.getMachine(), MachineFacing.UP.getFacing(machine), 22, -1, gui); - drawSateColor(drawContext, gui.getMachine(), MachineFacing.FRONT.getFacing(machine), 22, 18, gui); - drawSateColor(drawContext, gui.getMachine(), MachineFacing.DOWN.getFacing(machine), 22, 37, gui); - drawSateColor(drawContext, gui.getMachine(), MachineFacing.RIGHT.getFacing(machine), 41, 18, gui); - drawSateColor(drawContext, gui.getMachine(), MachineFacing.BACK.getFacing(machine), 41, 37, gui); - drawSateColor(drawContext, gui.getMachine(), MachineFacing.LEFT.getFacing(machine), 3, 18, gui); - } - - @Override - public boolean onRelease(MachineBaseBlockEntity provider, GuiBase gui, double mouseX, double mouseY) { - if (isInBox(23, 4, 16, 16, mouseX, mouseY, gui)) { - cycleConfig(MachineFacing.UP.getFacing(provider), gui); - } else if (isInBox(23, 23, 16, 16, mouseX, mouseY, gui)) { - cycleConfig(MachineFacing.FRONT.getFacing(provider), gui); - } else if (isInBox(42, 23, 16, 16, mouseX, mouseY, gui)) { - cycleConfig(MachineFacing.RIGHT.getFacing(provider), gui); - } else if (isInBox(4, 23, 16, 16, mouseX, mouseY, gui)) { - cycleConfig(MachineFacing.LEFT.getFacing(provider), gui); - } else if (isInBox(23, 42, 16, 16, mouseX, mouseY, gui)) { - cycleConfig(MachineFacing.DOWN.getFacing(provider), gui); - } else if (isInBox(42, 42, 16, 16, mouseX, mouseY, gui)) { - cycleConfig(MachineFacing.BACK.getFacing(provider), gui); - } else { - return false; - } - return true; - } - - public void cycleConfig(Direction side, GuiBase guiBase) { + protected void cycleConfig(Direction side, GuiBase guiBase) { FluidConfiguration.FluidConfig config = guiBase.getMachine().fluidConfiguration.getSideDetail(side); FluidConfiguration.ExtractConfig fluidIO = config.getIoConfig().getNext(); @@ -143,11 +79,12 @@ public class FluidConfigPopupElement extends ElementBase { return super.onHover(provider, gui, mouseX, mouseY); } - private void drawSateColor(DrawContext drawContext, MachineBaseBlockEntity machineBase, Direction side, int inx, int iny, GuiBase gui) { + @Override + protected void drawSateColor(DrawContext drawContext, GuiBase gui, Direction side, int inx, int iny) { iny += 4; int sx = inx + getX() + gui.getGuiLeft(); int sy = iny + getY() + gui.getGuiTop(); - FluidConfiguration fluidConfiguration = machineBase.fluidConfiguration; + FluidConfiguration fluidConfiguration = gui.getMachine().fluidConfiguration; if (fluidConfiguration == null) { RebornCore.LOGGER.debug("Hmm, this isn't supposed to happen"); return; @@ -163,39 +100,4 @@ public class FluidConfigPopupElement extends ElementBase { GuiUtil.drawGradientRect(drawContext.getMatrices(), sx, sy, 18, 18, color.getColor(), color.getColor()); RenderSystem.setShaderColor(1, 1, 1, 1); } - - private boolean isInBox(int rectX, int rectY, int rectWidth, int rectHeight, double pointX, double pointY, GuiBase guiBase) { - rectX += getX(); - rectY += getY(); - return isInRect(guiBase, rectX, rectY, rectWidth, rectHeight, pointX, pointY); - //return (pointX - guiBase.getGuiLeft()) >= rectX - 1 && (pointX - guiBase.getGuiLeft()) < rectX + rectWidth + 1 && (pointY - guiBase.getGuiTop()) >= rectY - 1 && (pointY - guiBase.getGuiTop()) < rectY + rectHeight + 1; - } - - public void drawState(GuiBase gui, - World world, - BakedModel model, - BlockState actualState, - BlockPos pos, - BlockRenderManager dispatcher, - int x, - int y, - Quaternionf quaternion) { - - MatrixStack matrixStack = new MatrixStack(); - matrixStack.push(); - matrixStack.translate(8 + gui.getGuiLeft() + this.x + x, 8 + gui.getGuiTop() + this.y + y, 512); - matrixStack.scale(16F, 16F, 16F); - matrixStack.translate(0.5F, 0.5F, 0.5F); - matrixStack.scale(-1, -1, -1); - - if (quaternion != null) { - matrixStack.multiply(quaternion); - } - - VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer()); - dispatcher.getModelRenderer().render(matrixStack.peek(), immediate.getBuffer(RenderLayer.getSolid()), actualState, model, 1F, 1F, 1F, OverlayTexture.getU(15F), OverlayTexture.DEFAULT_UV); - immediate.draw(); - matrixStack.pop(); - } - } diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/SlotConfigPopupElement.java b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/SlotConfigPopupElement.java index eeaba8643..7b7c60748 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/SlotConfigPopupElement.java +++ b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/SlotConfigPopupElement.java @@ -25,40 +25,21 @@ package reborncore.client.gui.builder.slot.elements; import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.block.BlockState; -import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.render.OverlayTexture; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.Tessellator; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.block.BlockRenderManager; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.screen.PlayerScreenHandler; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; -import net.minecraft.util.math.RotationAxis; -import net.minecraft.world.World; -import org.joml.Quaternionf; import reborncore.RebornCore; import reborncore.client.ClientNetworkManager; import reborncore.client.gui.GuiUtil; import reborncore.client.gui.builder.GuiBase; -import reborncore.common.blockentity.MachineBaseBlockEntity; import reborncore.common.blockentity.SlotConfiguration; import reborncore.common.network.IdentifiedPacket; import reborncore.common.network.ServerBoundPackets; import reborncore.common.util.Color; -import reborncore.common.util.MachineFacing; -public class SlotConfigPopupElement extends ElementBase { +public class SlotConfigPopupElement extends AbstractConfigPopupElement { int id; - public boolean filter = false; - ConfigSlotElement slotElement; - - boolean allowInput = true; + boolean allowInput; public SlotConfigPopupElement(int slotId, int x, int y, ConfigSlotElement slotElement, boolean allowInput) { super(x, y, Sprite.SLOT_CONFIG_POPUP); @@ -68,54 +49,7 @@ public class SlotConfigPopupElement extends ElementBase { } @Override - public void draw(DrawContext drawContext, GuiBase gui) { - drawDefaultBackground(drawContext, gui, adjustX(gui, getX() - 8), adjustY(gui, getY() - 7), 84, 105 + (filter ? 15 : 0)); - super.draw(drawContext, gui); - - MachineBaseBlockEntity machine = ((MachineBaseBlockEntity) gui.be); - World world = machine.getWorld(); - BlockPos pos = machine.getPos(); - BlockState state = world.getBlockState(pos); - BlockState actualState = state.getBlock().getDefaultState(); - BlockRenderManager dispatcher = MinecraftClient.getInstance().getBlockRenderManager(); - BakedModel model = dispatcher.getModels().getModel(state.getBlock().getDefaultState()); - MinecraftClient.getInstance().getTextureManager().bindTexture(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE); - drawState(gui, world, model, actualState, pos, dispatcher, 4, 23, RotationAxis.POSITIVE_Y.rotationDegrees(90F)); //left - drawState(gui, world, model, actualState, pos, dispatcher, 23, 4, RotationAxis.NEGATIVE_X.rotationDegrees(90F)); //top - drawState(gui, world, model, actualState, pos, dispatcher, 23, 23, null); //centre - drawState(gui, world, model, actualState, pos, dispatcher, 23, 26, RotationAxis.POSITIVE_X.rotationDegrees(90F)); //bottom - drawState(gui, world, model, actualState, pos, dispatcher, 42, 23, RotationAxis.POSITIVE_Y.rotationDegrees(90F)); //right - drawState(gui, world, model, actualState, pos, dispatcher, 26, 42, RotationAxis.POSITIVE_Y.rotationDegrees(180F)); //back - - drawSlotSateColor(drawContext, gui.getMachine(), MachineFacing.UP.getFacing(machine), id, 22, -1, gui); - drawSlotSateColor(drawContext, gui.getMachine(), MachineFacing.FRONT.getFacing(machine), id, 22, 18, gui); - drawSlotSateColor(drawContext, gui.getMachine(), MachineFacing.DOWN.getFacing(machine), id, 22, 37, gui); - drawSlotSateColor(drawContext, gui.getMachine(), MachineFacing.RIGHT.getFacing(machine), id, 41, 18, gui); - drawSlotSateColor(drawContext, gui.getMachine(), MachineFacing.BACK.getFacing(machine), id, 41, 37, gui); - drawSlotSateColor(drawContext, gui.getMachine(), MachineFacing.LEFT.getFacing(machine), id, 3, 18, gui); - } - - @Override - public boolean onRelease(MachineBaseBlockEntity provider, GuiBase gui, double mouseX, double mouseY) { - if (isInBox(23, 4, 16, 16, mouseX, mouseY, gui)) { - cycleSlotConfig(MachineFacing.UP.getFacing(provider), gui); - } else if (isInBox(23, 23, 16, 16, mouseX, mouseY, gui)) { - cycleSlotConfig(MachineFacing.FRONT.getFacing(provider), gui); - } else if (isInBox(42, 23, 16, 16, mouseX, mouseY, gui)) { - cycleSlotConfig(MachineFacing.RIGHT.getFacing(provider), gui); - } else if (isInBox(4, 23, 16, 16, mouseX, mouseY, gui)) { - cycleSlotConfig(MachineFacing.LEFT.getFacing(provider), gui); - } else if (isInBox(23, 42, 16, 16, mouseX, mouseY, gui)) { - cycleSlotConfig(MachineFacing.DOWN.getFacing(provider), gui); - } else if (isInBox(42, 42, 16, 16, mouseX, mouseY, gui)) { - cycleSlotConfig(MachineFacing.BACK.getFacing(provider), gui); - } else { - return false; - } - return true; - } - - public void cycleSlotConfig(Direction side, GuiBase guiBase) { + public void cycleConfig(Direction side, GuiBase guiBase) { SlotConfiguration.SlotConfig currentSlot = guiBase.getMachine().getSlotConfiguration().getSlotDetails(id).getSideDetail(side); // A bit of a mess, in the future have a way to remove config options from this list @@ -149,11 +83,12 @@ public class SlotConfigPopupElement extends ElementBase { ClientNetworkManager.sendToServer(packetSlotSave); } - private void drawSlotSateColor(DrawContext drawContext, MachineBaseBlockEntity machineBase, Direction side, int slotID, int inx, int iny, GuiBase gui) { + @Override + protected void drawSateColor(DrawContext drawContext, GuiBase gui, Direction side, int inx, int iny) { iny += 4; int sx = inx + getX() + gui.getGuiLeft(); int sy = iny + getY() + gui.getGuiTop(); - SlotConfiguration.SlotConfigHolder slotConfigHolder = machineBase.getSlotConfiguration().getSlotDetails(slotID); + SlotConfiguration.SlotConfigHolder slotConfigHolder = gui.getMachine().getSlotConfiguration().getSlotDetails(id); if (slotConfigHolder == null) { RebornCore.LOGGER.debug("Hmm, this isn't supposed to happen"); return; @@ -167,44 +102,5 @@ public class SlotConfigPopupElement extends ElementBase { RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); GuiUtil.drawGradientRect(drawContext.getMatrices(), sx, sy, 18, 18, color.getColor(), color.getColor()); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - - } - - private boolean isInBox(int rectX, int rectY, int rectWidth, int rectHeight, double pointX, double pointY, GuiBase guiBase) { - rectX += getX(); - rectY += getY(); - return isInRect(guiBase, rectX, rectY, rectWidth, rectHeight, pointX, pointY); - //return (pointX - guiBase.getGuiLeft()) >= rectX - 1 && (pointX - guiBase.getGuiLeft()) < rectX + rectWidth + 1 && (pointY - guiBase.getGuiTop()) >= rectY - 1 && (pointY - guiBase.getGuiTop()) < rectY + rectHeight + 1; - } - - public void drawState(GuiBase gui, - World world, - BakedModel model, - BlockState actualState, - BlockPos pos, - BlockRenderManager dispatcher, - int x, - int y, - Quaternionf quaternion) { - - MatrixStack matrixStack = new MatrixStack(); - matrixStack.push(); - matrixStack.translate(8 + gui.getGuiLeft() + this.x + x, 8 + gui.getGuiTop() + this.y + y, 512); - matrixStack.scale(16F, 16F, 16F); - matrixStack.translate(0.5F, 0.5F, 0.5F); - matrixStack.scale(-1, -1, -1); - - if (quaternion != null) { - matrixStack.multiply(quaternion); - } - - VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer()); - dispatcher.getModelRenderer().render(matrixStack.peek(), immediate.getBuffer(RenderLayer.getSolid()), actualState, model, 1F, 1F, 1F, OverlayTexture.getU(15F), OverlayTexture.DEFAULT_UV); - immediate.draw(); - matrixStack.pop(); - } - - public void drawState(GuiBase gui, World world, BakedModel model, BlockState actualState, BlockPos pos, BlockRenderManager dispatcher, int x, int y) { - drawState(gui, world, model, actualState, pos, dispatcher, x, y, null); } }