Search in sources :

Example 1 with ShulkerBoxBlock

use of net.minecraft.block.ShulkerBoxBlock in project MasaGadget by plusls.

the class MixinRenderUtils method modifyInv.

@ModifyVariable(method = "renderInventoryOverlay", at = @At(value = "INVOKE", target = "Lfi/dy/masa/malilib/util/GuiUtils;getScaledWindowWidth()I", ordinal = 0, remap = false), ordinal = 0)
private static Inventory modifyInv(Inventory inv) {
    Inventory ret = inv;
    Entity traceEntity = TraceUtil.getTraceEntity();
    if (Configs.Tweakeroo.INVENTORY_PREVIEW_SUPPORT_SHULKER_BOX_ITEM_ENTITY.getBooleanValue() && ret == null && traceEntity instanceof ItemEntity) {
        ItemStack itemStack = ((ItemEntity) traceEntity).getStack();
        Item item = itemStack.getItem();
        NbtCompound invNbt = itemStack.getSubNbt("BlockEntityTag");
        DefaultedList<ItemStack> stacks = DefaultedList.ofSize(27, ItemStack.EMPTY);
        if (item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof ShulkerBoxBlock) {
            ret = new SimpleInventory(27);
            if (invNbt != null) {
                Inventories.readNbt(invNbt, stacks);
            }
            for (int i = 0; i < 27; ++i) {
                ret.setStack(i, stacks.get(i));
            }
        }
    }
    return ret;
}
Also used : Entity(net.minecraft.entity.Entity) ItemEntity(net.minecraft.entity.ItemEntity) Item(net.minecraft.item.Item) BlockItem(net.minecraft.item.BlockItem) ItemEntity(net.minecraft.entity.ItemEntity) NbtCompound(net.minecraft.nbt.NbtCompound) ShulkerBoxBlock(net.minecraft.block.ShulkerBoxBlock) ItemStack(net.minecraft.item.ItemStack) BlockItem(net.minecraft.item.BlockItem) Inventory(net.minecraft.inventory.Inventory) SimpleInventory(net.minecraft.inventory.SimpleInventory) SimpleInventory(net.minecraft.inventory.SimpleInventory) ModifyVariable(org.spongepowered.asm.mixin.injection.ModifyVariable)

Example 2 with ShulkerBoxBlock

use of net.minecraft.block.ShulkerBoxBlock 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)

Example 3 with ShulkerBoxBlock

use of net.minecraft.block.ShulkerBoxBlock in project KiwiClient by TangyKiwi.

the class Tooltips method getShulkerColor.

public Color getShulkerColor(ItemStack shulkerItem) {
    if (!(shulkerItem.getItem() instanceof BlockItem))
        return Color.WHITE;
    Block block = ((BlockItem) shulkerItem.getItem()).getBlock();
    if (block == Blocks.ENDER_CHEST)
        return new Color(0, 50, 50);
    if (!(block instanceof ShulkerBoxBlock))
        return Color.WHITE;
    ShulkerBoxBlock shulkerBlock = (ShulkerBoxBlock) ShulkerBoxBlock.getBlockFromItem(shulkerItem.getItem());
    DyeColor dye = shulkerBlock.getColor();
    if (dye == null)
        return Color.WHITE;
    final float[] colors = dye.getColorComponents();
    return new Color(colors[0], colors[1], colors[2], 1f);
}
Also used : DyeColor(net.minecraft.util.DyeColor) ShulkerBoxBlock(net.minecraft.block.ShulkerBoxBlock) Block(net.minecraft.block.Block) ShulkerBoxBlock(net.minecraft.block.ShulkerBoxBlock) DyeColor(net.minecraft.util.DyeColor)

Example 4 with ShulkerBoxBlock

use of net.minecraft.block.ShulkerBoxBlock in project KiwiClient by TangyKiwi.

the class Dupe method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.executes(context -> {
        HitResult hr = MinecraftClient.getInstance().crosshairTarget;
        if (hr instanceof BlockHitResult) {
            BlockHitResult bhr = (BlockHitResult) hr;
            BlockState bs = MinecraftClient.getInstance().world.getBlockState(bhr.getBlockPos());
            if (bs.getBlock() instanceof ShulkerBoxBlock) {
                MinecraftClient.getInstance().interactionManager.interactBlock(MinecraftClient.getInstance().player, MinecraftClient.getInstance().world, Hand.MAIN_HAND, bhr);
                preDoDupe = true;
            }
        } else {
            Utils.mc.inGameHud.getChatHud().addMessage(new LiteralText("Please look at a shulker box"));
        }
        return SINGLE_SUCCESS;
    });
}
Also used : BlockHitResult(net.minecraft.util.hit.BlockHitResult) HitResult(net.minecraft.util.hit.HitResult) BlockState(net.minecraft.block.BlockState) ShulkerBoxBlock(net.minecraft.block.ShulkerBoxBlock) BlockHitResult(net.minecraft.util.hit.BlockHitResult) LiteralText(net.minecraft.text.LiteralText)

Example 5 with ShulkerBoxBlock

use of net.minecraft.block.ShulkerBoxBlock in project Client by MatHax.

the class AutoMountBypassDupe method onTick.

