Skip to content

Commit

Permalink
Fix #4585
Browse files Browse the repository at this point in the history
  • Loading branch information
Vazkii committed Jan 16, 2024
1 parent c04d623 commit 91585ce
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,7 @@ private void makeUUID() {
matrixId = UUID.randomUUID();
}

private void updateEnchantPower() {
ItemStack item = getItem(0);
influences.clear();
if(item.isEmpty())
return;

enchantability = Quark.ZETA.itemExtensions.get(item).getEnchantmentValueZeta(item);

public void updateEnchantPower() {
boolean allowWater = MatrixEnchantingModule.allowUnderwaterEnchanting;
boolean allowShort = MatrixEnchantingModule.allowShortBlockEnchanting;

Expand All @@ -263,6 +256,11 @@ private void updateEnchantPower() {
}

bookshelfPower = Math.min((int) power, MatrixEnchantingModule.maxBookshelves);

ItemStack item = getItem(0);
influences.clear();
if(!item.isEmpty())
enchantability = Quark.ZETA.itemExtensions.get(item).getEnchantmentValueZeta(item);
}

private boolean isAirGap(int j, int k, boolean allowWater, boolean allowShortBlock) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public void init() {
updateButtonStatus();

pieceList.refresh();
enchanter.updateEnchantPower();
}

@Override
Expand Down Expand Up @@ -103,17 +104,35 @@ protected void renderBg(@NotNull GuiGraphics guiGraphics, float partialTicks, in

pieceList.render(guiGraphics, mouseX, mouseY, partialTicks);

if(enchanter.matrix != null
boolean showCost = enchanter.matrix != null
&& enchanter.matrix.canGeneratePiece(enchanter.influences, enchanter.bookshelfPower, enchanter.enchantability)
&& !mc.player.getAbilities().instabuild) {
int x = i + 71;
int y = j + 56;
&& !mc.player.getAbilities().instabuild;

String text = ""+enchanter.bookshelfPower;
int x = i + 50;
int y = j + 55;

if(enchanter.bookshelfPower > 0) {
pose.pushPose();
guiGraphics.renderItem(new ItemStack(Items.BOOK), x, y);
pose.translate(0, 0, 1000);

x -= font.width(text) / 2;

drawBorderedText(guiGraphics, text, x + 3, y + 6, 0xc8ff8f);
pose.popPose();
}

if(showCost) {
int xpCost = enchanter.matrix.getNewPiecePrice();
int xpMin = enchanter.matrix.getMinXpLevel(enchanter.bookshelfPower);
boolean has = enchanter.matrix.validateXp(mc.player, enchanter.bookshelfPower);

x = i + 71;
y = j + 56;
text = String.valueOf(xpCost);

guiGraphics.blit(BACKGROUND, x, y, 0, imageHeight, 10, 10);
String text = String.valueOf(xpCost);

if(!has && mc.player.experienceLevel < xpMin) {
text = I18n.get("quark.gui.enchanting.min", xpMin);
Expand All @@ -122,24 +141,9 @@ protected void renderBg(@NotNull GuiGraphics guiGraphics, float partialTicks, in

x -= font.width(text) / 2;
drawBorderedText(guiGraphics, text, x + 2, y + 5, has ? 0xc8ff8f : 0xff8f8f);

text = ""+enchanter.bookshelfPower;
x = i + 50;
y = j + 55;

pose.pushPose();
guiGraphics.renderItem(new ItemStack(Items.BOOK), x, y);
pose.translate(0, 0, 1000);

x -= font.width(text) / 2;

drawBorderedText(guiGraphics, text, x + 3, y + 6, 0xc8ff8f);
pose.popPose();
}


}

private void drawBorderedText(GuiGraphics guiGraphics, String text, int x, int y, int color) {
guiGraphics.drawString(font, text, x - 1, y, 0, false);
guiGraphics.drawString(font, text, x + 1, y, 0, false);
Expand Down

0 comments on commit 91585ce

Please sign in to comment.