Skip to content

Commit

Permalink
feat: Multiline pentacle name rendering in JEI recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
klikli-dev committed Jun 1, 2023
1 parent 17d36f7 commit 8b923ab
Showing 1 changed file with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import net.minecraft.core.Vec3i;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.FormattedCharSequence;
import net.minecraft.world.item.ItemStack;

import java.util.List;
Expand Down Expand Up @@ -86,6 +87,10 @@ protected void drawStringCentered(PoseStack poseStack, Font font, Component text
font.draw(poseStack, text, (x - font.width(text) / 2.0f), y, 0);
}

protected void drawStringCentered(PoseStack poseStack, Font font, FormattedCharSequence text, int x, int y) {
font.draw(poseStack, text, (x - font.width(text) / 2.0f), y, 0);
}

@Override
public RecipeType<RitualRecipe> getRecipeType() {
return JeiRecipeTypes.RITUAL;
Expand Down Expand Up @@ -209,40 +214,46 @@ public void draw(RitualRecipe recipe, IRecipeSlotsView recipeSlotsView, PoseStac
this.arrow.draw(poseStack, this.ritualCenterX + this.recipeOutputOffsetX - 20, this.ritualCenterY);
RenderSystem.disableBlend();

int infotextY = 0;
int infoTextX = 94;
int lineHeight = Minecraft.getInstance().font.lineHeight;
var pentacle = ModonomiconAPI.get().getMultiblock(recipe.getPentacleId());
if (pentacle != null) {
this.drawStringCentered(poseStack, Minecraft.getInstance().font,
Component.translatable(Util.makeDescriptionId("multiblock", pentacle.getId())), 84, 0);
var pentacleName = Minecraft.getInstance().font.split( Component.translatable(Util.makeDescriptionId("multiblock", pentacle.getId())), 150);

for(var line : pentacleName){
this.drawStringCentered(poseStack, Minecraft.getInstance().font,
line , infoTextX, infotextY);
infotextY += lineHeight;
}
} else {
this.drawStringCentered(poseStack, Minecraft.getInstance().font,
Component.translatable("jei.occultism.error.pentacle_not_loaded"), 84, 0);
Component.translatable("jei.occultism.error.pentacle_not_loaded"), infoTextX, 0);
}

int infotextY = 0;
if (recipe.requiresSacrifice()) {
infotextY += 10;
this.drawStringCentered(poseStack, Minecraft.getInstance().font,
Component.translatable("jei.occultism.sacrifice", Component.translatable(recipe.getEntityToSacrificeDisplayName())), 84, infotextY);
Component.translatable("jei.occultism.sacrifice", Component.translatable(recipe.getEntityToSacrificeDisplayName())), infoTextX, infotextY);
infotextY += lineHeight;
}

if (recipe.requiresItemUse()) {
infotextY += 10;
this.drawStringCentered(poseStack, Minecraft.getInstance().font, Component.translatable("jei.occultism.item_to_use"), 84, infotextY);
this.drawStringCentered(poseStack, Minecraft.getInstance().font, Component.translatable("jei.occultism.item_to_use"), infoTextX, infotextY);
infotextY += lineHeight;
}

if (recipe.getEntityToSummon() != null) {
infotextY += 10;
this.drawStringCentered(poseStack, Minecraft.getInstance().font,
Component.translatable("jei.occultism.summon", Component.translatable(recipe.getEntityToSummon().getDescriptionId())),
84, infotextY);
infoTextX, infotextY);
infotextY += lineHeight;
}

if (recipe.getSpiritJobType() != null) {
infotextY += 10;
this.drawStringCentered(poseStack, Minecraft.getInstance().font,
Component.translatable("jei.occultism.job",
Component.translatable("job." + recipe.getSpiritJobType().toString().replace(":", "."))),
84, infotextY);
infoTextX, infotextY);
}
}
}

0 comments on commit 8b923ab

Please sign in to comment.