@EventHandler
private void onTick(TickEvent.Post event) {
    if (GLFW.glfwGetKey(mc.getWindow().getHandle(), GLFW.GLFW_KEY_ESCAPE) == GLFW.GLFW_PRESS) {
        toggle();
        mc.player.closeHandledScreen();
        return;
    }
    if (timer <= 0)
        timer = delay.get();
    else {
        timer--;
        return;
    }
    int slots = getInvSize(mc.player.getVehicle());
    for (Entity e : mc.world.getEntities()) {
        if (e.distanceTo(mc.player) < 5 && e instanceof AbstractDonkeyEntity && ((AbstractDonkeyEntity) e).isTame())
            entity = (AbstractDonkeyEntity) e;
    }
    if (entity == null)
        return;
    if (sneak) {
        mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY));
        mc.player.setSneaking(false);
        sneak = false;
        return;
    }
    if (slots == -1) {
        if (entity.hasChest() || mc.player.getMainHandStack().getItem() == Items.CHEST) {
            mc.player.networkHandler.sendPacket(PlayerInteractEntityC2SPacket.interact(entity, mc.player.isSneaking(), Hand.MAIN_HAND));
        } else {
            int slot = InvUtils.findInHotbar(Items.CHEST).slot();
            if (!InvUtils.swap(slot, true)) {
                error("Cannot find chest in your hotbar, disabling...");
                toggle();
            }
        }
    } else if (slots == 0) {
        if (isDupeTime()) {
            if (!slotsToThrow.isEmpty()) {
                if (faceDown.get())
                    Rotations.rotate(mc.player.getYaw(), 90, 99, this::drop);
                else
                    drop();
            } else {
                for (int i = 2; i < getDupeSize() + 1; i++) {
                    slotsToThrow.add(i);
                }
            }
        } else {
            mc.player.closeHandledScreen();
            mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.PRESS_SHIFT_KEY));
            mc.player.setSneaking(true);
            sneak = true;
        }
    } else if (!(mc.currentScreen instanceof HorseScreen))
        mc.player.openRidingInventory();
    else if (slots > 0) {
        if (slotsToMove.isEmpty()) {
            boolean empty = true;
            for (int i = 2; i <= slots; i++) {
                if (!(mc.player.currentScreenHandler.getStacks().get(i).isEmpty())) {
                    empty = false;
                    break;
                }
            }
            if (empty) {
                for (int i = slots + 2; i < mc.player.currentScreenHandler.getStacks().size(); i++) {
                    if (!(mc.player.currentScreenHandler.getStacks().get(i).isEmpty())) {
                        if (mc.player.currentScreenHandler.getSlot(i).getStack().getItem() == Items.CHEST)
                            continue;
                        if (!(mc.player.currentScreenHandler.getSlot(i).getStack().getItem() instanceof BlockItem && ((BlockItem) mc.player.currentScreenHandler.getSlot(i).getStack().getItem()).getBlock() instanceof ShulkerBoxBlock) && shulkersOnly.get())
                            continue;
                        slotsToMove.add(i);
                        if (slotsToMove.size() >= slots)
                            break;
                    }
                }
            } else {
                noCancel = true;
                mc.player.networkHandler.sendPacket(PlayerInteractEntityC2SPacket.interact(entity, mc.player.isSneaking(), Hand.MAIN_HAND));
                noCancel = false;
                return;
            }
        }
        if (!slotsToMove.isEmpty()) {
            for (int i : slotsToMove) {
                InvUtils.quickMove().from(i).to(0);
            }
            slotsToMove.clear();
        }
    }
}
Also used : AbstractDonkeyEntity(net.minecraft.entity.passive.AbstractDonkeyEntity) Entity(net.minecraft.entity.Entity) LlamaEntity(net.minecraft.entity.passive.LlamaEntity) HorseScreen(net.minecraft.client.gui.screen.ingame.HorseScreen) ClientCommandC2SPacket(net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket) ShulkerBoxBlock(net.minecraft.block.ShulkerBoxBlock) AbstractDonkeyEntity(net.minecraft.entity.passive.AbstractDonkeyEntity) BlockItem(net.minecraft.item.BlockItem) EventHandler(mathax.client.eventbus.EventHandler)

Aggregations

ShulkerBoxBlock (net.minecraft.block.ShulkerBoxBlock)7 BlockItem (net.minecraft.item.BlockItem)4 Block (net.minecraft.block.Block)3 Entity (net.minecraft.entity.Entity)2 ItemStack (net.minecraft.item.ItemStack)2 EventHandler (mathax.client.eventbus.EventHandler)1 AbstractFurnaceBlock (net.minecraft.block.AbstractFurnaceBlock)1 BarrelBlock (net.minecraft.block.BarrelBlock)1 BlockState (net.minecraft.block.BlockState)1 ChestBlock (net.minecraft.block.ChestBlock)1 DispenserBlock (net.minecraft.block.DispenserBlock)1 HopperBlock (net.minecraft.block.HopperBlock)1 HorseScreen (net.minecraft.client.gui.screen.ingame.HorseScreen)1 MatrixStack (net.minecraft.client.util.math.MatrixStack)1 ItemEntity (net.minecraft.entity.ItemEntity)1 AbstractDonkeyEntity (net.minecraft.entity.passive.AbstractDonkeyEntity)1 LlamaEntity (net.minecraft.entity.passive.LlamaEntity)1 Inventory (net.minecraft.inventory.Inventory)1 SimpleInventory (net.minecraft.inventory.SimpleInventory)1 Item (net.minecraft.item.Item)1