Skip to content

Commit

Permalink
fix: update hammer, fix guis
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaTheDinkus committed Aug 26, 2023
1 parent 6f086b2 commit 68f1118
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ protected void onMouseClicked(MouseClickedEvent event) {
}

@Override
public void draw(MatrixStack matrices, VertexConsumerProvider provider, float tickDelta) {
public void draw(DrawContext context, float tickDelta) {
var matrices = context.getMatrices();
var provider = context.getVertexConsumers();

if (body == null) return;

var client = InstanceUtil.getClient();
Expand Down Expand Up @@ -158,8 +161,8 @@ public void draw(MatrixStack matrices, VertexConsumerProvider provider, float ti
// Translate to the Title's position.
matrices.translate(informationWidth / 2.0F - TextUtil.getWidth(bodyName) / 2.0F, 0.0F, 0.0F);

var context = new DrawContext(MinecraftClient.getInstance(), MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers());
context.drawText(textRenderer, bodyName, 0, 0, Color.WHITE.toRgb(), false);
var newContext = new DrawContext(MinecraftClient.getInstance(), MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers());
newContext.drawText(textRenderer, bodyName, 0, 0, Color.WHITE.toRgb(), false);

matrices.pop(); // 2

Expand All @@ -174,7 +177,7 @@ public void draw(MatrixStack matrices, VertexConsumerProvider provider, float ti
matrices.translate(0.0F, 4.0F + TextUtil.getHeight(bodyName), 0.0F);

for (var line : bodyDescriptionLines) {
context.drawText(textRenderer, line, 0, 0, Color.GRAY.toRgb(), false);
newContext.drawText(textRenderer, line, 0, 0, Color.GRAY.toRgb(), false);

// Offset the line's size.
// TODO: Remove the ""!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import dev.vini2003.hammer.core.api.client.util.InstanceUtil;
import dev.vini2003.hammer.core.api.client.util.PositionUtil;
import dev.vini2003.hammer.gui.api.common.widget.Widget;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
Expand Down Expand Up @@ -86,7 +87,10 @@ public List<OrderedText> getTooltip() {
}

@Override
public void draw(MatrixStack matrices, VertexConsumerProvider provider, float tickDelta) {
public void draw(DrawContext context, float tickDelta) {
var matrices = context.getMatrices();
var provider = context.getVertexConsumers();

// Get the offset caused by mouse dragging.
var offsetX = BodySelectorHandledScreen.getOffsetX();
var offsetY = BodySelectorHandledScreen.getOffsetY();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorage;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
import net.fabricmc.fabric.api.transfer.v1.storage.StorageUtil;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
Expand Down Expand Up @@ -84,7 +85,10 @@ protected void onMouseClicked(MouseClickedEvent event) {
}

@Override
public void draw(MatrixStack matrices, VertexConsumerProvider provider, float tickDelta) {
public void draw(DrawContext context, float tickDelta) {
var matrices = context.getMatrices();
var provider = context.getVertexConsumers();

backgroundTexture.get().draw(matrices, provider, getX(), getY(), getWidth(), getHeight());

if (fluidVariant.get().isBlank()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ protected void onMouseClicked(MouseClickedEvent event) {
}

@Override
public void draw(MatrixStack matrices, VertexConsumerProvider provider, float tickDelta) {
public void draw(DrawContext context, float tickDelta) {
var matrices = context.getMatrices();
var provider = context.getVertexConsumers();

if (blockEntity == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import dev.vini2003.hammer.gui.api.common.event.MouseClickedEvent;
import dev.vini2003.hammer.gui.api.common.widget.Widget;
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
Expand Down Expand Up @@ -131,7 +132,9 @@ protected void onMouseClicked(MouseClickedEvent event) {
}

@Override
public void draw(MatrixStack matrices, VertexConsumerProvider provider, float tickDelta) {
public void draw(DrawContext context, float tickDelta) {
var matrices = context.getMatrices();
var provider = context.getVertexConsumers();
getTexture().draw(matrices, provider, getX(), getY(), getWidth(), getHeight());
}

Expand Down

0 comments on commit 68f1118

Please sign in to comment.