Rough reborn core client port

This commit is contained in:
modmuss50 2023-05-13 10:36:43 +01:00 committed by modmuss
parent 876c6154e1
commit 4e0ea809c6
16 changed files with 209 additions and 239 deletions

View file

@ -49,7 +49,7 @@ public class BlockOutlineRenderer implements WorldRenderEvents.BlockOutline {
public boolean onBlockOutline(WorldRenderContext worldRenderContext, WorldRenderContext.BlockOutlineContext context) {
List<VoxelShape> shapes = new ArrayList<>();
World world = context.entity().world;
World world = context.entity().getWorld();
BlockPos targetPos = context.blockPos();
if (context.entity() == MinecraftClient.getInstance().player) {
@ -61,7 +61,7 @@ public class BlockOutlineRenderer implements WorldRenderEvents.BlockOutline {
}
if (stack.getItem() instanceof MultiBlockBreakingTool) {
Set<BlockPos> blockPosList = ((MultiBlockBreakingTool) stack.getItem()).getBlocksToBreak(stack, clientPlayerEntity.world, targetPos, clientPlayerEntity);
Set<BlockPos> blockPosList = ((MultiBlockBreakingTool) stack.getItem()).getBlocksToBreak(stack, clientPlayerEntity.getWorld(), targetPos, clientPlayerEntity);
for (BlockPos pos : blockPosList) {
if (pos.equals(targetPos)) {
@ -82,7 +82,7 @@ public class BlockOutlineRenderer implements WorldRenderEvents.BlockOutline {
shape = VoxelShapes.union(shape, voxelShape);
}
WorldRenderer.drawShapeOutline(worldRenderContext.matrixStack(), worldRenderContext.consumers().getBuffer(RenderLayer.getLines()), shape, (double)targetPos.getX() - context.cameraX(), (double)targetPos.getY() - context.cameraY(), (double)targetPos.getZ() - context.cameraZ(), 0.0F, 0.0F, 0.0F, 0.4F);
WorldRenderer.drawShapeOutline(worldRenderContext.matrixStack(), worldRenderContext.consumers().getBuffer(RenderLayer.getLines()), shape, (double)targetPos.getX() - context.cameraX(), (double)targetPos.getY() - context.cameraY(), (double)targetPos.getZ() - context.cameraZ(), 0.0F, 0.0F, 0.0F, 0.4F, true);
}
return true;

View file

@ -31,6 +31,7 @@ import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.Framebuffer;
import net.minecraft.client.gl.SimpleFramebuffer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.DiffuseLighting;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.util.math.MatrixStack;
@ -53,18 +54,18 @@ public class ItemStackRenderer implements HudRenderCallback {
private static final int SIZE = 512;
@Override
public void onHudRender(MatrixStack matrixStack, float v) {
public void onHudRender(DrawContext drawContext, float v) {
if (!ItemStackRenderManager.RENDER_QUEUE.isEmpty()) {
ItemStack itemStack = ItemStackRenderManager.RENDER_QUEUE.remove();
Identifier id = Registries.ITEM.getId(itemStack.getItem());
MinecraftClient.getInstance().textRenderer.draw(matrixStack, "Rendering " + id + ", " + ItemStackRenderManager.RENDER_QUEUE.size() + " items left", 5, 5, -1);
drawContext.drawText(MinecraftClient.getInstance().textRenderer, "Rendering " + id + ", " + ItemStackRenderManager.RENDER_QUEUE.size() + " items left", 5, 5, -1, true);
export(id, itemStack);
}
}
private void export(Identifier identifier, ItemStack item) {
Matrix4f matrix4f = new Matrix4f().setOrtho(0, 16, 0, 16, 1000, 3000);
RenderSystem.setProjectionMatrix(matrix4f);
RenderSystem.setProjectionMatrix(matrix4f, null); // TODO 1.20
MatrixStack stack = RenderSystem.getModelViewStack();
stack.loadIdentity();
stack.translate(0, 0, -2000);
@ -79,7 +80,7 @@ public class ItemStackRenderer implements HudRenderCallback {
framebuffer.beginWrite(true);
GlStateManager._clear(GL12.GL_COLOR_BUFFER_BIT | GL12.GL_DEPTH_BUFFER_BIT, MinecraftClient.IS_SYSTEM_MAC);
MinecraftClient.getInstance().getItemRenderer().renderInGui(stack, item, 0, 0);
// MinecraftClient.getInstance().getItemRenderer().renderInGui(stack, item, 0, 0); // TODO 1.20
framebuffer.endWrite();
framebuffer.beginRead();

View file

@ -28,6 +28,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.Selectable;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.gui.widget.ClickableWidget;
@ -150,39 +151,39 @@ public class GuiBase<T extends ScreenHandler> extends HandledScreen<T> {
return backgroundWidth;
}
public void drawSlot(MatrixStack matrixStack, int x, int y, Layer layer) {
public void drawSlot(DrawContext drawContext, int x, int y, Layer layer) {
if (layer == Layer.BACKGROUND) {
x += this.x;
y += this.y;
}
builder.drawSlot(matrixStack, this, x - 1, y - 1);
builder.drawSlot(drawContext, this, x - 1, y - 1);
}
public void drawOutputSlotBar(MatrixStack matrixStack, int x, int y, int count, Layer layer) {
public void drawOutputSlotBar(DrawContext drawContext, int x, int y, int count, Layer layer) {
if (layer == Layer.BACKGROUND) {
x += this.x;
y += this.y;
}
builder.drawOutputSlotBar(matrixStack, this, x - 4, y - 4, count);
builder.drawOutputSlotBar(drawContext, this, x - 4, y - 4, count);
}
public void drawArmourSlots(MatrixStack matrixStack, int x, int y, Layer layer) {
public void drawArmourSlots(DrawContext drawContext, int x, int y, Layer layer) {
if (layer == Layer.BACKGROUND) {
x += this.x;
y += this.y;
}
builder.drawSlot(matrixStack, this, x - 1, y - 1);
builder.drawSlot(matrixStack, this, x - 1, y - 1 + 18);
builder.drawSlot(matrixStack, this, x - 1, y - 1 + 18 + 18);
builder.drawSlot(matrixStack, this, x - 1, y - 1 + 18 + 18 + 18);
builder.drawSlot(drawContext, this, x - 1, y - 1);
builder.drawSlot(drawContext, this, x - 1, y - 1 + 18);
builder.drawSlot(drawContext, this, x - 1, y - 1 + 18 + 18);
builder.drawSlot(drawContext, this, x - 1, y - 1 + 18 + 18 + 18);
}
public void drawOutputSlot(MatrixStack matrixStack, int x, int y, Layer layer) {
public void drawOutputSlot(DrawContext drawContext, int x, int y, Layer layer) {
if (layer == Layer.BACKGROUND) {
x += this.x;
y += this.y;
}
builder.drawOutputSlot(matrixStack, this, x - 5, y - 5);
builder.drawOutputSlot(drawContext, this, x - 5, y - 5);
}
@Override
@ -197,31 +198,31 @@ public class GuiBase<T extends ScreenHandler> extends HandledScreen<T> {
}
@Override
protected void drawBackground(MatrixStack matrixStack, float lastFrameDuration, int mouseX, int mouseY) {
protected void drawBackground(DrawContext drawContext, float lastFrameDuration, int mouseX, int mouseY) {
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
renderBackground(matrixStack);
renderBackground(drawContext);
boolean drawPlayerSlots = selectedTab == null && drawPlayerSlots();
updateSlotDraw(drawPlayerSlots);
builder.drawDefaultBackground(matrixStack, this, x, y, xSize, ySize);
builder.drawDefaultBackground(drawContext, this, x, y, xSize, ySize);
if (drawPlayerSlots) {
builder.drawPlayerSlots(matrixStack, this, x + backgroundWidth / 2, y + 93, true);
builder.drawPlayerSlots(drawContext, this, x + backgroundWidth / 2, y + 93, true);
}
if (tryAddUpgrades() && be instanceof IUpgradeable upgradeable) {
if (upgradeable.canBeUpgraded()) {
builder.drawUpgrades(matrixStack, this, x - 24, y + 6);
builder.drawUpgrades(drawContext, this, x - 24, y + 6);
upgrades = true;
}
}
int offset = upgrades ? 86 : 6;
for (GuiTab slot : tabs) {
if (slot.enabled()) {
builder.drawSlotTab(matrixStack, this, x - 24, y + offset, slot.stack());
builder.drawSlotTab(drawContext, this, x - 24, y + offset, slot.stack());
offset += 24;
}
}
final GuiBase<T> gui = this;
getTab().ifPresent(guiTab -> builder.drawSlotConfigTips(matrixStack, gui, x + backgroundWidth / 2, y + 93, mouseX, mouseY, guiTab));
getTab().ifPresent(guiTab -> builder.drawSlotConfigTips(drawContext, gui, x + backgroundWidth / 2, y + 93, mouseX, mouseY, guiTab));
}
@ -245,29 +246,29 @@ public class GuiBase<T extends ScreenHandler> extends HandledScreen<T> {
}
@Override
protected void drawForeground(MatrixStack matrixStack, int mouseX, int mouseY) {
drawTitle(matrixStack);
getTab().ifPresent(guiTab -> guiTab.draw(matrixStack, mouseX, mouseY));
protected void drawForeground(DrawContext drawContext, int mouseX, int mouseY) {
drawTitle(drawContext);
getTab().ifPresent(guiTab -> guiTab.draw(drawContext, mouseX, mouseY));
}
@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
super.render(matrixStack, mouseX, mouseY, partialTicks);
this.drawMouseoverTooltip(matrixStack, mouseX, mouseY);
public void render(DrawContext drawContext, int mouseX, int mouseY, float partialTicks) {
super.render(drawContext, mouseX, mouseY, partialTicks);
this.drawMouseoverTooltip(drawContext, mouseX, mouseY);
}
@Override
protected void drawMouseoverTooltip(MatrixStack matrixStack, int mouseX, int mouseY) {
protected void drawMouseoverTooltip(DrawContext drawContext, int mouseX, int mouseY) {
if (isPointWithinBounds(-25, 6, 24, 80, mouseX, mouseY) && upgrades
&& this.focusedSlot != null && !this.focusedSlot.hasStack()) {
List<Text> list = new ArrayList<>();
list.add(Text.translatable("reborncore.gui.tooltip.upgrades"));
renderTooltip(matrixStack, list, mouseX, mouseY);
drawContext.drawTooltip(MinecraftClient.getInstance().textRenderer, list, mouseX, mouseY);
}
int offset = upgrades ? 82 : 0;
for (GuiTab tab : tabs) {
if (isPointWithinBounds(-26, 6 + offset, 24, 23, mouseX, mouseY)) {
renderTooltip(matrixStack, Collections.singletonList(Text.translatable(tab.name())), mouseX, mouseY);
drawContext.drawTooltip(MinecraftClient.getInstance().textRenderer, Collections.singletonList(Text.translatable(tab.name())), mouseX, mouseY);
}
offset += 24;
}
@ -282,29 +283,29 @@ public class GuiBase<T extends ScreenHandler> extends HandledScreen<T> {
}
}
super.drawMouseoverTooltip(matrixStack, mouseX, mouseY);
super.drawMouseoverTooltip(drawContext, mouseX, mouseY);
}
protected void drawTitle(MatrixStack matrixStack) {
drawCentredText(matrixStack, Text.translatable(be.getCachedState().getBlock().getTranslationKey()), 6, 4210752, Layer.FOREGROUND);
protected void drawTitle(DrawContext drawContext) {
drawCentredText(drawContext, Text.translatable(be.getCachedState().getBlock().getTranslationKey()), 6, 4210752, Layer.FOREGROUND);
}
public void drawCentredText(MatrixStack matrixStack, Text text, int y, int colour, Layer layer) {
drawText(matrixStack, text, (backgroundWidth / 2 - getTextRenderer().getWidth(text) / 2), y, colour, layer);
public void drawCentredText(DrawContext drawContext, Text text, int y, int colour, Layer layer) {
drawText(drawContext, text, (backgroundWidth / 2 - getTextRenderer().getWidth(text) / 2), y, colour, layer);
}
protected void drawCentredText(MatrixStack matrixStack, Text text, int y, int colour, int modifier, Layer layer) {
drawText(matrixStack, text, (backgroundWidth / 2 - (getTextRenderer().getWidth(text)) / 2) + modifier, y, colour, layer);
protected void drawCentredText(DrawContext drawContext, Text text, int y, int colour, int modifier, Layer layer) {
drawText(drawContext, text, (backgroundWidth / 2 - (getTextRenderer().getWidth(text)) / 2) + modifier, y, colour, layer);
}
public void drawText(MatrixStack matrixStack, Text text, int x, int y, int colour, Layer layer) {
public void drawText(DrawContext drawContext, Text text, int x, int y, int colour, Layer layer) {
int factorX = 0;
int factorY = 0;
if (layer == Layer.BACKGROUND) {
factorX = this.x;
factorY = this.y;
}
getTextRenderer().draw(matrixStack, text, x + factorX, y + factorY, colour);
drawContext.drawText(MinecraftClient.getInstance().textRenderer, text, x + factorX, y + factorY, colour, true);
RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
}

View file

@ -24,6 +24,7 @@
package reborncore.client.gui.builder;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
@ -38,7 +39,7 @@ import java.util.Locale;
public class RedstoneConfigGui {
public static void draw(MatrixStack matrixStack, GuiBase<?> guiBase, int mouseX, int mouseY) {
public static void draw(DrawContext drawContext, GuiBase<?> guiBase, int mouseX, int mouseY) {
if (guiBase.getMachine() == null) return;
RedstoneConfiguration configuration = guiBase.getMachine().getRedstoneConfiguration();
GuiBuilder builder = guiBase.builder;
@ -50,16 +51,15 @@ public class RedstoneConfigGui {
int i = 0;
int spread = configuration.getElements().size() == 3 ? 27 : 18;
for (RedstoneConfiguration.Element element : configuration.getElements()) {
itemRenderer.renderInGuiWithOverrides(matrixStack, element.getIcon(), x - 3, y + (i * spread) - 5);
guiBase.getTextRenderer().draw(matrixStack, Text.translatable("reborncore.gui.fluidconfig." + element.getName()), x + 15, y + (i * spread), -1);
drawContext.drawItem(element.getIcon(), x - 3, y + (i * spread) - 5);
drawContext.drawText(guiBase.getTextRenderer(), Text.translatable("reborncore.gui.fluidconfig." + element.getName()), x + 15, y + (i * spread), -1, true);
boolean hovered = withinBounds(guiBase, mouseX, mouseY, x + 92, y + (i * spread) - 2, 63, 15);
int color = hovered ? 0xFF8b8b8b : 0x668b8b8b;
RenderUtil.drawGradientRect(matrixStack, 0, x + 91, y + (i * spread) - 2, x + 93 + 65, y + (i * spread) + 10, color, color);
RenderUtil.drawGradientRect(drawContext.getMatrices(), 0, x + 91, y + (i * spread) - 2, x + 93 + 65, y + (i * spread) + 10, color, color);
Text name = Text.translatable("reborncore.gui.fluidconfig." + configuration.getState(element).name().toLowerCase(Locale.ROOT));
guiBase.drawCentredText(matrixStack, name, y + (i * spread), -1, x + 37, GuiBase.Layer.FOREGROUND);
guiBase.drawCentredText(drawContext, name, y + (i * spread), -1, x + 37, GuiBase.Layer.FOREGROUND);
//guiBase.getTextRenderer().drawWithShadow(name, x + 92, y + (i * spread), -1);
i++;
}

View file

@ -26,6 +26,7 @@ package reborncore.client.gui.builder.slot;
import com.google.common.collect.Lists;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.util.math.MatrixStack;
import org.jetbrains.annotations.Nullable;
import reborncore.client.gui.builder.GuiBase;
@ -45,8 +46,8 @@ public class FluidConfigGui {
fluidConfigElement = new ConfigFluidElement(guiBase.getMachine().getTank(), SlotType.NORMAL, 35 - guiBase.getGuiLeft() + 50, 35 - guiBase.getGuiTop() - 25, guiBase);
}
public static void draw(MatrixStack matrixStack, GuiBase<?> guiBase, int mouseX, int mouseY) {
fluidConfigElement.draw(matrixStack, guiBase);
public static void draw(DrawContext drawContext, GuiBase<?> guiBase, int mouseX, int mouseY) {
fluidConfigElement.draw(drawContext, guiBase);
}
public static List<ConfigFluidElement> getVisibleElements() {

View file

@ -24,7 +24,7 @@
package reborncore.client.gui.builder.slot;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.Validate;
import reborncore.client.gui.builder.GuiBase;
@ -63,8 +63,8 @@ public class GuiTab {
return machineBaseBlockEntity;
}
public void draw(MatrixStack matrixStack, int x, int y) {
builder.draw.draw(matrixStack, guiBase, x, y);
public void draw(DrawContext drawContext, int x, int y) {
builder.draw.draw(drawContext, guiBase, x, y);
}
public boolean click(double mouseX, double mouseY, int mouseButton) {
@ -162,7 +162,7 @@ public class GuiTab {
}
public interface Draw {
void draw(MatrixStack matrixStack, GuiBase<?> guiBase, int mouseX, int mouseY);
void draw(DrawContext drawContext, GuiBase<?> guiBase, int mouseX, int mouseY);
}
public interface Click {

View file

@ -27,6 +27,7 @@ package reborncore.client.gui.builder.slot;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.screen.slot.Slot;
import net.minecraft.text.Text;
@ -74,7 +75,7 @@ public class SlotConfigGui {
}
public static void draw(MatrixStack matrixStack, GuiBase<?> guiBase, int mouseX, int mouseY) {
public static void draw(DrawContext drawContext, GuiBase<?> guiBase, int mouseX, int mouseY) {
BuiltScreenHandler container = guiBase.builtScreenHandler;
for (Slot slot : container.slots) {
if (guiBase.be != slot.inventory) {
@ -82,13 +83,13 @@ public class SlotConfigGui {
}
RenderSystem.setShaderColor(1.0F, 0, 0, 1.0F);
Color color = new Color(255, 0, 0, 128);
GuiUtil.drawGradientRect(matrixStack, slot.x - 1, slot.y - 1, 18, 18, color.getColor(), color.getColor());
GuiUtil.drawGradientRect(drawContext.getMatrices(), slot.x - 1, slot.y - 1, 18, 18, color.getColor(), color.getColor());
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
}
if (selectedSlot != -1) {
slotElementMap.get(selectedSlot).draw(matrixStack, guiBase);
slotElementMap.get(selectedSlot).draw(drawContext, guiBase);
}
}

View file

@ -24,6 +24,7 @@
package reborncore.client.gui.builder.slot.elements;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import reborncore.client.gui.builder.GuiBase;
@ -65,14 +66,14 @@ public class CheckBoxElement extends ElementBase {
}
@Override
public void draw(MatrixStack matrixStack, GuiBase<?> gui) {
public void draw(DrawContext drawContext, GuiBase<?> gui) {
// super.draw(gui);
ISprite sprite = checkBoxSprite.normal();
if (ticked.test(this)) {
sprite = checkBoxSprite.ticked();
}
drawSprite(matrixStack, gui, sprite, x, y);
drawText(matrixStack, gui, label, x + checkBoxSprite.normal().width + 5, ((y + getHeight(gui.getMachine()) / 2) - (gui.getTextRenderer().fontHeight / 2)), labelColor);
drawSprite(drawContext, gui, sprite, x, y);
drawText(drawContext, gui, label, x + checkBoxSprite.normal().width + 5, ((y + getHeight(gui.getMachine()) / 2) - (gui.getTextRenderer().fontHeight / 2)), labelColor);
}
}

View file

@ -24,6 +24,7 @@
package reborncore.client.gui.builder.slot.elements;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import reborncore.client.gui.builder.GuiBase;
@ -67,12 +68,12 @@ public class ConfigFluidElement extends ElementBase {
}
@Override
public void draw(MatrixStack matrixStack, GuiBase<?> gui) {
super.draw(matrixStack, gui);
public void draw(DrawContext drawContext, GuiBase<?> gui) {
super.draw(drawContext, gui);
if (isHovering) {
drawSprite(matrixStack, gui, type.getButtonHoverOverlay(), x, y);
drawSprite(drawContext, gui, type.getButtonHoverOverlay(), x, y);
}
elements.forEach(elementBase -> elementBase.draw(matrixStack, gui));
elements.forEach(elementBase -> elementBase.draw(drawContext, gui));
}
public SlotType getType() {

View file

@ -27,6 +27,7 @@ package reborncore.client.gui.builder.slot.elements;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.inventory.Inventory;
@ -103,25 +104,18 @@ public class ConfigSlotElement extends ElementBase {
}
@Override
public void draw(MatrixStack matrixStack, GuiBase<?> gui) {
super.draw(matrixStack, gui);
public void draw(DrawContext drawContext, GuiBase<?> gui) {
super.draw(drawContext, gui);
ItemStack stack = inventory.getStack(id);
int xPos = x + 1 + gui.getGuiLeft();
int yPos = y + 1 + gui.getGuiTop();
RenderSystem.enableDepthTest();
matrixStack.push();
RenderSystem.enableBlend();
RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA);
ItemRenderer renderItem = MinecraftClient.getInstance().getItemRenderer();
renderItem.renderInGuiWithOverrides(matrixStack, stack, xPos, yPos);
renderItem.renderGuiItemOverlay(matrixStack, gui.getTextRenderer(), stack, xPos, yPos, null);
RenderSystem.disableDepthTest();
matrixStack.pop();
drawContext.drawItemInSlot(gui.getTextRenderer(), stack, xPos, yPos);
if (isHovering) {
drawSprite(matrixStack, gui, type.getButtonHoverOverlay(), x, y);
drawSprite(drawContext, gui, type.getButtonHoverOverlay(), x, y);
}
elements.forEach(elementBase -> elementBase.draw(matrixStack, gui));
elements.forEach(elementBase -> elementBase.draw(drawContext, gui));
}
public SlotType getType() {

View file

@ -27,6 +27,7 @@ package reborncore.client.gui.builder.slot.elements;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.util.math.MatrixStack;
@ -125,9 +126,9 @@ public class ElementBase {
}
}
public void draw(MatrixStack matrixStack, GuiBase<?> gui) {
public void draw(DrawContext drawContext, GuiBase<?> gui) {
for (OffsetSprite sprite : getSpriteContainer().offsetSprites) {
drawSprite(matrixStack, gui, sprite.getSprite(), x + sprite.getOffsetX(gui.getMachine()), y + sprite.getOffsetY(gui.getMachine()));
drawSprite(drawContext, gui, sprite.getSprite(), x + sprite.getOffsetX(gui.getMachine()), y + sprite.getOffsetY(gui.getMachine()));
}
}
@ -294,33 +295,21 @@ public class ElementBase {
return gui.isPointInRect(x + gui.getGuiLeft(), y + gui.getGuiTop(), xSize, ySize, mouseX, mouseY);
}
public void drawText(MatrixStack matrixStack, GuiBase<?> gui, Text text, int x, int y, int color) {
public void drawText(DrawContext drawContext, GuiBase<?> gui, Text text, int x, int y, int color) {
x = adjustX(gui, x);
y = adjustY(gui, y);
gui.getTextRenderer().draw(matrixStack, text, x, y, color);
drawContext.drawText(gui.getTextRenderer(), text, x, y, color, true);
}
public void setTextureSheet(Identifier textureLocation) {
RenderSystem.setShaderTexture(0, textureLocation);
}
public void drawSprite(MatrixStack matrixStack, GuiBase<?> gui, ISprite iSprite, int x, int y) {
public void drawSprite(DrawContext drawContext, GuiBase<?> gui, ISprite iSprite, int x, int y) {
Sprite sprite = iSprite.getSprite(gui.getMachine());
if (sprite != null) {
if (sprite.hasTextureInfo()) {
RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
setTextureSheet(sprite.textureLocation);
gui.drawTexture(matrixStack, x + gui.getGuiLeft(), y + gui.getGuiTop(), sprite.x, sprite.y, sprite.width, sprite.height);
drawContext.drawTexture(sprite.textureLocation, x + gui.getGuiLeft(), y + gui.getGuiTop(), sprite.x, sprite.y, sprite.width, sprite.height);
}
if (sprite.hasStack()) {
matrixStack.push();
RenderSystem.enableBlend();
RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA);
ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
itemRenderer.renderInGuiWithOverrides(matrixStack, sprite.itemStack, x + gui.getGuiLeft(), y + gui.getGuiTop());
matrixStack.pop();
drawContext.drawItem(sprite.itemStack, x + gui.getGuiLeft(), y + gui.getGuiTop());
}
}
}
@ -336,12 +325,10 @@ public class ElementBase {
return (int) ((CurrentValue * 100.0f) / MaxValue);
}
public void drawDefaultBackground(MatrixStack matrixStack, Screen gui, int x, int y, int width, int height) {
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, GuiBuilder.defaultTextureSheet);
gui.drawTexture(matrixStack, x, y, 0, 0, width / 2, height / 2);
gui.drawTexture(matrixStack, x + width / 2, y, 150 - width / 2, 0, width / 2, height / 2);
gui.drawTexture(matrixStack, x, y + height / 2, 0, 150 - height / 2, width / 2, height / 2);
gui.drawTexture(matrixStack, x + width / 2, y + height / 2, 150 - width / 2, 150 - height / 2, width / 2, height / 2);
public void drawDefaultBackground(DrawContext drawContext, Screen gui, int x, int y, int width, int height) {
drawContext.drawTexture(GuiBuilder.defaultTextureSheet, x, y, 0, 0, width / 2, height / 2);
drawContext.drawTexture(GuiBuilder.defaultTextureSheet, x + width / 2, y, 150 - width / 2, 0, width / 2, height / 2);
drawContext.drawTexture(GuiBuilder.defaultTextureSheet, x, y + height / 2, 0, 150 - height / 2, width / 2, height / 2);
drawContext.drawTexture(GuiBuilder.defaultTextureSheet, x + width / 2, y + height / 2, 150 - width / 2, 150 - height / 2, width / 2, height / 2);
}
}

View file

@ -27,6 +27,7 @@ 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;
@ -63,9 +64,9 @@ public class FluidConfigPopupElement extends ElementBase {
}
@Override
public void draw(MatrixStack matrixStack, GuiBase<?> gui) {
drawDefaultBackground(matrixStack, gui, adjustX(gui, getX() - 8), adjustY(gui, getY() - 7), 84, 105 + (filter ? 15 : 0));
super.draw(matrixStack, gui);
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();
@ -82,12 +83,12 @@ public class FluidConfigPopupElement extends ElementBase {
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(matrixStack, gui.getMachine(), MachineFacing.UP.getFacing(machine), 22, -1, gui);
drawSateColor(matrixStack, gui.getMachine(), MachineFacing.FRONT.getFacing(machine), 22, 18, gui);
drawSateColor(matrixStack, gui.getMachine(), MachineFacing.DOWN.getFacing(machine), 22, 37, gui);
drawSateColor(matrixStack, gui.getMachine(), MachineFacing.RIGHT.getFacing(machine), 41, 18, gui);
drawSateColor(matrixStack, gui.getMachine(), MachineFacing.BACK.getFacing(machine), 41, 37, gui);
drawSateColor(matrixStack, gui.getMachine(), MachineFacing.LEFT.getFacing(machine), 3, 18, gui);
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
@ -142,7 +143,7 @@ public class FluidConfigPopupElement extends ElementBase {
return super.onHover(provider, gui, mouseX, mouseY);
}
private void drawSateColor(MatrixStack matrices, MachineBaseBlockEntity machineBase, Direction side, int inx, int iny, GuiBase<?> gui) {
private void drawSateColor(DrawContext drawContext, MachineBaseBlockEntity machineBase, Direction side, int inx, int iny, GuiBase<?> gui) {
iny += 4;
int sx = inx + getX() + gui.getGuiLeft();
int sy = iny + getY() + gui.getGuiTop();
@ -159,7 +160,7 @@ public class FluidConfigPopupElement extends ElementBase {
case ALL -> new Color(52, 255, 30, 128);
};
RenderSystem.setShaderColor(1, 1, 1, 1);
GuiUtil.drawGradientRect(matrices, sx, sy, 18, 18, color.getColor(), color.getColor());
GuiUtil.drawGradientRect(drawContext.getMatrices(), sx, sy, 18, 18, color.getColor(), color.getColor());
RenderSystem.setShaderColor(1, 1, 1, 1);
}

View file

@ -27,6 +27,7 @@ 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;
@ -67,9 +68,9 @@ public class SlotConfigPopupElement extends ElementBase {
}
@Override
public void draw(MatrixStack matrixStack, GuiBase<?> gui) {
drawDefaultBackground(matrixStack, gui, adjustX(gui, getX() - 8), adjustY(gui, getY() - 7), 84, 105 + (filter ? 15 : 0));
super.draw(matrixStack, gui);
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();
@ -86,12 +87,12 @@ public class SlotConfigPopupElement extends ElementBase {
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(matrixStack, gui.getMachine(), MachineFacing.UP.getFacing(machine), id, 22, -1, gui);
drawSlotSateColor(matrixStack, gui.getMachine(), MachineFacing.FRONT.getFacing(machine), id, 22, 18, gui);
drawSlotSateColor(matrixStack, gui.getMachine(), MachineFacing.DOWN.getFacing(machine), id, 22, 37, gui);
drawSlotSateColor(matrixStack, gui.getMachine(), MachineFacing.RIGHT.getFacing(machine), id, 41, 18, gui);
drawSlotSateColor(matrixStack, gui.getMachine(), MachineFacing.BACK.getFacing(machine), id, 41, 37, gui);
drawSlotSateColor(matrixStack, gui.getMachine(), MachineFacing.LEFT.getFacing(machine), id, 3, 18, gui);
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
@ -148,7 +149,7 @@ public class SlotConfigPopupElement extends ElementBase {
ClientNetworkManager.sendToServer(packetSlotSave);
}
private void drawSlotSateColor(MatrixStack matrices, MachineBaseBlockEntity machineBase, Direction side, int slotID, int inx, int iny, GuiBase<?> gui) {
private void drawSlotSateColor(DrawContext drawContext, MachineBaseBlockEntity machineBase, Direction side, int slotID, int inx, int iny, GuiBase<?> gui) {
iny += 4;
int sx = inx + getX() + gui.getGuiLeft();
int sy = iny + getY() + gui.getGuiTop();
@ -164,7 +165,7 @@ public class SlotConfigPopupElement extends ElementBase {
default -> new Color(0, 0, 0, 0);
};
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
GuiUtil.drawGradientRect(matrices, sx, sy, 18, 18, color.getColor(), color.getColor());
GuiUtil.drawGradientRect(drawContext.getMatrices(), sx, sy, 18, 18, color.getColor(), color.getColor());
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
}

View file

@ -24,6 +24,7 @@
package reborncore.client.gui.builder.widget;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
@ -44,7 +45,7 @@ public class GuiButtonHologram extends GuiButtonExtended {
}
@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
public void render(DrawContext drawContext, int mouseX, int mouseY, float partialTicks) {
}
}

View file

@ -24,9 +24,8 @@
package reborncore.client.gui.builder.widget;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import reborncore.client.gui.builder.GuiBase;
@ -45,24 +44,13 @@ public class GuiButtonUpDown extends GuiButtonExtended {
}
@Override
public void renderButton(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
public void renderButton(DrawContext drawContext, int mouseX, int mouseY, float partialTicks) {
if (gui.hideGuiElements()) return;
RenderSystem.setShaderTexture(0, gui.builder.getResourceLocation());
switch (type) {
case FASTFORWARD:
gui.drawTexture(matrixStack, getX(), getY(), 174, 74, 12, 12);
break;
case FORWARD:
gui.drawTexture(matrixStack, getX(), getY(), 174, 86, 12, 12);
break;
case REWIND:
gui.drawTexture(matrixStack, getX(), getY(), 174, 98, 12, 12);
break;
case FASTREWIND:
gui.drawTexture(matrixStack, getX(), getY(), 174, 110, 12, 12);
break;
default:
break;
case FASTFORWARD -> drawContext.drawTexture(gui.builder.getResourceLocation(), getX(), getY(), 174, 74, 12, 12);
case FORWARD -> drawContext.drawTexture(gui.builder.getResourceLocation(), getX(), getY(), 174, 86, 12, 12);
case REWIND -> drawContext.drawTexture(gui.builder.getResourceLocation(), getX(), getY(), 174, 98, 12, 12);
case FASTREWIND -> drawContext.drawTexture(gui.builder.getResourceLocation(), getX(), getY(), 174, 110, 12, 12);
}
}

View file

@ -29,7 +29,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
import net.fabricmc.fabric.api.transfer.v1.client.fluid.FluidVariantRendering;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.gui.widget.EntryListWidget;
@ -38,7 +38,6 @@ import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.PlayerScreenHandler;
@ -80,17 +79,15 @@ public class GuiBuilder {
return resourceLocation;
}
public void drawDefaultBackground(MatrixStack matrixStack, Screen gui, int x, int y, int width, int height) {
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 0, 0, width / 2, height / 2);
gui.drawTexture(matrixStack, x + width / 2, y, 150 - width / 2, 0, width / 2, height / 2);
gui.drawTexture(matrixStack, x, y + height / 2, 0, 150 - height / 2, width / 2, height / 2);
gui.drawTexture(matrixStack, x + width / 2, y + height / 2, 150 - width / 2, 150 - height / 2, width / 2,
public void drawDefaultBackground(DrawContext drawContext, Screen gui, int x, int y, int width, int height) {
drawContext.drawTexture(resourceLocation, x, y, 0, 0, width / 2, height / 2);
drawContext.drawTexture(resourceLocation, x + width / 2, y, 150 - width / 2, 0, width / 2, height / 2);
drawContext.drawTexture(resourceLocation, x, y + height / 2, 0, 150 - height / 2, width / 2, height / 2);
drawContext.drawTexture(resourceLocation, x + width / 2, y + height / 2, 150 - width / 2, 150 - height / 2, width / 2,
height / 2);
}
public void drawPlayerSlots(MatrixStack matrixStack, Screen gui, int posX, int posY, boolean center) {
public void drawPlayerSlots(DrawContext drawContext, Screen gui, int posX, int posY, boolean center) {
RenderSystem.setShaderTexture(0, resourceLocation);
if (center) {
@ -99,36 +96,36 @@ public class GuiBuilder {
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 9; x++) {
gui.drawTexture(matrixStack, posX + x * 18, posY + y * 18, 150, 0, 18, 18);
drawContext.drawTexture(resourceLocation, posX + x * 18, posY + y * 18, 150, 0, 18, 18);
}
}
for (int x = 0; x < 9; x++) {
gui.drawTexture(matrixStack, posX + x * 18, posY + 58, 150, 0, 18, 18);
drawContext.drawTexture(resourceLocation, posX + x * 18, posY + 58, 150, 0, 18, 18);
}
}
public void drawSlot(MatrixStack matrixStack, Screen gui, int posX, int posY) {
public void drawSlot(DrawContext drawContext, Screen gui, int posX, int posY) {
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, posX, posY, 150, 0, 18, 18);
drawContext.drawTexture(resourceLocation, posX, posY, 150, 0, 18, 18);
}
public void drawText(MatrixStack matrixStack, GuiBase<?> gui, Text text, int x, int y, int color) {
gui.getTextRenderer().draw(matrixStack, text, x, y, color);
public void drawText(DrawContext drawContext, GuiBase<?> gui, Text text, int x, int y, int color) {
drawContext.drawText(gui.getTextRenderer(), text, x, y, color, true);
}
public void drawProgressBar(MatrixStack matrixStack, GuiBase<?> gui, double progress, int x, int y) {
public void drawProgressBar(DrawContext drawContext, GuiBase<?> gui, double progress, int x, int y) {
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 150, 18, 22, 15);
drawContext.drawTexture(resourceLocation, x, y, 150, 18, 22, 15);
int j = (int) (progress);
if (j > 0) {
gui.drawTexture(matrixStack, x, y, 150, 34, j + 1, 15);
drawContext.drawTexture(resourceLocation, x, y, 150, 34, j + 1, 15);
}
}
public void drawOutputSlot(MatrixStack matrixStack, GuiBase<?> gui, int x, int y) {
public void drawOutputSlot(DrawContext drawContext, GuiBase<?> gui, int x, int y) {
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 174, 0, 26, 26);
drawContext.drawTexture(resourceLocation, x, y, 174, 0, 26, 26);
}
/**
@ -139,7 +136,7 @@ public class GuiBuilder {
* @param y {@code int} Top left corner where to place button
* @param layer {@link GuiBase.Layer} The layer to draw on
*/
public void drawJEIButton(MatrixStack matrixStack, GuiBase<?> gui, int x, int y, GuiBase.Layer layer) {
public void drawJEIButton(DrawContext drawContext, GuiBase<?> gui, int x, int y, GuiBase.Layer layer) {
if (gui.hideGuiElements()) return;
if (FabricLoader.getInstance().isModLoaded("jei")) {
if (layer == GuiBase.Layer.BACKGROUND) {
@ -147,7 +144,7 @@ public class GuiBuilder {
y += gui.getGuiTop();
}
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 202, 0, 12, 12);
drawContext.drawTexture(resourceLocation, x, y, 202, 0, 12, 12);
}
}
@ -162,14 +159,14 @@ public class GuiBuilder {
* @param layer {@link GuiBase.Layer} The layer to draw on
* @param locked {@code boolean} Set to true if it is in locked state
*/
public void drawLockButton(MatrixStack matrixStack, GuiBase<?> gui, int x, int y, int mouseX, int mouseY, GuiBase.Layer layer, boolean locked) {
public void drawLockButton(DrawContext drawContext, GuiBase<?> gui, int x, int y, int mouseX, int mouseY, GuiBase.Layer layer, boolean locked) {
if (gui.hideGuiElements()) return;
if (layer == GuiBase.Layer.BACKGROUND) {
x += gui.getGuiLeft();
y += gui.getGuiTop();
}
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 174, 26 + (locked ? 12 : 0), 20, 12);
drawContext.drawTexture(resourceLocation, x, y, 174, 26 + (locked ? 12 : 0), 20, 12);
if (gui.isPointInRect(x, y, 20, 12, mouseX, mouseY)) {
List<Text> list = new ArrayList<>();
if (locked) {
@ -177,9 +174,7 @@ public class GuiBuilder {
} else {
list.add(Text.translatable("reborncore.gui.tooltip.lock_items"));
}
matrixStack.push();
gui.renderTooltip(matrixStack, list, mouseX, mouseY);
matrixStack.pop();
drawContext.drawTooltip(gui.getTextRenderer(), list, mouseX, mouseY);
}
}
@ -193,7 +188,7 @@ public class GuiBuilder {
* @param mouseY {@code int} Mouse cursor position to check for tooltip
* @param layer {@link GuiBase.Layer} The layer to draw on
*/
public void drawHologramButton(MatrixStack matrixStack, GuiBase<?> gui, int x, int y, int mouseX, int mouseY, GuiBase.Layer layer) {
public void drawHologramButton(DrawContext drawContext, GuiBase<?> gui, int x, int y, int mouseX, int mouseY, GuiBase.Layer layer) {
if (gui.isTabOpen()) return;
if (layer == GuiBase.Layer.BACKGROUND) {
x += gui.getGuiLeft();
@ -201,20 +196,18 @@ public class GuiBuilder {
}
RenderSystem.setShaderTexture(0, resourceLocation);
if (gui.getMachine().renderMultiblock) {
gui.drawTexture(matrixStack, x, y, 174, 62, 20, 12);
drawContext.drawTexture(resourceLocation, x, y, 174, 62, 20, 12);
} else {
gui.drawTexture(matrixStack, x, y, 174, 50, 20, 12);
drawContext.drawTexture(resourceLocation, x, y, 174, 50, 20, 12);
}
if (gui.isPointInRect(x, y, 20, 12, mouseX, mouseY)) {
List<Text> list = new ArrayList<>();
list.add(Text.translatable("reborncore.gui.tooltip.hologram"));
matrixStack.push();
if (layer == GuiBase.Layer.FOREGROUND) {
mouseX -= gui.getGuiLeft();
mouseY -= gui.getGuiTop();
}
gui.renderTooltip(matrixStack, list, mouseX, mouseY);
matrixStack.pop();
drawContext.drawTooltip(gui.getTextRenderer(), list, mouseX, mouseY);
}
}
@ -228,25 +221,25 @@ public class GuiBuilder {
* @param max {@code int} Maximum heat value
* @param layer {@link GuiBase.Layer} The layer to draw on
*/
public void drawBigHeatBar(MatrixStack matrixStack, GuiBase<?> gui, int x, int y, int value, int max, GuiBase.Layer layer) {
public void drawBigHeatBar(DrawContext drawContext, GuiBase<?> gui, int x, int y, int value, int max, GuiBase.Layer layer) {
if (gui.hideGuiElements()) return;
if (layer == GuiBase.Layer.BACKGROUND) {
x += gui.getGuiLeft();
y += gui.getGuiTop();
}
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 26, 218, 114, 18);
drawContext.drawTexture(resourceLocation, x, y, 26, 218, 114, 18);
if (value != 0) {
int j = (int) ((double) value / (double) max * 106);
if (j < 0) {
j = 0;
}
gui.drawTexture(matrixStack, x + 4, y + 4, 26, 246, j, 10);
drawContext.drawTexture(resourceLocation, x + 4, y + 4, 26, 246, j, 10);
Text text = Text.literal(String.valueOf(value))
.append(Text.translatable("reborncore.gui.heat"));
gui.drawCentredText(matrixStack, text, y + 5, 0xFFFFFF, layer);
gui.drawCentredText(drawContext, text, y + 5, 0xFFFFFF, layer);
}
}
@ -265,7 +258,7 @@ public class GuiBuilder {
* @param format {@link String} Formatted value to put on the bar
* @param layer {@link GuiBase.Layer} The layer to draw on
*/
public void drawBigBlueBar(MatrixStack matrixStack, GuiBase<?> gui, int x, int y, int value, int max, int mouseX, int mouseY, String suffix, Text line2, String format, GuiBase.Layer layer) {
public void drawBigBlueBar(DrawContext drawContext, GuiBase<?> gui, int x, int y, int value, int max, int mouseX, int mouseY, String suffix, Text line2, String format, GuiBase.Layer layer) {
if (gui.hideGuiElements()) return;
if (layer == GuiBase.Layer.BACKGROUND) {
x += gui.getGuiLeft();
@ -276,11 +269,11 @@ public class GuiBuilder {
if (j < 0) {
j = 0;
}
gui.drawTexture(matrixStack, x + 4, y + 4, 0, 236, j, 10);
drawContext.drawTexture(resourceLocation, x + 4, y + 4, 0, 236, j, 10);
if (!suffix.equals("")) {
suffix = " " + suffix;
}
gui.drawCentredText(matrixStack, Text.literal(format).append(suffix), y + 5, 0xFFFFFF, layer);
gui.drawCentredText(drawContext, Text.literal(format).append(suffix), y + 5, 0xFFFFFF, layer);
if (gui.isPointInRect(x, y, 114, 18, mouseX, mouseY)) {
int percentage = percentage(max, value);
List<Text> list = new ArrayList<>();
@ -323,19 +316,19 @@ public class GuiBuilder {
mouseX -= gui.getGuiLeft();
mouseY -= gui.getGuiTop();
}
gui.renderTooltip(matrixStack, list, mouseX, mouseY);
drawContext.drawTooltip(gui.getTextRenderer(), list, mouseX, mouseY);
//RenderSystem.disableLighting();
RenderSystem.setShaderColor(1, 1, 1, 1);
}
}
public void drawBigBlueBar(MatrixStack matrixStack, GuiBase<?> gui, int x, int y, int value, int max, int mouseX, int mouseY, String suffix, GuiBase.Layer layer) {
drawBigBlueBar(matrixStack, gui, x, y, value, max, mouseX, mouseY, suffix, Text.empty(), Integer.toString(value), layer);
public void drawBigBlueBar(DrawContext drawContext, GuiBase<?> gui, int x, int y, int value, int max, int mouseX, int mouseY, String suffix, GuiBase.Layer layer) {
drawBigBlueBar(drawContext, gui, x, y, value, max, mouseX, mouseY, suffix, Text.empty(), Integer.toString(value), layer);
}
public void drawBigBlueBar(MatrixStack matrixStack, GuiBase<?> gui, int x, int y, int value, int max, int mouseX, int mouseY, GuiBase.Layer layer) {
drawBigBlueBar(matrixStack, gui, x, y, value, max, mouseX, mouseY, "", Text.empty(), "", layer);
public void drawBigBlueBar(DrawContext drawContext, GuiBase<?> gui, int x, int y, int value, int max, int mouseX, int mouseY, GuiBase.Layer layer) {
drawBigBlueBar(drawContext, gui, x, y, value, max, mouseX, mouseY, "", Text.empty(), "", layer);
}
/**
@ -344,7 +337,7 @@ public class GuiBuilder {
* @param gui {@link GuiBase} The GUI to draw on
* @param layer {@link GuiBase.Layer} The layer to draw on
*/
public void drawMultiblockMissingBar(MatrixStack matrixStack, GuiBase<?> gui, GuiBase.Layer layer) {
public void drawMultiblockMissingBar(DrawContext drawContext, GuiBase<?> gui, GuiBase.Layer layer) {
if (gui.hideGuiElements()) return;
int x = 0;
int y = 4;
@ -355,12 +348,12 @@ public class GuiBuilder {
//RenderSystem.disableLighting();
RenderSystem.enableDepthTest();
RenderSystem.colorMask(true, true, true, false);
RenderUtil.drawGradientRect(matrixStack, 0, x, y, x + 176, y + 20, 0x000000, 0xC0000000);
RenderUtil.drawGradientRect(matrixStack, 0, x, y + 20, x + 176, y + 20 + 48, 0xC0000000, 0xC0000000);
RenderUtil.drawGradientRect(matrixStack, 0, x, y + 68, x + 176, y + 70 + 20, 0xC0000000, 0x00000000);
RenderUtil.drawGradientRect(drawContext.getMatrices(), 0, x, y, x + 176, y + 20, 0x000000, 0xC0000000);
RenderUtil.drawGradientRect(drawContext.getMatrices(), 0, x, y + 20, x + 176, y + 20 + 48, 0xC0000000, 0xC0000000);
RenderUtil.drawGradientRect(drawContext.getMatrices(), 0, x, y + 68, x + 176, y + 70 + 20, 0xC0000000, 0x00000000);
RenderSystem.colorMask(true, true, true, true);
RenderSystem.disableDepthTest();
gui.drawCentredText(matrixStack, Text.translatable("reborncore.gui.missingmultiblock"), 43, 0xFFFFFF, layer);
gui.drawCentredText(drawContext, Text.translatable("reborncore.gui.missingmultiblock"), 43, 0xFFFFFF, layer);
}
/**
@ -371,9 +364,9 @@ public class GuiBuilder {
* @param x {@code int} Top left corner where to place slots
* @param y {@code int} Top left corner where to place slots
*/
public void drawUpgrades(MatrixStack matrixStack, GuiBase<?> gui, int x, int y) {
public void drawUpgrades(DrawContext drawContext, GuiBase<?> gui, int x, int y) {
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 217, 0, 24, 81);
drawContext.drawTexture(resourceLocation, x, y, 217, 0, 24, 81);
}
/**
@ -384,10 +377,9 @@ public class GuiBuilder {
* @param y {@code int} Top left corner where to place tab
* @param stack {@link ItemStack} Item to show as tab icon
*/
public void drawSlotTab(MatrixStack matrixStack, GuiBase<?> gui, int x, int y, ItemStack stack) {
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 217, 82, 24, 24);
gui.getMinecraft().getItemRenderer().renderInGuiWithOverrides(matrixStack, stack, x + 5, y + 4);
public void drawSlotTab(DrawContext drawContext, GuiBase<?> gui, int x, int y, ItemStack stack) {
drawContext.drawTexture(resourceLocation, x, y, 217, 82, 24, 24);
drawContext.drawItem(stack, x + 5, y + 4);
}
@ -400,14 +392,14 @@ public class GuiBuilder {
* @param mouseX {@code int} Mouse cursor position
* @param mouseY {@code int} Mouse cursor position
*/
public void drawSlotConfigTips(MatrixStack matrixStack, GuiBase<?> gui, int x, int y, int mouseX, int mouseY, GuiTab guiTab) {
public void drawSlotConfigTips(DrawContext drawContext, GuiBase<?> gui, int x, int y, int mouseX, int mouseY, GuiTab guiTab) {
List<Text> tips = guiTab.getTips().stream()
.map(Text::translatable)
.collect(Collectors.toList());
TipsListWidget explanation = new TipsListWidget(gui, gui.getScreenWidth() - 14, 54, y, y + 76, 9 + 2, tips);
explanation.setLeftPos(x - 81);
explanation.render(matrixStack, mouseX, mouseY, 1.0f);
explanation.render(drawContext, mouseX, mouseY, 1.0f);
RenderSystem.setShaderColor(1, 1, 1, 1);
}
@ -427,15 +419,15 @@ public class GuiBuilder {
}
@Override
protected void renderBackground(MatrixStack matrixStack) {
protected void renderBackground(DrawContext drawContext) {
}
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) {
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
RenderSystem.setShaderTexture(0, OPTIONS_BACKGROUND_TEXTURE);
RenderSystem.setShaderTexture(0, Screen.OPTIONS_BACKGROUND_TEXTURE);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
bufferBuilder.vertex(this.left, this.bottom, 0.0D).texture((float) this.left / 32.0F, (float) (this.bottom + (int) this.getScrollAmount()) / 32.0F).color(32, 32, 32, 255).next();
@ -444,7 +436,7 @@ public class GuiBuilder {
bufferBuilder.vertex(this.left, this.top, 0.0D).texture((float) this.left / 32.0F, (float) (this.top + (int) this.getScrollAmount()) / 32.0F).color(32, 32, 32, 255).next();
tessellator.draw();
super.renderList(matrices, mouseX, mouseY, delta);
super.renderList(drawContext, mouseX, mouseY, delta);
}
@Override
@ -460,8 +452,8 @@ public class GuiBuilder {
}
@Override
public void render(MatrixStack matrixStack, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean hovering, float delta) {
MinecraftClient.getInstance().textRenderer.drawTrimmed(matrixStack, tip, x, y, width, 11184810);
public void render(DrawContext drawContext, int index, int y, int x, int width, int height, int mouseX, int mouseY, boolean hovering, float delta) {
drawContext.drawTooltip(MinecraftClient.getInstance().textRenderer, tip, x, y);
}
}
}
@ -477,7 +469,7 @@ public class GuiBuilder {
* @param maxOutput {@code int} Energy output value
* @param layer {@link GuiBase.Layer} The layer to draw on
*/
public void drawEnergyOutput(MatrixStack matrixStack, GuiBase<?> gui, int x, int y, int maxOutput, GuiBase.Layer layer) {
public void drawEnergyOutput(DrawContext drawContext, GuiBase<?> gui, int x, int y, int maxOutput, GuiBase.Layer layer) {
if (gui.hideGuiElements()) return;
Text text = Text.literal(PowerSystem.getLocalizedPowerNoSuffix(maxOutput))
.append(SPACE_TEXT)
@ -485,13 +477,13 @@ public class GuiBuilder {
.append("\t");
int width = gui.getTextRenderer().getWidth(text);
gui.drawText(matrixStack, text, x - width - 2, y + 5, 0, layer);
gui.drawText(drawContext, text, x - width - 2, y + 5, 0, layer);
if (layer == GuiBase.Layer.BACKGROUND) {
x += gui.getGuiLeft();
y += gui.getGuiTop();
}
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 150, 91, 16, 16);
drawContext.drawTexture(resourceLocation, x, y, 150, 91, 16, 16);
}
/**
@ -507,7 +499,7 @@ public class GuiBuilder {
* @param direction {@link ProgressDirection} Direction of the progress arrow
* @param layer {@link GuiBase.Layer} The layer to draw on
*/
public void drawProgressBar(MatrixStack matrixStack, GuiBase<?> gui, int progress, int maxProgress, int x, int y, int mouseX, int mouseY, ProgressDirection direction, GuiBase.Layer layer) {
public void drawProgressBar(DrawContext drawContext, GuiBase<?> gui, int progress, int maxProgress, int x, int y, int mouseX, int mouseY, ProgressDirection direction, GuiBase.Layer layer) {
if (gui.hideGuiElements()) return;
if (layer == GuiBase.Layer.BACKGROUND) {
x += gui.getGuiLeft();
@ -515,7 +507,7 @@ public class GuiBuilder {
}
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, direction.x, direction.y, direction.width, direction.height);
drawContext.drawTexture(resourceLocation, x, y, direction.x, direction.y, direction.width, direction.height);
int j = (int) ((double) progress / (double) maxProgress * 16);
if (j < 0) {
j = 0;
@ -523,16 +515,16 @@ public class GuiBuilder {
switch (direction) {
case RIGHT:
gui.drawTexture(matrixStack, x, y, direction.xActive, direction.yActive, j, 10);
drawContext.drawTexture(resourceLocation, x, y, direction.xActive, direction.yActive, j, 10);
break;
case LEFT:
gui.drawTexture(matrixStack, x + 16 - j, y, direction.xActive + 16 - j, direction.yActive, j, 10);
drawContext.drawTexture(resourceLocation, x + 16 - j, y, direction.xActive + 16 - j, direction.yActive, j, 10);
break;
case UP:
gui.drawTexture(matrixStack, x, y + 16 - j, direction.xActive, direction.yActive + 16 - j, 10, j);
drawContext.drawTexture(resourceLocation, x, y + 16 - j, direction.xActive, direction.yActive + 16 - j, 10, j);
break;
case DOWN:
gui.drawTexture(matrixStack, x, y, direction.xActive, direction.yActive, 10, j);
drawContext.drawTexture(resourceLocation, x, y, direction.xActive, direction.yActive, 10, j);
break;
default:
return;
@ -550,7 +542,7 @@ public class GuiBuilder {
mouseX -= gui.getGuiLeft();
mouseY -= gui.getGuiTop();
}
gui.renderTooltip(matrixStack, list, mouseX, mouseY);
drawContext.drawTooltip(gui.getTextRenderer(), list, mouseX, mouseY);
//RenderSystem.disableLighting();
RenderSystem.setShaderColor(1, 1, 1, 1);
}
@ -569,7 +561,7 @@ public class GuiBuilder {
* @param buttonID {@code int} Button ID used to switch energy systems
* @param layer {@link GuiBase.Layer} The layer to draw on
*/
public void drawMultiEnergyBar(MatrixStack matrixStack, GuiBase<?> gui, int x, int y, long energyStored, long maxEnergyStored, int mouseX,
public void drawMultiEnergyBar(DrawContext drawContext, GuiBase<?> gui, int x, int y, long energyStored, long maxEnergyStored, int mouseX,
int mouseY, int buttonID, GuiBase.Layer layer) {
if (gui.hideGuiElements()) return;
if (layer == GuiBase.Layer.BACKGROUND) {
@ -579,12 +571,12 @@ public class GuiBuilder {
EnergySystem displayPower = PowerSystem.getDisplayPower();
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, displayPower.xBar - 15, displayPower.yBar - 1, 14, 50);
drawContext.drawTexture(resourceLocation, x, y, displayPower.xBar - 15, displayPower.yBar - 1, 14, 50);
int draw = (int) ((double) energyStored / (double) maxEnergyStored * (48));
if (energyStored > maxEnergyStored) {
draw = 48;
}
gui.drawTexture(matrixStack, x + 1, y + 49 - draw, displayPower.xBar, 48 + displayPower.yBar - draw, 12, draw);
drawContext.drawTexture(resourceLocation, x + 1, y + 49 - draw, displayPower.xBar, 48 + displayPower.yBar - draw, 12, draw);
int percentage = percentage(maxEnergyStored, energyStored);
if (gui.isPointInRect(x + 1, y + 1, 11, 48, mouseX, mouseY)) {
List<Text> list = Lists.newArrayList();
@ -631,7 +623,7 @@ public class GuiBuilder {
mouseX -= gui.getGuiLeft();
mouseY -= gui.getGuiTop();
}
gui.renderTooltip(matrixStack, list, mouseX, mouseY);
drawContext.drawTooltip(gui.getTextRenderer(), list, mouseX, mouseY);
//RenderSystem.disableLighting();
RenderSystem.setShaderColor(1, 1, 1, 1);
}
@ -650,7 +642,7 @@ public class GuiBuilder {
* @param isTankEmpty {@code boolean} True if tank is empty
* @param layer {@link GuiBase.Layer} The layer to draw on
*/
public void drawTank(MatrixStack matrixStack, GuiBase<?> gui, int x, int y, int mouseX, int mouseY, FluidInstance fluid, FluidValue maxCapacity, boolean isTankEmpty, GuiBase.Layer layer) {
public void drawTank(DrawContext drawContext, GuiBase<?> gui, int x, int y, int mouseX, int mouseY, FluidInstance fluid, FluidValue maxCapacity, boolean isTankEmpty, GuiBase.Layer layer) {
if (gui.hideGuiElements()) return;
if (layer == GuiBase.Layer.BACKGROUND) {
x += gui.getGuiLeft();
@ -664,11 +656,11 @@ public class GuiBuilder {
percentage = percentage(maxCapacity.getRawValue(), amount.getRawValue());
}
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 194, 26, 22, 56);
drawContext.drawTexture(resourceLocation, x, y, 194, 26, 22, 56);
if (!isTankEmpty) {
drawFluid(matrixStack, gui, fluid, x + 4, y + 4, 14, 48, maxCapacity.getRawValue());
drawFluid(drawContext, gui, fluid, x + 4, y + 4, 14, 48, maxCapacity.getRawValue());
}
gui.drawTexture(matrixStack, x + 3, y + 3, 194, 82, 16, 50);
drawContext.drawTexture(resourceLocation, x + 3, y + 3, 194, 82, 16, 50);
if (gui.isPointInRect(x, y, 22, 56, mouseX, mouseY)) {
List<Text> list = new ArrayList<>();
@ -694,7 +686,7 @@ public class GuiBuilder {
mouseX -= gui.getGuiLeft();
mouseY -= gui.getGuiTop();
}
gui.renderTooltip(matrixStack, list, mouseX, mouseY);
drawContext.drawTooltip(gui.getTextRenderer(), list, mouseX, mouseY);
//RenderSystem.disableLighting();
RenderSystem.setShaderColor(1, 1, 1, 1);
}
@ -711,7 +703,7 @@ public class GuiBuilder {
* @param height {@code int} Height of fluid to draw
* @param maxCapacity {@code int} Maximum capacity of tank
*/
public void drawFluid(MatrixStack matrixStack, GuiBase<?> gui, FluidInstance fluid, int x, int y, int width, int height, long maxCapacity) {
public void drawFluid(DrawContext drawContext, GuiBase<?> gui, FluidInstance fluid, int x, int y, int width, int height, long maxCapacity) {
if (fluid.getFluid() == Fluids.EMPTY) {
return;
}
@ -730,7 +722,7 @@ public class GuiBuilder {
while (offsetHeight != 0) {
final int curHeight = offsetHeight < iconHeight ? offsetHeight : iconHeight;
DrawableHelper.drawSprite(matrixStack, x, y - offsetHeight, 0, width, curHeight, sprite);
drawContext.drawSprite(x, y - offsetHeight, 0, width, curHeight, sprite);
offsetHeight -= curHeight;
iteration++;
if (iteration > 50) {
@ -754,17 +746,17 @@ public class GuiBuilder {
* @param mouseY {@code int} Mouse cursor position to check for tooltip
* @param layer {@link GuiBase.Layer} The layer to draw on
*/
public void drawBurnBar(MatrixStack matrixStack, GuiBase<?> gui, int progress, int maxProgress, int x, int y, int mouseX, int mouseY, GuiBase.Layer layer) {
public void drawBurnBar(DrawContext drawContext, GuiBase<?> gui, int progress, int maxProgress, int x, int y, int mouseX, int mouseY, GuiBase.Layer layer) {
if (gui.hideGuiElements()) return;
if (layer == GuiBase.Layer.BACKGROUND) {
x += gui.getGuiLeft();
y += gui.getGuiTop();
}
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 150, 64, 13, 13);
drawContext.drawTexture(resourceLocation, x, y, 150, 64, 13, 13);
int j = 13 - (int) ((double) progress / (double) maxProgress * 13);
if (j > 0) {
gui.drawTexture(matrixStack, x, y + j, 150, 51 + j, 13, 13 - j);
drawContext.drawTexture(resourceLocation, x, y + j, 150, 51 + j, 13, 13 - j);
}
if (gui.isPointInRect(x, y, 12, 12, mouseX, mouseY)) {
@ -775,7 +767,7 @@ public class GuiBuilder {
mouseX -= gui.getGuiLeft();
mouseY -= gui.getGuiTop();
}
gui.renderTooltip(matrixStack, list, mouseX, mouseY);
drawContext.drawTooltip(gui.getTextRenderer(), list, mouseX, mouseY);
//RenderSystem.disableLighting();
RenderSystem.setShaderColor(1, 1, 1, 1);
}
@ -789,15 +781,15 @@ public class GuiBuilder {
* @param y {@code int} Top left corner where to place slots bar
* @param count {@code int} Number of output slots
*/
public void drawOutputSlotBar(MatrixStack matrixStack, GuiBase<?> gui, int x, int y, int count) {
public void drawOutputSlotBar(DrawContext drawContext, GuiBase<?> gui, int x, int y, int count) {
RenderSystem.setShaderTexture(0, resourceLocation);
gui.drawTexture(matrixStack, x, y, 150, 122, 3, 26);
drawContext.drawTexture(resourceLocation, x, y, 150, 122, 3, 26);
x += 3;
for (int i = 1; i <= count; i++) {
gui.drawTexture(matrixStack, x, y, 150 + 3, 122, 20, 26);
drawContext.drawTexture(resourceLocation, x, y, 150 + 3, 122, 20, 26);
x += 20;
}
gui.drawTexture(matrixStack, x, y, 150 + 23, 122, 3, 26);
drawContext.drawTexture(resourceLocation, x, y, 150 + 23, 122, 3, 26);
}
protected int percentage(long MaxValue, long CurrentValue) {