Skip to content

Commit

Permalink
fix: JEI pages + GUI scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
bruberu committed Jul 27, 2024
1 parent a409d62 commit d75dbd6
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 64 deletions.
38 changes: 2 additions & 36 deletions src/main/java/gregtech/integration/jei/basic/CoolantCategory.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ public class CoolantCategory extends BasicRecipeCategory<CoolantInfo, CoolantInf
private final IDrawable icon;
protected final IDrawable slot;
private final IDrawable arrow;
private String temps;
private String heatCapacity;
private String heatTransfer;
private String moderation;
private String hydrogen;

public CoolantCategory(IGuiHelper guiHelper) {
super("coolant", "fission.coolant.name", guiHelper.createBlankDrawable(176, 90), guiHelper);
Expand All @@ -51,46 +46,17 @@ public void setRecipe(IRecipeLayout recipeLayout, CoolantInfo recipeWrapper, IIn
fluidStackGroup.set(0, recipeWrapper.coolant);
fluidStackGroup.init(1, true, 105, 9);
fluidStackGroup.set(1, recipeWrapper.hotCoolant);

ICoolantStats coolant = CoolantRegistry.getCoolant(recipeWrapper.coolant.getFluid());

temps = I18n.format("gregtech.coolant.exit_temp",
coolant.getHotCoolant().getTemperature());
heatCapacity = I18n.format("gregtech.coolant.heat_capacity",
coolant.getSpecificHeatCapacity());
heatTransfer = I18n.format(I18n.format("gregtech.coolant.cooling_factor",
coolant.getCoolingFactor()));
moderation = I18n.format("gregtech.coolant.moderation_factor",
coolant.getModeratorFactor());

if (coolant.accumulatesHydrogen()) {
hydrogen = I18n.format("gregtech.coolant.accumulates_hydrogen");
} else {
hydrogen = "";
}
}

@Override
public void drawExtras(Minecraft minecraft) {
slot.draw(minecraft, 54, 8);
slot.draw(minecraft, 104, 8);
arrow.draw(minecraft, 77, 6);

int start = 40;
int linesDrawn = 0;
minecraft.fontRenderer.drawString(temps, 0, FONT_HEIGHT * linesDrawn + start, 0x111111);
linesDrawn++;
minecraft.fontRenderer.drawString(heatCapacity, 0, FONT_HEIGHT * linesDrawn + start, 0x111111);
linesDrawn++;
minecraft.fontRenderer.drawString(heatTransfer, 0, FONT_HEIGHT * linesDrawn + start, 0x111111);
linesDrawn++;
minecraft.fontRenderer.drawString(moderation, 0, FONT_HEIGHT * linesDrawn + start, 0x111111);
linesDrawn++;
if (hydrogen.length() > 0) {
minecraft.fontRenderer.drawString(hydrogen, 0, FONT_HEIGHT * linesDrawn + start, 0x111111);
}
}



@Override
public IRecipeWrapper getRecipeWrapper(CoolantInfo recipe) {
return recipe;
Expand Down
45 changes: 45 additions & 0 deletions src/main/java/gregtech/integration/jei/basic/CoolantInfo.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package gregtech.integration.jei.basic;

import gregtech.api.nuclear.fission.CoolantRegistry;
import gregtech.api.nuclear.fission.ICoolantStats;

import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;

Expand All @@ -12,14 +17,54 @@ public class CoolantInfo implements IRecipeWrapper {
public FluidStack coolant;
public FluidStack hotCoolant;

private String temps;
private String heatCapacity;
private String heatTransfer;
private String moderation;
private String hydrogen;

public CoolantInfo(Fluid coolant, Fluid hotCoolant) {
this.coolant = new FluidStack(coolant, 1000);
this.hotCoolant = new FluidStack(hotCoolant, 1000);

ICoolantStats stats = CoolantRegistry.getCoolant(this.coolant.getFluid());

temps = I18n.format("gregtech.coolant.exit_temp",
stats.getHotCoolant().getTemperature());
heatCapacity = I18n.format("gregtech.coolant.heat_capacity",
stats.getSpecificHeatCapacity());
heatTransfer = I18n.format(I18n.format("gregtech.coolant.cooling_factor",
stats.getCoolingFactor()));
moderation = I18n.format("gregtech.coolant.moderation_factor",
stats.getModeratorFactor());
if (stats.accumulatesHydrogen()) {
hydrogen = I18n.format("gregtech.coolant.accumulates_hydrogen");
}
}

@Override
public void getIngredients(IIngredients ingredients) {
ingredients.setInput(VanillaTypes.FLUID, coolant);
ingredients.setOutput(VanillaTypes.FLUID, hotCoolant);
}

@Override
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
int fontHeight = Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT;

int start = 40;
int linesDrawn = 0;
minecraft.fontRenderer.drawString(temps, 0, fontHeight * linesDrawn + start, 0x111111);
linesDrawn++;
minecraft.fontRenderer.drawString(heatCapacity, 0, fontHeight * linesDrawn + start, 0x111111);
linesDrawn++;
minecraft.fontRenderer.drawString(heatTransfer, 0, fontHeight * linesDrawn + start, 0x111111);
linesDrawn++;
minecraft.fontRenderer.drawString(moderation, 0, fontHeight * linesDrawn + start, 0x111111);
linesDrawn++;

if (hydrogen != null) {
minecraft.fontRenderer.drawString(hydrogen, 0, fontHeight * linesDrawn + start, 0x111111);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ public class FissionFuelCategory extends BasicRecipeCategory<FissionFuelInfo, Fi
private final IDrawable icon;
protected final IDrawable slot;
private final IDrawable arrow;
private String duration;
private String maxTemp;
private String crossSectionFast;
private String crossSectionSlow;
private String neutronGenerationTime;

public FissionFuelCategory(IGuiHelper guiHelper) {
super("fission_fuel", "fission.fuel.name", guiHelper.createBlankDrawable(176, 90), guiHelper);
Expand All @@ -51,18 +46,6 @@ public void setRecipe(IRecipeLayout recipeLayout, FissionFuelInfo recipeWrapper,
itemStackGroup.set(0, recipeWrapper.rod);
itemStackGroup.init(1, true, 104, 8);
itemStackGroup.set(1, recipeWrapper.depletedRod);

IFissionFuelStats prop = FissionFuelRegistry.getFissionFuel(recipeWrapper.rod);

duration = I18n.format("metaitem.nuclear.tooltip.duration", prop.getDuration());
maxTemp = I18n.format("metaitem.nuclear.tooltip.temperature", prop.getMaxTemperature());
crossSectionFast = I18n.format("metaitem.nuclear.tooltip.cross_section_fast",
prop.getFastNeutronFissionCrossSection());
crossSectionSlow = I18n.format("metaitem.nuclear.tooltip.cross_section_slow",
prop.getSlowNeutronFissionCrossSection());
neutronGenerationTime = I18n.format(
"metaitem.nuclear.tooltip.neutron_time." + prop.getNeutronGenerationTimeCategory(),
prop.getNeutronGenerationTime());
}

@Override
Expand All @@ -71,17 +54,6 @@ public void drawExtras(Minecraft minecraft) {
slot.draw(minecraft, 104, 8);
arrow.draw(minecraft, 77, 6);

int start = 40;
int linesDrawn = 0;
minecraft.fontRenderer.drawString(duration, 0, FONT_HEIGHT * linesDrawn + start, 0x111111);
linesDrawn++;
minecraft.fontRenderer.drawString(maxTemp, 0, FONT_HEIGHT * linesDrawn + start, 0x111111);
linesDrawn++;
minecraft.fontRenderer.drawString(crossSectionFast, 0, FONT_HEIGHT * linesDrawn + start, 0x111111);
linesDrawn++;
minecraft.fontRenderer.drawString(crossSectionSlow, 0, FONT_HEIGHT * linesDrawn + start, 0x111111);
linesDrawn++;
minecraft.fontRenderer.drawString(neutronGenerationTime, 0, FONT_HEIGHT * linesDrawn + start, 0x111111);
}

@Override
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/gregtech/integration/jei/basic/FissionFuelInfo.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package gregtech.integration.jei.basic;

import gregtech.api.nuclear.fission.FissionFuelRegistry;
import gregtech.api.nuclear.fission.IFissionFuelStats;

import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;

import mezz.jei.api.ingredients.IIngredients;
Expand All @@ -11,14 +16,50 @@ public class FissionFuelInfo implements IRecipeWrapper {
public ItemStack rod;
public ItemStack depletedRod;

private String duration;
private String maxTemp;
private String crossSectionFast;
private String crossSectionSlow;
private String neutronGenerationTime;

public FissionFuelInfo(ItemStack rod, ItemStack depletedRod) {
this.rod = rod;
this.depletedRod = depletedRod;

IFissionFuelStats prop = FissionFuelRegistry.getFissionFuel(rod);

duration = I18n.format("metaitem.nuclear.tooltip.duration", prop.getDuration());
maxTemp = I18n.format("metaitem.nuclear.tooltip.temperature", prop.getMaxTemperature());
crossSectionFast = I18n.format("metaitem.nuclear.tooltip.cross_section_fast",
prop.getFastNeutronFissionCrossSection());
crossSectionSlow = I18n.format("metaitem.nuclear.tooltip.cross_section_slow",
prop.getSlowNeutronFissionCrossSection());
neutronGenerationTime = I18n.format(
"metaitem.nuclear.tooltip.neutron_time." + prop.getNeutronGenerationTimeCategory(),
prop.getNeutronGenerationTime());
}

@Override
public void getIngredients(IIngredients ingredients) {
ingredients.setInput(VanillaTypes.ITEM, rod);
ingredients.setOutput(VanillaTypes.ITEM, depletedRod);
}

@Override
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
int fontHeight = Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT;

int start = 40;
int linesDrawn = 0;
minecraft.fontRenderer.drawString(duration, 0, start, 0x111111);
linesDrawn++;
minecraft.fontRenderer.drawString(maxTemp, 0, fontHeight * linesDrawn + start, 0x111111);
linesDrawn++;
minecraft.fontRenderer.drawString(crossSectionFast, 0, fontHeight * linesDrawn + start, 0x111111);
linesDrawn++;
minecraft.fontRenderer.drawString(crossSectionSlow, 0, fontHeight * linesDrawn + start, 0x111111);
linesDrawn++;
minecraft.fontRenderer.drawString(neutronGenerationTime, 0, fontHeight * linesDrawn + start, 0x111111);

}
}

0 comments on commit d75dbd6

Please sign in to comment.