Search in sources :

Example 71 with CompoundNBT

use of net.minecraft.nbt.CompoundNBT in project Bookshelf by Darkhax-Minecraft.

the class SerializerVec3f method writeNBT.

@Override
public INBT writeNBT(Vector3f toWrite) {
    final CompoundNBT tag = new CompoundNBT();
    tag.putFloat("x", toWrite.x());
    tag.putFloat("y", toWrite.y());
    tag.putFloat("z", toWrite.z());
    return tag;
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT)

Example 72 with CompoundNBT

use of net.minecraft.nbt.CompoundNBT in project Bookshelf by Darkhax-Minecraft.

the class CommandLootChest method translate.

private int translate(CommandContext<CommandSource> context) throws CommandSyntaxException {
    final ItemStack item = new ItemStack(Items.CHEST);
    final CompoundNBT tag = item.getOrCreateTagElement("BlockEntityTag");
    tag.putString("LootTable", ArgumentTypeLootTable.getTableId(context, "table"));
    if (CommandUtils.hasArgument(context, "seed")) {
        tag.putLong("LootTableSeed", StringArgumentType.getString(context, "seed").hashCode());
    }
    for (final PlayerEntity player : EntityArgument.getPlayers(context, "targets")) {
        ItemHandlerHelper.giveItemToPlayer(player, item.copy());
    }
    return 0;
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) ItemStack(net.minecraft.item.ItemStack) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 73 with CompoundNBT

use of net.minecraft.nbt.CompoundNBT in project BluePower by Qmunity.

the class JEIPlugin method getMicroblockRecipes.

private static List<IRecipe<?>> getMicroblockRecipes() {
    List<IRecipe<?>> recipes = new ArrayList<>();
    for (Block block : ForgeRegistries.BLOCKS.getValues().stream().filter(b -> !b.hasTileEntity(b.defaultBlockState())).collect(Collectors.toList())) {
        VoxelShape shape = null;
        try {
            shape = block.defaultBlockState().getShape(null, null);
        } catch (NullPointerException ignored) {
        // Shulker Boxes try to query the Tile Entity
        }
        if (block.getRegistryName() != null && shape == VoxelShapes.block()) {
            ItemStack output = ItemStack.EMPTY;
            for (Block mb : BPBlocks.microblocks) {
                NonNullList<Ingredient> input = NonNullList.create();
                input.add(Ingredient.of(ItemTags.createOptional(new ResourceLocation("bluepower:saw"))));
                if (mb == BPBlocks.half_block) {
                    input.add(Ingredient.of(new ItemStack(block)));
                } else {
                    input.add(Ingredient.of(output));
                }
                CompoundNBT nbt = new CompoundNBT();
                nbt.putString("block", block.getRegistryName().toString());
                ItemStack stack = new ItemStack(mb);
                stack.setTag(nbt);
                stack.setHoverName(new TranslationTextComponent(block.getDescriptionId()).append(new StringTextComponent(" ")).append(new TranslationTextComponent(mb.getDescriptionId())));
                output = stack;
                recipes.add(new ShapelessRecipe(new ResourceLocation("bluepower:" + mb.getDescriptionId() + block.getDescriptionId()), "", output, input));
            }
        }
    }
    return recipes;
}
Also used : Refs(com.bluepowermod.reference.Refs) java.util(java.util) ContainerBlulectricAlloyFurnace(com.bluepowermod.container.ContainerBlulectricAlloyFurnace) GuiBlulectricAlloyFurnace(com.bluepowermod.client.gui.GuiBlulectricAlloyFurnace) Item(net.minecraft.item.Item) BPBlocks(com.bluepowermod.init.BPBlocks) CompoundNBT(net.minecraft.nbt.CompoundNBT) AlloyFurnaceRegistry(com.bluepowermod.recipe.AlloyFurnaceRegistry) net.minecraft.item.crafting(net.minecraft.item.crafting) IGuiHelper(mezz.jei.api.helpers.IGuiHelper) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ContainerBlulectricFurnace(com.bluepowermod.container.ContainerBlulectricFurnace) ItemStack(net.minecraft.item.ItemStack) IAlloyFurnaceRecipe(com.bluepowermod.api.recipe.IAlloyFurnaceRecipe) Block(net.minecraft.block.Block) Minecraft(net.minecraft.client.Minecraft) IRecipeCategory(mezz.jei.api.recipe.category.IRecipeCategory) mezz.jei.api(mezz.jei.api) VoxelShape(net.minecraft.util.math.shapes.VoxelShape) StringTextComponent(net.minecraft.util.text.StringTextComponent) NonNullList(net.minecraft.util.NonNullList) VanillaRecipeCategoryUid(mezz.jei.api.constants.VanillaRecipeCategoryUid) ContainerAlloyFurnace(com.bluepowermod.container.ContainerAlloyFurnace) ItemTags(net.minecraft.tags.ItemTags) ContainerProjectTable(com.bluepowermod.container.ContainerProjectTable) ItemStackUtils(com.bluepowermod.util.ItemStackUtils) mezz.jei.api.registration(mezz.jei.api.registration) Collectors(java.util.stream.Collectors) IJeiHelpers(mezz.jei.api.helpers.IJeiHelpers) GuiBlulectricFurnace(com.bluepowermod.client.gui.GuiBlulectricFurnace) ResourceLocation(net.minecraft.util.ResourceLocation) VoxelShapes(net.minecraft.util.math.shapes.VoxelShapes) BluePower(com.bluepowermod.BluePower) ForgeRegistries(net.minecraftforge.registries.ForgeRegistries) GuiAlloyFurnace(com.bluepowermod.client.gui.GuiAlloyFurnace) CompoundNBT(net.minecraft.nbt.CompoundNBT) VoxelShape(net.minecraft.util.math.shapes.VoxelShape) ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) StringTextComponent(net.minecraft.util.text.StringTextComponent) ItemStack(net.minecraft.item.ItemStack)

