Skip to content

Commit

Permalink
fix: rocket workbench screen texture references
Browse files Browse the repository at this point in the history
shuffle textured Graphics parameters
shift rocket render with gui height
also fix encoding of rocket workbench item data

closes #373
  • Loading branch information
marcus8448 committed Dec 15, 2024
1 parent b1c6e02 commit 7d1077e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public class RocketWorkbenchScreen extends AbstractContainerScreen<RocketWorkben
private static final int HEIGHT_EXT_U = BASE_UI_WIDTH;

private static final int ROCKET_PREVIEW_X = 209;
private static final int ROCKET_PREVIEW_Y = 106;
private static final int ROCKET_PREVIEW_Y = 100;

private static final int RECIPES_PER_PAGE = 35;

Expand Down Expand Up @@ -183,7 +183,7 @@ protected void renderBg(GuiGraphics guiGraphics, float delta, int mouseX, int mo
drawSelection(guiGraphics, mouseX, mouseY, delta);

try (Graphics graphics = Graphics.managed(guiGraphics, this.font)) {
try (Graphics.Texture texture = graphics.texture(Constant.ScreenTexture.ROCKET_WORKBENCH_SCREEN, 512, 512)) {
try (Graphics.Texture texture = graphics.texture(Constant.ScreenTexture.ROCKET_WORKBENCH_SCREEN, 512, 256)) {
texture.blit(this.leftPos, this.topPos + this.menu.additionalHeight + CAP_HEIGHT, 0, 0, BASE_UI_WIDTH, BASE_UI_HEIGHT);

if (this.menu.additionalHeight > 0) {
Expand All @@ -200,7 +200,7 @@ protected void renderBg(GuiGraphics guiGraphics, float delta, int mouseX, int mo
}
}

renderEntityInInventory(guiGraphics, this.leftPos + ROCKET_PREVIEW_X, this.topPos + ROCKET_PREVIEW_Y, 15, SmithingScreen.ARMOR_STAND_ANGLE, null, this.entity);
renderEntityInInventory(guiGraphics, this.leftPos + ROCKET_PREVIEW_X, this.topPos + ROCKET_PREVIEW_Y + this.menu.additionalHeight, 15, SmithingScreen.ARMOR_STAND_ANGLE, null, this.entity);
}

@Override
Expand Down Expand Up @@ -285,7 +285,7 @@ private void drawSelection(GuiGraphics guiGraphics, int mouseX, int mouseY, floa

int size = this.recipes != null ? this.recipes.size() : 0;
try (Graphics graphics = Graphics.managed(guiGraphics, this.font)) {
try (Graphics.Texture texture = graphics.texture(Constant.ScreenTexture.ROCKET_WORKBENCH_SCREEN, 512, 512)) {
try (Graphics.Texture texture = graphics.texture(Constant.ScreenTexture.ROCKET_SELECTION, 256, 256)) {
texture.blit(0, 0, 0, 0, SELECTION_SCREEN_WIDTH, SELECTION_SCREEN_HEIGHT);

{
Expand Down Expand Up @@ -331,10 +331,12 @@ private void drawSelection(GuiGraphics guiGraphics, int mouseX, int mouseY, floa
int y = 8;
for (Tab tab : Tab.values()) {
if (tab == Tab.COLOR) {
continue;
// graphics.renderFakeItem(new ItemStack(Items.RED_DYE), -TAB_WIDTH + TAB_ICON_OFFSET, y);
continue;
} else {
guiGraphics.pose().translate(0, 0, 100);
RocketPartRendererRegistry.INSTANCE.getRenderer(tab.part).renderGUI(guiGraphics, -TAB_WIDTH + TAB_ICON_OFFSET, y, mouseX, mouseY, delta);
guiGraphics.pose().translate(0, 0, -100);
}
y += TAB_SPACING + TAB_HEIGHT;
}
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/dev/galacticraft/mod/client/util/Graphics.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,15 @@ private Texture(int texture, int textureWidth, int textureHeight) {
Graphics.this.renderers.add(this);
}

public void blit(int x, int y, int width, int height, int z, int u, int v) {
this.blit(x, y, width, height, z, u, v, width, height);
public void blit(int x, int y, int z, int u, int v, int width, int height) {
this.blit(x, y, z, width, height, u, v, width, height);
}

public void blit(int x, int y, int width, int height, int z, int u, int v, int uWidth, int vHeight) {
public void blit(int x, int y, int z, int width, int height, int u, int v, int uWidth, int vHeight) {
this.blitRaw(x, y, x + width, y + height, z, (float) u / this.textureWidth, (float) v / this.textureHeight, (float) (u + uWidth) / this.textureWidth, (float) (v + vHeight) / this.textureHeight);
}

public void blit(float x, float y, float width, float height, float z, float u, float v, float uWidth, float vHeight) {
public void blit(float x, float y, float z, float width, float height, float u, float v, float uWidth, float vHeight) {
this.blitRaw(x, y, x + width, y + height, z, u / this.textureWidth, v / this.textureHeight, (u + uWidth) / this.textureWidth, (v + vHeight) / this.textureHeight);
}

Expand All @@ -337,20 +337,20 @@ public void blitRaw(float x1, float y1, float x2, float y2, float z, float u1, f
.addVertex(matrix, x2, y1, z).setUv(u2, v1);
}

public void blit(int x, int y, int width, int height, int u, int v) {
this.blit(x, y, width, height, 0, u, v, width, height);
public void blit(int x, int y, int u, int v, int width, int height) {
this.blit(x, y, 0, width, height, u, v, width, height);
}

public void blit(int x, int y, int width, int height, int u, int v, int uWidth, int vHeight) {
this.blit(x, y, width, height, 0, u, v, uWidth, vHeight);
this.blit(x, y, 0, width, height, u, v, uWidth, vHeight);
}

public void blit(float x, float y, float width, float height, float u, float v) {
this.blit(x, y, width, height, 0.0f, u, v, width, height);
public void blit(float x, float y, float u, float v, float width, float height) {
this.blit(x, y, 0.0f, width, height, u, v, width, height);
}

public void blit(float x, float y, float width, float height, float u, float v, float uWidth, float vHeight) {
this.blit(x, y, width, height, 0.0f, u, v, uWidth, vHeight);
this.blit(x, y, 0.0f, width, height, u, v, uWidth, vHeight);
}

private void ensureOpen() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,7 @@ public CompoundTag toTag(HolderLookup.Provider provider) {
tag.putInt("TargetSize", this.targetSize);
ListTag list = new ListTag();
for (ItemStack stack : this.stacks) {
CompoundTag item = new CompoundTag();
stack.save(provider, item);
list.add(item);
list.add(stack.saveOptional(provider));
}
tag.put("Items", list);
return tag;
Expand Down

0 comments on commit 7d1077e

Please sign in to comment.