Skip to content

Commit

Permalink
Add tooltip icon for stored radioactive cell chemical
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Oct 1, 2023
1 parent 227dab6 commit d1db68e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package gripe._90.megacells.integration.appmek.item;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import appeng.api.stacks.GenericStack;
import appeng.core.AEConfig;
import appeng.items.storage.StorageCellTooltipComponent;
import net.minecraft.world.inventory.tooltip.TooltipComponent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -74,6 +80,28 @@ public void appendHoverText(
}
}

@NotNull
@Override
public Optional<TooltipComponent> getTooltipImage(@NotNull ItemStack is) {
var inv = HANDLER.getCellInventory(is, null);

if (inv == null) {
return Optional.empty();
}

var content = new ArrayList<GenericStack>();

if (AEConfig.instance().isTooltipShowCellContent()) {
if (inv.getStoredChemical() != null) {
content.add(new GenericStack(inv.getStoredChemical(), inv.getChemAmount()));
} else if (inv.getFilterItem() != null) {
content.add(new GenericStack(inv.getFilterItem(), 0));
}
}

return Optional.of(new StorageCellTooltipComponent(List.of(), content, false, true));
}

public static class Handler implements ICellHandler {
private Handler() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ public CellState getStatus() {
return CellState.NOT_EMPTY;
}

public AEKey getStoredChemical() {
return storedChemical;
}

public long getChemAmount() {
return chemAmount;
}

public AEKey getFilterItem() {
var config = getConfigInventory().keySet().stream().toList();
if (config.isEmpty()) {
Expand Down

0 comments on commit d1db68e

Please sign in to comment.