Skip to content

Commit

Permalink
feat: JEI improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
bruberu committed Jul 21, 2024
1 parent 644941a commit cda4923
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,6 @@ public void addInformation(@NotNull ItemStack itemStack, @Nullable World worldIn
Material material = getMaterial(itemStack);
if (prefix == null || material == null) return;
addMaterialTooltip(lines, itemStack);
if (material.isRadioactive()) {
lines.add(I18n.format("metaitem.info.radioactive"));
}
}

/**
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/gregtech/api/nuclear/fission/IFissionFuelStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,20 @@ public interface IFissionFuelStats {
* @return The average time for a neutron to be emitted during a fission event. Do not make this accurate.
*/
double getNeutronGenerationTime();

/**
* Helper method for the tooltip
* @return An integer corresponding to the stability of the fuel. 0 corresponds to stable, 1 to somewhat stable, 2 to dangerous, 3 to very dangerous
*/
default int getNeutronGenerationTimeCategory() {
if (this.getNeutronGenerationTime() > 2) {
return 0;
} else if (this.getNeutronGenerationTime() > 1.25) {
return 1;
} else if (this.getNeutronGenerationTime() > 0.9) {
return 2;
} else {
return 3;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1045,28 +1045,24 @@ public static void register() {
.build();

Plutonium238 = new Material.Builder(137, gregtechId("plutonium_238"))
.ingot(3)
.liquid(new FluidBuilder().temperature(913))
.color(0xF03232).iconSet(METALLIC)
.element(Elements.Pu238)
.build();

Plutonium240 = new Material.Builder(138, gregtechId("plutonium_240"))
.ingot(3)
.liquid(new FluidBuilder().temperature(913))
.color(0xF03232).iconSet(METALLIC)
.element(Elements.Pu240)
.build();

Plutonium242 = new Material.Builder(139, gregtechId("plutonium_242"))
.ingot(3)
.liquid(new FluidBuilder().temperature(913))
.color(0xF03232).iconSet(METALLIC)
.element(Elements.Pu242)
.build();

Plutonium244 = new Material.Builder(140, gregtechId("plutonium_244"))
.ingot(3)
.liquid(new FluidBuilder().temperature(913))
.color(0xF03232).iconSet(METALLIC)
.element(Elements.Pu244)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,4 @@ public double getNeutronGenerationTime() {
public void setNeutronGenerationTime(double neutronGenerationTime) {
this.neutronGenerationTime = neutronGenerationTime;
}

/*
* Helper method for the tooltip; 0 corresponds to stable, 1 to somewhat stable, 2 to dangerous, 3 to very dangerous
*/
public int getNeutronGenerationTimeCategory() {
if (this.neutronGenerationTime > 2) {
return 0;
} else if (this.neutronGenerationTime > 1.25) {
return 1;
} else if (this.neutronGenerationTime > 0.9) {
return 2;
} else {
return 3;
}
}
}
16 changes: 1 addition & 15 deletions src/main/java/gregtech/api/unification/ore/OrePrefix.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,21 +329,7 @@ public class OrePrefix {
// Nuclear stuff, introduced by Zalgo and Bruberu
public static final OrePrefix fuelRod = new OrePrefix("fuelRod", -1, null, MaterialIconType.fuelRod, 0,
material -> material.hasProperty(PropertyKey.FISSION_FUEL),
mat -> {
FissionFuelProperty prop = mat.getProperty(PropertyKey.FISSION_FUEL);
return Arrays.asList(I18n.format("metaitem.nuclear.tooltip.radioactive"),
I18n.format("metaitem.nuclear.tooltip.duration",
prop.getDuration()),
I18n.format("metaitem.nuclear.tooltip.temperature",
prop.getMaxTemperature()),
I18n.format("metaitem.nuclear.tooltip.cross_sections",
prop.getFastNeutronFissionCrossSection(),
prop.getSlowNeutronFissionCrossSection()),
I18n.format(
"metaitem.nuclear.tooltip.neutron_time." +
prop.getNeutronGenerationTimeCategory(),
prop.getNeutronGenerationTime()));
});
mat -> Collections.singletonList(I18n.format("metaitem.nuclear.tooltip.radioactive")));
public static final OrePrefix fuelRodDepleted = new OrePrefix("fuelRodDepleted", -1, null,
MaterialIconType.fuelRodDepleted, 0, material -> material.hasProperty(PropertyKey.FISSION_FUEL),
mat -> Collections.singletonList(I18n.format("metaitem.nuclear.tooltip.radioactive")));
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/gregtech/api/util/FluidTooltipUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,6 @@ public static Supplier<List<String>> createFluidTooltip(@Nullable Material mater
ICoolantStats coolant = CoolantRegistry.getCoolant(fluid);
if (coolant != null) {
tooltip.add(I18n.format("gregtech.coolant.general"));
tooltip.add(I18n.format("gregtech.coolant.boiling_point",
coolant.getBoilingPoint(),
coolant.getHotCoolant().getTemperature()));
tooltip.add(I18n.format("gregtech.coolant.heat_capacity",
coolant.getSpecificHeatCapacity()));
tooltip.add(I18n.format("gregtech.coolant.cooling_factor",
coolant.getCoolingFactor()));
tooltip.add(I18n.format("gregtech.coolant.moderation_factor",
coolant.getModeratorFactor()));
if (coolant.accumulatesHydrogen()) {
tooltip.add(I18n.format("gregtech.coolant.accumulates_hydrogen"));
}
}
return tooltip;
};
Expand Down
55 changes: 49 additions & 6 deletions src/main/java/gregtech/integration/jei/basic/CoolantCategory.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package gregtech.integration.jei.basic;

import gregtech.api.gui.GuiTextures;
import gregtech.api.nuclear.fission.CoolantRegistry;
import gregtech.api.nuclear.fission.ICoolantStats;
import gregtech.common.metatileentities.MetaTileEntities;

import mezz.jei.api.gui.IGuiFluidStackGroup;
Expand All @@ -13,14 +15,23 @@
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeWrapper;

import net.minecraft.client.resources.I18n;

import org.jetbrains.annotations.Nullable;

public class CoolantCategory extends BasicRecipeCategory<CoolantInfo, CoolantInfo> {
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, 50), guiHelper);
super("coolant", "fission.coolant.name", guiHelper.createBlankDrawable(176, 90), guiHelper);

this.icon = guiHelper.createDrawableIngredient(MetaTileEntities.FISSION_REACTOR.getStackForm());
this.slot = guiHelper.drawableBuilder(GuiTextures.SLOT.imageLocation, 0, 0, 18, 18).setTextureSize(18, 18).build();
Expand All @@ -37,17 +48,49 @@ public IDrawable getIcon() {
public void setRecipe(IRecipeLayout recipeLayout, CoolantInfo recipeWrapper, IIngredients ingredients) {
IGuiFluidStackGroup fluidStackGroup = recipeLayout.getFluidStacks();

fluidStackGroup.init(0, true, 55, 17);
fluidStackGroup.init(0, true, 55, 9);
fluidStackGroup.set(0, recipeWrapper.coolant);
fluidStackGroup.init(1, true, 105, 17);
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, 16);
slot.draw(minecraft, 104, 16);
arrow.draw(minecraft, 77, 14);
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import gregtech.api.GTValues;
import gregtech.api.gui.GuiTextures;

import gregtech.api.nuclear.fission.FissionFuelRegistry;
import gregtech.api.nuclear.fission.IFissionFuelStats;
import gregtech.common.metatileentities.MetaTileEntities;

import mezz.jei.api.IGuiHelper;
Expand All @@ -12,24 +14,33 @@
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;

import mezz.jei.api.recipe.IRecipeCategory;

import mezz.jei.api.recipe.IRecipeWrapper;

import net.minecraft.client.Minecraft;

import net.minecraft.client.resources.I18n;

import org.jetbrains.annotations.Nullable;

public class FissionFuelCategory extends BasicRecipeCategory<FissionFuelInfo, FissionFuelInfo> {

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, 50), guiHelper);
super("fission_fuel", "fission.fuel.name", guiHelper.createBlankDrawable(176, 90), guiHelper);

this.icon = guiHelper.createDrawableIngredient(MetaTileEntities.FISSION_REACTOR.getStackForm());
this.slot = guiHelper.drawableBuilder(GuiTextures.SLOT.imageLocation, 0, 0, 18, 18).setTextureSize(18, 18).build();
this.arrow = guiHelper.drawableBuilder(GuiTextures.PROGRESS_BAR_ARROW.imageLocation, 0, 20, 20, 20).setTextureSize(20, 40).build();
this.slot = guiHelper.drawableBuilder(GuiTextures.SLOT.imageLocation, 0, 0, 18, 18).setTextureSize(18, 18)
.build();
this.arrow = guiHelper.drawableBuilder(GuiTextures.PROGRESS_BAR_ARROW.imageLocation, 0, 20, 20, 20)
.setTextureSize(20, 40).build();
}

@Nullable
Expand All @@ -42,17 +53,41 @@ public IDrawable getIcon() {
public void setRecipe(IRecipeLayout recipeLayout, FissionFuelInfo recipeWrapper, IIngredients ingredients) {
IGuiItemStackGroup itemStackGroup = recipeLayout.getItemStacks();

itemStackGroup.init(0, true, 54, 16);
itemStackGroup.init(0, true, 54, 8);
itemStackGroup.set(0, recipeWrapper.rod);
itemStackGroup.init(1, true, 104, 16);
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
public void drawExtras(Minecraft minecraft) {
slot.draw(minecraft, 54, 16);
slot.draw(minecraft, 104, 16);
arrow.draw(minecraft, 77, 14);
slot.draw(minecraft, 54, 8);
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
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ private static void registerRecyclingRecipes() {
MACERATOR_RECIPES.recipeBuilder()
.input(stone, GraniteRed)
.output(dust, GraniteRed)
.chancedOutput(dust, Uranium, 10, 5)
.chancedOutput(dust, Uraninite, 10, 5)
.buildAndRegister();

MACERATOR_RECIPES.recipeBuilder()
Expand Down
29 changes: 16 additions & 13 deletions src/main/resources/assets/gregtech/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,15 @@ metaitem.electric.discharge_mode.tooltip=Use while sneaking to toggle discharge
metaitem.dust.tooltip.purify=Throw into Cauldron to get clean Dust
metaitem.crushed.tooltip.purify=Throw into Cauldron to get Purified Ore
metaitem.nuclear.tooltip.radioactive=§cEmits dangerous radiation
metaitem.nuclear.tooltip.duration=Depletes in §f%d§7 MJ of heat
metaitem.nuclear.tooltip.temperature=Melts at §f%d§7 degrees K
metaitem.nuclear.tooltip.cross_sections=Fissions with probability §f%d§7 barns with fast neutrons and §f%d§7 barns with slow neutrons
metaitem.nuclear.tooltip.neutron_time.0=Releases neutrons §f%d§7 seconds after fissioning on average (§aStable§7)
metaitem.nuclear.tooltip.neutron_time.1=Releases neutrons §f%d§7 seconds after fissioning on average (§eSomewhat stable§7)
metaitem.nuclear.tooltip.neutron_time.2=Releases neutrons §f%d§7 seconds after fissioning on average (§cDangerous§7)
metaitem.nuclear.tooltip.neutron_time.3=Releases neutrons §f%d§7 seconds after fissioning on average (§4Very dangerous§7)
metaitem.nuclear.tooltip.duration=Total heat energy: %d MJ
metaitem.nuclear.tooltip.temperature=Melting point: %d K
metaitem.nuclear.tooltip.cross_section_fast=Fast neutron prob: %d barn
metaitem.nuclear.tooltip.cross_section_slow=Slow neutron prob: %d barn
metaitem.nuclear.tooltip.neutron_time.0=Avg. neutron: %ds (§aSafe§r)
metaitem.nuclear.tooltip.neutron_time.1=Avg. neutron: %ds (§eSafer§r)
metaitem.nuclear.tooltip.neutron_time.2=Avg. neutron: %ds (§cUnsafe§r)
metaitem.nuclear.tooltip.neutron_time.3=Avg. neutron: %ds (§4Very unsafe§r)

metaitem.int_circuit.configuration=§aConfigured Value: §f%d§7
metaitem.credit.copper.name=Copper Credit
metaitem.credit.copper.tooltip=0.125 Credits
Expand Down Expand Up @@ -1895,7 +1897,8 @@ gregtech.material.hafnium_dioxide=Hafnium Dioxide
gregtech.material.hafnium_tetrachloride=Hafnium Tetrachloride
gregtech.material.boron_trioxide=Boron Trioxide
gregtech.material.boron_carbide=Boron Carbide

gregtech.material.heavy_water=Heavy Water
gregtech.material.high_pressure_heavy_water=High Pressure Heavy Water

# Organic Chemistry Materials
gregtech.material.silicone_rubber=Silicone Rubber
Expand Down Expand Up @@ -5537,11 +5540,11 @@ gregtech.fluid.state_liquid=§aState: Liquid
gregtech.fluid.state_plasma=§aState: Plasma
gregtech.fluid.type_acid.tooltip=§6Acidic! Handle with care!
gregtech.coolant.general=§9Can be used as a coolant§7
gregtech.coolant.boiling_point=§5Boils at §f%d§5 K at STP, and exits at §f%d§5 K from a reactor
gregtech.coolant.heat_capacity=§5Has a specific heat capacity of §f%d§5 J/kg*K
gregtech.coolant.cooling_factor=§5Has a heat transfer coefficient of §f%d§5 W/(m^2K)
gregtech.coolant.moderation_factor=§5Has a moderation cross section of §f%d§5 barns
gregtech.coolant.accumulates_hydrogen=§6Accumulates explosive hydrogen gas at 1500K
gregtech.coolant.exit_temp=Hot coolant temperature: %d K
gregtech.coolant.heat_capacity=Heat capacity: %d J/kgK
gregtech.coolant.cooling_factor=Heat transfer: %d W/(m^2K)
gregtech.coolant.moderation_factor=Moderation cross section: %d barn
gregtech.coolant.accumulates_hydrogen=§6Accumulates hydrogen at 1500K

gregtech.gui.fuel_amount=Fuel Amount:
gregtech.gui.fluid_amount=Fluid Amount:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "gregtech:items/metaitems/cladding.fuel"
}
}

0 comments on commit cda4923

Please sign in to comment.