Search in sources :

Example 1 with TileEntityDrawers

use of com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers in project TUMAT by canitzp.

the class StorageDrawers method renderTileEntity.

@Override
public TooltipComponent renderTileEntity(WorldClient world, EntityPlayerSP player, TileEntity tileEntity, EnumFacing side, TooltipComponent component, boolean shouldCalculate) {
    if (player.isSneaking() && tileEntity instanceof TileEntityDrawers) {
        if (tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) {
            IItemHandler handler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
            if (handler != null) {
                List<String> lines = new ArrayList<>();
                for (int i = 1; i < handler.getSlots(); i++) {
                    ItemStack stack = handler.getStackInSlot(i);
                    if (!stack.isEmpty()) {
                        lines.add(L10n.getStorageDrawersContent(i, InfoUtil.getItemName(stack)));
                    } else {
                        lines.add(L10n.getStorageDrawersContent(i, TextFormatting.WHITE + L10n.EMPTY));
                    }
                }
                component.add(new DescriptionComponent(lines), TooltipComponent.Priority.HIGH);
            }
        } else {
            component.add(new TextComponent(L10n.SNEAKFORMORE).setScale(0.8F).setFormat(TextFormatting.GRAY), TooltipComponent.Priority.HIGH);
        }
    }
    return component;
}
Also used : TextComponent(de.canitzp.tumat.api.components.TextComponent) IItemHandler(net.minecraftforge.items.IItemHandler) TileEntityDrawers(com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) DescriptionComponent(de.canitzp.tumat.api.components.DescriptionComponent)

Aggregations

TileEntityDrawers (com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers)1 DescriptionComponent (de.canitzp.tumat.api.components.DescriptionComponent)1 TextComponent (de.canitzp.tumat.api.components.TextComponent)1 ArrayList (java.util.ArrayList)1 ItemStack (net.minecraft.item.ItemStack)1 IItemHandler (net.minecraftforge.items.IItemHandler)1