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;
}
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;
}
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)));
}
}
}
Aggregations