Skip to content

Commit

Permalink
Matrix enchanter shows enchanting power
Browse files Browse the repository at this point in the history
  • Loading branch information
Vazkii committed Jan 15, 2024
1 parent d46991b commit 8e6535c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;

public class MatrixEnchantingScreen extends AbstractContainerScreen<MatrixEnchantingMenu> {

Expand Down Expand Up @@ -84,6 +86,8 @@ public void containerTick() {
@Override
protected void renderBg(@NotNull GuiGraphics guiGraphics, float partialTicks, int mouseX, int mouseY) {
Minecraft mc = getMinecraft();
PoseStack pose = guiGraphics.pose();

RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);

Expand All @@ -102,27 +106,45 @@ protected void renderBg(@NotNull GuiGraphics guiGraphics, float partialTicks, in
if(enchanter.matrix != null
&& enchanter.matrix.canGeneratePiece(enchanter.influences, enchanter.bookshelfPower, enchanter.enchantability)
&& !mc.player.getAbilities().instabuild) {
int x = i + 74;
int y = j + 58;
int x = i + 71;
int y = j + 56;
int xpCost = enchanter.matrix.getNewPiecePrice();
int xpMin = enchanter.matrix.getMinXpLevel(enchanter.bookshelfPower);
boolean has = enchanter.matrix.validateXp(mc.player, enchanter.bookshelfPower);

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

if(!has && mc.player.experienceLevel < xpMin) {
guiGraphics.drawString(font, "!", x + 6, y + 3, 0xFF0000, true);
text = I18n.get("quark.gui.enchanting.min", xpMin);
}

x -= (font.width(text) - 5);
y += 3;
guiGraphics.drawString(font, text, x - 1, y, 0);
guiGraphics.drawString(font, text, x + 1, y, 0);
guiGraphics.drawString(font, text, x, y + 1, 0);
guiGraphics.drawString(font, text, x, y - 1, 0);
guiGraphics.drawString(font, text, x, y, has ? 0xc8ff8f : 0xff8f8f);
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);
guiGraphics.drawString(font, text, x, y + 1, 0, false);
guiGraphics.drawString(font, text, x, y - 1, 0, false);
guiGraphics.drawString(font, text, x, y, color, false);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/quark/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"quark.gui.button.back": "Back",
"quark.gui.button.shift_lock": "Shift Lock",

"quark.gui.enchanting.min": "Min: %d",
"quark.gui.enchanting.min": "%d+",
"quark.gui.enchanting.influence": "Candle Influence: +%d%%",
"quark.gui.enchanting.dampen": "Candle Influence: %d%%",
"quark.gui.enchanting.upgrade": "Upgrade: %d/%d",
Expand Down

0 comments on commit 8e6535c

Please sign in to comment.