Search in sources :

Example 1 with DispenserBlock

use of net.minecraft.block.DispenserBlock in project BleachHack by BleachDrinker420.

the class Peek method drawShulkerToolTip.

public List<TooltipComponent> drawShulkerToolTip(MatrixStack matrices, Slot slot, int mouseX, int mouseY) {
    if (!(slot.getStack().getItem() instanceof BlockItem)) {
        return null;
    }
    Block block = ((BlockItem) slot.getStack().getItem()).getBlock();
    if (!(block instanceof ShulkerBoxBlock) && !(block instanceof ChestBlock) && !(block instanceof BarrelBlock) && !(block instanceof DispenserBlock) && !(block instanceof HopperBlock) && !(block instanceof AbstractFurnaceBlock)) {
        return null;
    }
    List<ItemStack> items = ItemContentUtils.getItemsInContainer(slot.getStack());
    if (items.stream().allMatch(ItemStack::isEmpty)) {
        return null;
    }
    int mode = getSetting(0).asToggle().getChild(0).asMode().getMode();
    int realY = mode == 2 ? mouseY + 24 : mouseY;
    int tooltipWidth = block instanceof AbstractFurnaceBlock ? 47 : block instanceof HopperBlock ? 82 : 150;
    int tooltipHeight = block instanceof AbstractFurnaceBlock || block instanceof HopperBlock || block instanceof DispenserBlock ? 13 : 47;
    renderTooltipBox(matrices, mouseX, realY - tooltipHeight - 7, tooltipWidth, tooltipHeight, true);
    int count = block instanceof HopperBlock || block instanceof DispenserBlock || block instanceof AbstractFurnaceBlock ? 18 : 0;
    for (ItemStack i : items) {
        if (count > 26) {
            break;
        }
        int x = mouseX + 11 + 17 * (count % 9);
        int y = realY - 67 + 17 * (count / 9);
        mc.getItemRenderer().zOffset = 400;
        mc.getItemRenderer().renderGuiItemIcon(i, x, y);
        mc.getItemRenderer().renderGuiItemOverlay(mc.textRenderer, i, x, y, null);
        mc.getItemRenderer().zOffset = 300;
        count++;
    }
    if (mode == 1) {
        return Arrays.asList(TooltipComponent.of(slot.getStack().getName().asOrderedText()));
    } else if (mode == 2) {
        return List.of();
    }
    return null;
}
Also used : DispenserBlock(net.minecraft.block.DispenserBlock) ShulkerBoxBlock(net.minecraft.block.ShulkerBoxBlock) HopperBlock(net.minecraft.block.HopperBlock) Block(net.minecraft.block.Block) BarrelBlock(net.minecraft.block.BarrelBlock) HopperBlock(net.minecraft.block.HopperBlock) ChestBlock(net.minecraft.block.ChestBlock) AbstractFurnaceBlock(net.minecraft.block.AbstractFurnaceBlock) ShulkerBoxBlock(net.minecraft.block.ShulkerBoxBlock) DispenserBlock(net.minecraft.block.DispenserBlock) BarrelBlock(net.minecraft.block.BarrelBlock) AbstractFurnaceBlock(net.minecraft.block.AbstractFurnaceBlock) ChestBlock(net.minecraft.block.ChestBlock) ItemStack(net.minecraft.item.ItemStack) BlockItem(net.minecraft.item.BlockItem)

Aggregations

AbstractFurnaceBlock (net.minecraft.block.AbstractFurnaceBlock)1 BarrelBlock (net.minecraft.block.BarrelBlock)1 Block (net.minecraft.block.Block)1 ChestBlock (net.minecraft.block.ChestBlock)1 DispenserBlock (net.minecraft.block.DispenserBlock)1 HopperBlock (net.minecraft.block.HopperBlock)1 ShulkerBoxBlock (net.minecraft.block.ShulkerBoxBlock)1 BlockItem (net.minecraft.item.BlockItem)1 ItemStack (net.minecraft.item.ItemStack)1