From d1db68e192ec0945be58ec1d31c243f023ff0150 Mon Sep 17 00:00:00 2001 From: 90 Date: Sun, 1 Oct 2023 11:15:16 +0300 Subject: [PATCH] Add tooltip icon for stored radioactive cell chemical --- .../appmek/item/MEGARadioactiveCell.java | 28 +++++++++++++++++++ .../appmek/item/RadioactiveCellInventory.java | 8 ++++++ 2 files changed, 36 insertions(+) diff --git a/forge/src/main/java/gripe/_90/megacells/integration/appmek/item/MEGARadioactiveCell.java b/forge/src/main/java/gripe/_90/megacells/integration/appmek/item/MEGARadioactiveCell.java index b7c94f6d..812f1d82 100644 --- a/forge/src/main/java/gripe/_90/megacells/integration/appmek/item/MEGARadioactiveCell.java +++ b/forge/src/main/java/gripe/_90/megacells/integration/appmek/item/MEGARadioactiveCell.java @@ -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; @@ -74,6 +80,28 @@ public void appendHoverText( } } + @NotNull + @Override + public Optional getTooltipImage(@NotNull ItemStack is) { + var inv = HANDLER.getCellInventory(is, null); + + if (inv == null) { + return Optional.empty(); + } + + var content = new ArrayList(); + + 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() {} diff --git a/forge/src/main/java/gripe/_90/megacells/integration/appmek/item/RadioactiveCellInventory.java b/forge/src/main/java/gripe/_90/megacells/integration/appmek/item/RadioactiveCellInventory.java index 88e51b71..69dbb7d7 100644 --- a/forge/src/main/java/gripe/_90/megacells/integration/appmek/item/RadioactiveCellInventory.java +++ b/forge/src/main/java/gripe/_90/megacells/integration/appmek/item/RadioactiveCellInventory.java @@ -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()) {