Search in sources :

Example 1 with NbtCompound

use of net.minecraft.nbt.NbtCompound in project Skyblocker by LifeIsAParadox.

the class DungeonMap method render.

public static void render(MatrixStack matrices) {
    MinecraftClient client = MinecraftClient.getInstance();
    if (client.player == null && client.world == null)
        return;
    ItemStack item = client.player.getInventory().main.get(8);
    NbtCompound tag = item.getNbt();
    if (tag != null && tag.contains("map")) {
        String tag2 = tag.asString();
        tag2 = StringUtils.substringBetween(tag2, "map:", "}");
        int mapid = Integer.parseInt(tag2);
        VertexConsumerProvider.Immediate vertices = client.getBufferBuilders().getEffectVertexConsumers();
        MapRenderer map = client.gameRenderer.getMapRenderer();
        MapState state = FilledMapItem.getMapState(mapid, client.world);
        if (state == null)
            return;
        matrices.push();
        matrices.translate(2, 2, 0);
        matrices.scale(1, 1, 0);
        map.draw(matrices, vertices, mapid, state, false, 15728880);
        vertices.draw();
        matrices.pop();
    }
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) MapRenderer(net.minecraft.client.render.MapRenderer) MinecraftClient(net.minecraft.client.MinecraftClient) MapState(net.minecraft.item.map.MapState) ItemStack(net.minecraft.item.ItemStack) VertexConsumerProvider(net.minecraft.client.render.VertexConsumerProvider)

Example 2 with NbtCompound

use of net.minecraft.nbt.NbtCompound 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 3 with NbtCompound

use of net.minecraft.nbt.NbtCompound in project MasaGadget by plusls.

the class BborProtocol method parse.

public static void parse(PacketByteBuf buf) {
    Identifier dimensionId = buf.readIdentifier();
    ModInfo.LOGGER.debug("dimensionId = {}", dimensionId.toString());
    NbtCompound tag = BoundingBoxDeserializer.deserializeStructure(buf);
    if (!structuresCache.containsKey(dimensionId)) {
        structuresCache.put(dimensionId, new NbtList());
    }
    if (tag != null) {
        structuresCache.get(dimensionId).add(tag);
        if (enable && Configs.Minihud.COMPACT_BBOR_PROTOCOL.getBooleanValue() && MinecraftClient.getInstance().world != null) {
            BborProtocol.lock.lock();
            try {
                DataStorage.getInstance().addOrUpdateStructuresFromServer(structuresCache.get(dimensionId), 0x7fffffff - 0x1000, false);
            } catch (Exception e) {
                e.printStackTrace();
            }
            BborProtocol.lock.unlock();
        }
    }
}
Also used : Identifier(net.minecraft.util.Identifier) NbtCompound(net.minecraft.nbt.NbtCompound) NbtList(net.minecraft.nbt.NbtList)

Example 4 with NbtCompound

use of net.minecraft.nbt.NbtCompound in project MasaGadget by plusls.

the class BoundingBoxDeserializer method deserializeStructure.

public static NbtCompound deserializeStructure(PacketByteBuf buf) {
    NbtCompound tag = new NbtCompound();
    deserializeStructureBox(buf, tag, true);
    if (!tag.contains("BB")) {
        return null;
    }
    NbtList childrenTagList = new NbtList();
    while (buf.isReadable()) {
        NbtCompound childrenTag = new NbtCompound();
        deserializeStructureBox(buf, childrenTag, false);
        childrenTagList.add(childrenTag);
    }
    tag.put("Children", childrenTagList);
    return tag;
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) NbtList(net.minecraft.nbt.NbtList)

Example 5 with NbtCompound

use of net.minecraft.nbt.NbtCompound in project MCDoom by AzureDoom.

the class DoomEquipmentUtils method onSendEquipmentBreakStatusImpl.

public static void onSendEquipmentBreakStatusImpl(ServerPlayerEntity serverPlayer, ItemStack breakingStack, boolean forceSet) {
    for (Map.Entry<Item, Item> itemMap : DoomItems.getItemMap().entrySet()) {
        if (isVanillaItemStackBreaking(breakingStack, itemMap.getValue())) {
            // Directly copy over breaking Item's NBT, removing specific fields
            ItemStack ruinedStack = new ItemStack(itemMap.getKey());
            NbtCompound breakingNBT = breakingStack.getOrCreateNbt();
            if (breakingNBT.contains("Damage"))
                breakingNBT.remove("Damage");
            if (breakingNBT.contains("RepairCost"))
                breakingNBT.remove("RepairCost");
            // Set enchantment NBT data
            NbtCompound enchantTag = getNbtForEnchantments(breakingStack, ruinedStack);
            if (enchantTag != null)
                breakingNBT.copyFrom(enchantTag);
            if (breakingNBT.contains("Enchantments"))
                breakingNBT.remove("Enchantments");
            ruinedStack.setNbt(breakingNBT);
            serverPlayer.getInventory().offerOrDrop(ruinedStack);
        }
    }
}
Also used : Item(net.minecraft.item.Item) NbtCompound(net.minecraft.nbt.NbtCompound) ItemStack(net.minecraft.item.ItemStack) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

NbtCompound (net.minecraft.nbt.NbtCompound)282 NbtList (net.minecraft.nbt.NbtList)79 ItemStack (net.minecraft.item.ItemStack)58 LiteralText (net.minecraft.text.LiteralText)24 NbtElement (net.minecraft.nbt.NbtElement)23 Identifier (net.minecraft.util.Identifier)23 IOException (java.io.IOException)21 BlockPos (net.minecraft.util.math.BlockPos)19 Inject (org.spongepowered.asm.mixin.injection.Inject)18 NbtString (net.minecraft.nbt.NbtString)16 File (java.io.File)13 List (java.util.List)9 Text (net.minecraft.text.Text)9 Items (net.minecraft.item.Items)8 TranslatableText (net.minecraft.text.TranslatableText)8 BlockState (net.minecraft.block.BlockState)6 Item (net.minecraft.item.Item)6 NbtIo (net.minecraft.nbt.NbtIo)6 PacketByteBuf (net.minecraft.network.PacketByteBuf)6 Vec3d (net.minecraft.util.math.Vec3d)6