Search in sources :

Example 6 with ShulkerBoxBlock

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

the class InventoryOverlayRenderHandler method render.

public void render(MatrixStack matrixStack) {
    // fuck mojang
    // for 1.18
    // 不添加会渲染错误,不知道麻将哪里 pop 了没有 apply
    RenderSystem.applyModelViewMatrix();
    if (currentIdx == 0) {
        return;
    }
    if (selectedIdx != UN_SELECTED) {
        if (selectedIdx >= currentIdx) {
            selectedIdx %= currentIdx;
        } else if (selectedIdx < 0) {
            while (selectedIdx < 0) {
                selectedIdx += currentIdx;
            }
        } else {
            if (itemStack != null) {
                if (selectInventory) {
                    if (itemStack.getItem() instanceof BlockItem && ((BlockItem) itemStack.getItem()).getBlock() instanceof ShulkerBoxBlock) {
                        renderSelectedRect(matrixStack, renderX, renderY);
                        // 盒子预览
                        renderingSubInventory = true;
                        RenderUtils.renderShulkerBoxPreview(itemStack, GuiUtils.getScaledWindowWidth() / 2 - 96, GuiUtils.getScaledWindowHeight() / 2 + 30, true);
                        renderingSubInventory = false;
                        if (subSelectedIdx != UN_SELECTED) {
                            if (subCurrentIdx != 0) {
                                if (subSelectedIdx >= subCurrentIdx) {
                                    subSelectedIdx %= subCurrentIdx;
                                } else if (subSelectedIdx < 0) {
                                    while (subSelectedIdx < 0) {
                                        subSelectedIdx += subCurrentIdx;
                                    }
                                } else {
                                    if (subItemStack != null) {
                                        MatrixStack stack = RenderSystem.getModelViewStack();
                                        stack.push();
                                        stack.translate(0, 0, 400);
                                        RenderSystem.applyModelViewMatrix();
                                        ModInfo.LOGGER.debug("subRenderX: {} subRenderY: {}", subRenderX, subRenderY);
                                        renderSelectedRect(matrixStack, subRenderX, subRenderY);
                                        renderOrderedTooltip(matrixStack, subItemStack, subRenderX, subRenderY + 8);
                                        RenderSystem.getModelViewStack().pop();
                                        RenderSystem.applyModelViewMatrix();
                                    } else {
                                        ModInfo.LOGGER.debug("InventoryOverlayRenderHandler sub wtf???");
                                    }
                                }
                            }
                        }
                    } else {
                        // 激活预览但是被预览的物品不是盒子
                        switchSelectInventory();
                    }
                }
                if (!selectInventory) {
                    ModInfo.LOGGER.debug("renderX: {} renderY: {}", renderX, renderY);
                    renderSelectedRect(matrixStack, renderX, renderY);
                    renderOrderedTooltip(matrixStack, itemStack, renderX, renderY + 8);
                }
            } else {
                ModInfo.LOGGER.debug("InventoryOverlayRenderHandler wtf???");
            }
        }
    }
    currentIdx = 0;
    itemStack = null;
    renderX = -1;
    renderY = -1;
    subCurrentIdx = 0;
    subItemStack = null;
    subRenderX = -1;
    subRenderY = -1;
}
Also used : MatrixStack(net.minecraft.client.util.math.MatrixStack) ShulkerBoxBlock(net.minecraft.block.ShulkerBoxBlock) BlockItem(net.minecraft.item.BlockItem)

Example 7 with ShulkerBoxBlock

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

the class Auto32K method isShulkerBox.

private boolean isShulkerBox(ItemStack stack) {
    Item item = stack.getItem();
    if (!(item instanceof BlockItem))
        return false;
    Block block = ((BlockItem) item).getBlock();
    return block instanceof ShulkerBoxBlock;
}
Also used : ShulkerBoxBlock(net.minecraft.block.ShulkerBoxBlock) Block(net.minecraft.block.Block) ShulkerBoxBlock(net.minecraft.block.ShulkerBoxBlock)

Example 8 with ShulkerBoxBlock

use of net.minecraft.block.ShulkerBoxBlock in project carpet-fixes by fxmorin.

the class ItemEntity_shulkerDroppingMixin method onKilled.

@Inject(method = "damage", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/ItemEntity;remove()V"))
public void onKilled(CallbackInfoReturnable<Boolean> cir) {
    if (CarpetFixesSettings.shulkerBoxItemsDropContents && (this.getStack().getItem() instanceof BlockItem) && (((BlockItem) this.getStack().getItem()).getBlock() instanceof ShulkerBoxBlock)) {
        CompoundTag compoundTag = this.getStack().getTag();
        if (compoundTag != null) {
            ListTag listTag = compoundTag.getCompound("BlockEntityTag").getList("Items", 10);
            Stream<ItemStack> stream = listTag.stream().map(CompoundTag.class::cast).map(ItemStack::fromTag);
            World world = this.accessorGetWorld();
            if (!world.isClient)
                stream.forEach((itemStack) -> world.spawnEntity(new ItemEntity(world, this.invokerGetX(), this.invokerGetY(), this.invokerGetZ(), itemStack)));
        }
    }
}
Also used : World(net.minecraft.world.World) Inject(org.spongepowered.asm.mixin.injection.Inject) EntityAccessorMixin(carpetfixes.mixins.entityFixes.EntityAccessorMixin) CallbackInfoReturnable(org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable) ItemStack(net.minecraft.item.ItemStack) ItemEntity(net.minecraft.entity.ItemEntity) CompoundTag(net.minecraft.nbt.CompoundTag) Stream(java.util.stream.Stream) BlockItem(net.minecraft.item.BlockItem) Mixin(org.spongepowered.asm.mixin.Mixin) ShulkerBoxBlock(net.minecraft.block.ShulkerBoxBlock) Shadow(org.spongepowered.asm.mixin.Shadow) CarpetFixesSettings(carpetfixes.CarpetFixesSettings) ListTag(net.minecraft.nbt.ListTag) At(org.spongepowered.asm.mixin.injection.At) ItemEntity(net.minecraft.entity.ItemEntity) ShulkerBoxBlock(net.minecraft.block.ShulkerBoxBlock) ItemStack(net.minecraft.item.ItemStack) World(net.minecraft.world.World) BlockItem(net.minecraft.item.BlockItem) ListTag(net.minecraft.nbt.ListTag) CompoundTag(net.minecraft.nbt.CompoundTag) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

ShulkerBoxBlock (net.minecraft.block.ShulkerBoxBlock)8 BlockItem (net.minecraft.item.BlockItem)5 Block (net.minecraft.block.Block)3 ItemStack (net.minecraft.item.ItemStack)3 Entity (net.minecraft.entity.Entity)2 ItemEntity (net.minecraft.entity.ItemEntity)2 CarpetFixesSettings (carpetfixes.CarpetFixesSettings)1 EntityAccessorMixin (carpetfixes.mixins.entityFixes.EntityAccessorMixin)1 Stream (java.util.stream.Stream)1 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 AbstractDonkeyEntity (net.minecraft.entity.passive.AbstractDonkeyEntity)1 LlamaEntity (net.minecraft.entity.passive.LlamaEntity)1