Example 74 with CompoundNBT

use of net.minecraft.nbt.CompoundNBT in project BluePower by Qmunity.

the class ContainerSeedBag method removed.

@Override
public void removed(PlayerEntity playerIn) {
    // Update items in the NBT
    ItemStack seedBag = playerIn.getItemInHand(activeHand);
    if (!seedBag.hasTag())
        seedBag.setTag(new CompoundNBT());
    if (seedBag.getTag() != null) {
        seedBag.getTag().put("inv", seedBagInvHandler.serializeNBT());
    }
    super.removed(playerIn);
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) ItemStack(net.minecraft.item.ItemStack)

Example 75 with CompoundNBT

use of net.minecraft.nbt.CompoundNBT in project BluePower by Qmunity.

the class InventoryItem method writeToNBT.

protected void writeToNBT() {
    if (item.getTag() == null) {
        item.setTag(new CompoundNBT());
    }
    ListNBT itemList = new ListNBT();
    for (int i = 0; i < getContainerSize(); i++) {
        if (!getItem(i).isEmpty()) {
            CompoundNBT slotEntry = new CompoundNBT();
            slotEntry.putByte("Slot", (byte) i);
            getItem(i).save(slotEntry);
            itemList.add(slotEntry);
        }
    }
    CompoundNBT inventory = new CompoundNBT();
    inventory.put("Items", itemList);
    item.getTag().put("Inventory", inventory);
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT)

Aggregations

CompoundNBT (net.minecraft.nbt.CompoundNBT)119 ItemStack (net.minecraft.item.ItemStack)33 ListNBT (net.minecraft.nbt.ListNBT)15 Nonnull (javax.annotation.Nonnull)12 PlayerEntity (net.minecraft.entity.player.PlayerEntity)10 ResourceLocation (net.minecraft.util.ResourceLocation)8 BlockPos (net.minecraft.util.math.BlockPos)8 TileEntity (net.minecraft.tileentity.TileEntity)7 StringTextComponent (net.minecraft.util.text.StringTextComponent)7 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)6 DimensionType (net.minecraft.world.dimension.DimensionType)6 TileBPMultipart (com.bluepowermod.tile.TileBPMultipart)5 Block (net.minecraft.block.Block)5 BlockState (net.minecraft.block.BlockState)5 ArrayList (java.util.ArrayList)4 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)4 SUpdateTileEntityPacket (net.minecraft.network.play.server.SUpdateTileEntityPacket)4 LongItemStack (com.cjm721.overloaded.storage.stacks.intint.LongItemStack)3 Nullable (javax.annotation.Nullable)3 IItemProvider (net.minecraft.util.IItemProvider)3