Skip to content
Merged
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
46 changes: 46 additions & 0 deletions src/main/java/com/glodblock/github/common/item/FCBaseItemCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,30 @@

import static appeng.util.item.AEFluidStackType.FLUID_STACK_TYPE;

import java.util.List;

import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;

import org.jetbrains.annotations.NotNull;

import com.glodblock.github.common.storage.CellType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.google.common.base.Optional;

import appeng.api.AEApi;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEStackType;
import appeng.core.localization.GuiText;
import appeng.items.AEBaseCell;
import appeng.me.storage.FluidCellInventoryHandler;
import appeng.util.IterationCounter;
import appeng.util.ReadableNumberConverter;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public abstract class FCBaseItemCell extends AEBaseCell {

Expand All @@ -31,6 +45,38 @@ public FCBaseItemCell(long bytes, int perType, int totalType, double drain) {
return FLUID_STACK_TYPE;
}

@Override
@SideOnly(Side.CLIENT)
public void addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List<String> lines,
final boolean displayMoreInfo) {
super.addCheckedInformation(stack, player, lines, displayMoreInfo);

final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
.getCellInventory(stack, null, getStackType());
if (!(inventory instanceof FluidCellInventoryHandler handler) || handler.getCellInv().getTotalItemTypes() != 1
|| handler.getCellInv().getStoredItemTypes() == 0)
return;

Comment thread
Worive marked this conversation as resolved.
final IAEFluidStack content = handler
.getAvailableItems(FLUID_STACK_TYPE.createPrimitiveList(), IterationCounter.fetchNewId())
.getFirstItem();
Comment thread
Worive marked this conversation as resolved.
final String oldLine = GuiText.Contains.getLocal() + ": " + content.getDisplayName();
final int oldLineIndex = lines.lastIndexOf(oldLine);
if (oldLineIndex >= 0) {
Comment thread
Worive marked this conversation as resolved.
if (!GuiScreen.isCtrlKeyDown()) {
lines.set(oldLineIndex, EnumChatFormatting.GRAY + GuiText.HoldCtrlForContents.getLocal());
return;
}
final String unit = FLUID_STACK_TYPE.getDisplayUnit();
lines.set(
oldLineIndex,
" " + content.getDisplayName()
+ " x"
+ ReadableNumberConverter.INSTANCE.toWideReadableForm(content.getStackSize())
+ (unit.isEmpty() ? "" : " " + unit));
}
}

public FCBaseItemCell(Optional subName) {
super(subName);
}
Expand Down