Skip to content

Commit

Permalink
improve/add lang for TOP and tooltip
Browse files Browse the repository at this point in the history
handle type pos map better
  • Loading branch information
ghzdude committed Oct 9, 2024
1 parent a02be46 commit d88c2a3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/main/java/gregtech/api/capability/IQuantumController.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public interface IQuantumController extends ICapabilityProvider {

long getEnergyUsage();

int getCount(IQuantumStorage.Type type);

long getTypeEnergy(IQuantumStorage<?> storage);

void updateHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public class MetaTileEntityQuantumStorageController extends MetaTileEntity imple

public MetaTileEntityQuantumStorageController(ResourceLocation metaTileEntityId) {
super(metaTileEntityId);
for (var type : VALUES) {
typePosMap.put(type, new HashSet<>());
}
}

@Override
Expand Down Expand Up @@ -259,10 +262,7 @@ public void rebuildNetwork() {
storageInstances = new HashMap<>();
storagePositions = new HashSet<>();

typePosMap.clear();
for (var type : VALUES) {
typePosMap.put(type, new HashSet<>());
}
typePosMap.values().forEach(Set::clear);

Queue<BlockPos> searchQueue = new ArrayDeque<>();
Set<BlockPos> checked = new HashSet<>();
Expand Down Expand Up @@ -363,6 +363,7 @@ private void calculateEnergyUsage() {
for (var pos : storagePositions) {
var storage = getStorage(pos);
if (storage != null) {
typePosMap.get(storage.getType()).add(pos);
energyConsumption += getTypeEnergy(storage);
if (storage.getType() == ENERGY) {
energyContainers.add((IEnergyContainer) storage.getTypeValue());
Expand All @@ -387,6 +388,11 @@ public long getTypeEnergy(IQuantumStorage<?> storage) {
};
}

@Override
public int getCount(IQuantumStorage.Type type) {
return typePosMap.get(type).size();
}

public final long getEnergyUsage() {
return energyConsumption;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer play
if (blockState.getBlock().hasTileEntity(blockState) &&
world.getTileEntity(data.getPos()) instanceof IGregTechTileEntity gtte) {
if (gtte.getMetaTileEntity() instanceof IQuantumController controller) {
configureEnergyUsage(controller.getEnergyUsage() / 10, probeInfo);
if (controller.getCount(IQuantumStorage.Type.ENERGY) == 0) {
probeInfo.text("{*gregtech.top.quantum_controller.no_hatches*}");
} else if (!controller.isPowered()) {
probeInfo.text("{*gregtech.top.quantum_controller.no_power*}");
} else {
long usage = controller.getEnergyUsage();
configureEnergyUsage(usage / 10, probeInfo);
}
} else if (gtte.getMetaTileEntity() instanceof IQuantumStorage<?>storage &&
(storage.getType() == IQuantumStorage.Type.ITEM ||
storage.getType() == IQuantumStorage.Type.FLUID)) {
Expand All @@ -53,6 +60,7 @@ public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer play
}

public void configureEnergyUsage(long EUs, IProbeInfo probeInfo) {
if (EUs == 0) return;
String text = TextFormatting.RED.toString() + EUs + TextStyleClass.INFO + " EU/t" + TextFormatting.GREEN +
" (" + GTValues.VNF[GTUtility.getTierByVoltage(EUs)] + TextFormatting.GREEN + ")";
probeInfo.text(TextStyleClass.INFO + "{*gregtech.top.energy_consumption*} " + text);
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/assets/gregtech/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ gregtech.top.quantum_status.label=Status:
gregtech.top.quantum_status.powered=§bOnline
gregtech.top.quantum_status.connected=§cNo Power
gregtech.top.quantum_status.disconnected=Not connected
gregtech.top.quantum_controller.no_hatches=§cNo Energy Hatches Connected
gregtech.top.quantum_controller.no_power=§cNo Power

gregtech.top.working_disabled=Working Disabled

Expand Down Expand Up @@ -4389,7 +4391,7 @@ gregtech.machine.quantum_tank.uhv.name=Quantum Tank V

#Quantum Storage Controller
gregtech.machine.quantum_storage_controller.name=Quantum Storage Controller
gregtech.machine.quantum_storage_controller.tooltip=Heart of the Quantum Storage Network
gregtech.machine.quantum_storage_controller.tooltip=Heart of the Quantum Storage Network/nConnect Energy Hatches to power the Quantum Storage Network
gregtech.machine.quantum_storage_proxy.name=Quantum Storage Proxy
gregtech.machine.quantum_storage_proxy.tooltip=Proxies the Quantum Storage Network's inventory
gregtech.machine.quantum_storage_extender.name=Quantum Storage Extender
Expand Down

0 comments on commit d88c2a3

Please sign in to comment.