Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Jade to show Steam usage #2309

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class SteamParallelMultiblockMachine extends WorkableMultiblockMachine im
public int maxParallels = ConfigHolder.INSTANCE.machines.steamMultiParallelAmount;

// if in millibuckets, this is 0.5, Meaning 2mb of steam -> 1 EU
private static final double CONVERSION_RATE = 0.5D;
public static final double CONVERSION_RATE = 0.5D;

public SteamParallelMultiblockMachine(IMachineBlockEntity holder, Object... args) {
this(holder, ConfigHolder.INSTANCE.machines.steamMultiParallelAmount, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.material.Fluid;
import net.minecraftforge.fluids.FluidType;
import net.minecraftforge.registries.ForgeRegistries;
Expand Down Expand Up @@ -41,7 +42,7 @@ public void appendTooltip(ITooltip iTooltip, BlockAccessor blockAccessor, IPlugi
CompoundTag itemTag = itemTags.getCompound(i);
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(itemTag.getString("item")));
long count = itemTag.getLong("count");
if (item != null) {
if (item != null && !item.equals(Items.AIR)) {
iTooltip.add(item.getDescription()
.copy()
.withStyle(ChatFormatting.GOLD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.material.Fluid;
import net.minecraftforge.fluids.FluidType;
import net.minecraftforge.registries.ForgeRegistries;
Expand Down Expand Up @@ -45,7 +46,7 @@ public void appendTooltip(ITooltip iTooltip, BlockAccessor blockAccessor, IPlugi
CompoundTag itemTag = itemTags.getCompound(i);
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(itemTag.getString("item")));
long count = itemTag.getLong("count");
if (item != null) {
if (item != null && !item.equals(Items.AIR)) {
iTooltip.add(item.getDescription()
.copy()
.withStyle(ChatFormatting.GOLD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtceu.api.GTValues;
import com.gregtechceu.gtceu.api.blockentity.MetaMachineBlockEntity;
import com.gregtechceu.gtceu.api.capability.GTCapabilityHelper;
import com.gregtechceu.gtceu.api.machine.steam.SimpleSteamMachine;
import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic;
import com.gregtechceu.gtceu.api.recipe.RecipeHelper;
import com.gregtechceu.gtceu.common.machine.multiblock.steam.SteamParallelMultiblockMachine;
import com.gregtechceu.gtceu.utils.FormattingUtil;
import com.gregtechceu.gtceu.utils.GTUtil;

Expand Down Expand Up @@ -36,9 +39,6 @@ protected RecipeLogic getCapability(Level level, BlockPos pos, @Nullable Directi

@Override
protected void write(CompoundTag data, RecipeLogic capability) {
// TODO PrimitiveRecipeLogic
// if(capability instanceof PrimitiveRecipeLogic) return;

data.putBoolean("Working", capability.isWorking());
var recipeInfo = new CompoundTag();
var recipe = capability.getLastRecipe();
Expand All @@ -57,10 +57,6 @@ protected void write(CompoundTag data, RecipeLogic capability) {
if (!recipeInfo.isEmpty()) {
data.put("Recipe", recipeInfo);
}

var machine = capability.machine;
// TODO if(machine instanceof SteamMachine), display steam usage in mB/t
// (could probably also be done clientside actually, since we have access to the BlockEntity there)
}

@Override
Expand All @@ -71,20 +67,34 @@ protected void addTooltip(CompoundTag capData, ITooltip tooltip, Player player,
if (!recipeInfo.isEmpty()) {
var EUt = recipeInfo.getLong("EUt");
var isInput = recipeInfo.getBoolean("isInput");
boolean isSteam = false;

long absEUt = Math.abs(EUt);

// Default behavior, if this TE is not a steam machine (or somehow not instanceof
// IGregTechTileEntity...)
var tier = GTUtil.getTierByVoltage(absEUt);
Component text = Component.literal(FormattingUtil.formatNumbers(absEUt)).withStyle(ChatFormatting.RED)
.append(Component.literal(" EU/t").withStyle(ChatFormatting.RESET)
.append(Component.literal(" (").withStyle(ChatFormatting.GREEN)
.append(Component.literal(GTValues.VNF[tier])
.withStyle(style -> style.withColor(GTValues.VC[tier])))
.append(Component.literal(")").withStyle(ChatFormatting.GREEN))));
if (blockEntity instanceof MetaMachineBlockEntity mbe) {
var machine = mbe.getMetaMachine();
if (machine instanceof SimpleSteamMachine) {
isSteam = true;
} else if (machine instanceof SteamParallelMultiblockMachine) {
EUt = (long) (EUt * SteamParallelMultiblockMachine.CONVERSION_RATE);
isSteam = true;
}
}

if (EUt > 0) {
Component text;

if (isSteam) {
text = Component.literal(FormattingUtil.formatNumbers(EUt)).withStyle(ChatFormatting.GREEN)
.append(Component.literal(" mB/t").withStyle(ChatFormatting.RESET));
} else {
var tier = GTUtil.getTierByVoltage(EUt);
text = Component.literal(FormattingUtil.formatNumbers(EUt)).withStyle(ChatFormatting.RED)
.append(Component.literal(" EU/t").withStyle(ChatFormatting.RESET)
.append(Component.literal(" (").withStyle(ChatFormatting.GREEN)
.append(Component.literal(GTValues.VNF[tier])
.withStyle(style -> style.withColor(GTValues.VC[tier])))
.append(Component.literal(")").withStyle(ChatFormatting.GREEN))));
}

if (isInput) {
tooltip.add(Component.translatable("gtceu.top.energy_consumption").append(" ").append(text));
} else {
Expand Down