Search in sources :

Example 71 with NbtCompound

use of net.minecraft.nbt.NbtCompound in project CodeUtilities by CodeUtilities.

the class TemplateUtils method applyRawTemplateNBT.

public static void applyRawTemplateNBT(ItemStack stack, LiteralText name, String author, String codeData, int version) {
    NbtCompound publicBukkitNBT = new NbtCompound();
    NbtCompound itemNBT = new NbtCompound();
    NbtCompound codeNBT = new NbtCompound();
    codeNBT.putString("name", name.toString());
    codeNBT.putString("author", author);
    codeNBT.putString("code", codeData);
    codeNBT.putInt("version", version);
    // Apply the template data to the item.
    publicBukkitNBT.putString("hypercube:codetemplatedata", codeNBT.toString());
    // Assign the bukkit container to the item. (Contains the template data)
    itemNBT.put("PublicBukkitValues", publicBukkitNBT);
    stack.setNbt(itemNBT);
// stack.setCustomName(name);
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound)

Example 72 with NbtCompound

use of net.minecraft.nbt.NbtCompound in project CodeUtilities by CodeUtilities.

the class TemplateUtils method fromItemStack.

public static JsonObject fromItemStack(ItemStack stack) {
    NbtCompound tag = stack.getNbt();
    NbtCompound publicBukkitNBT = tag.getCompound("PublicBukkitValues");
    String template = publicBukkitNBT.getString("hypercube:codetemplatedata");
    return JsonParser.parseString(template).getAsJsonObject();
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound)

Example 73 with NbtCompound

use of net.minecraft.nbt.NbtCompound in project GlobalSpawn by DaFuqs.

the class PlayerManagerMixin method loadPlayerData.

/**
 * Called everytime a player connects to the server,
 * and its profile is being loaded from disk
 * => Change the players position as early as possible
 */
@Inject(method = "loadPlayerData(Lnet/minecraft/server/network/ServerPlayerEntity;)Lnet/minecraft/nbt/NbtCompound;", at = @At("RETURN"), cancellable = true)
public void loadPlayerData(ServerPlayerEntity player, @NotNull CallbackInfoReturnable<NbtCompound> cir) {
    NbtCompound currentCompound = cir.getReturnValue();
    if (GlobalSpawnManager.isInitialSpawnPointActive() && GlobalSpawnMixinHandler.isNewPlayer(currentCompound)) {
        currentCompound = new NbtCompound();
        GlobalSpawnMixinHandler.modifySpawnRegistryPositionAndDimensionForNewPlayer(currentCompound);
        player.readNbt(currentCompound);
        cir.setReturnValue(currentCompound);
    } else if (GlobalSpawnManager.isGlobalRespawnPointActive() && GlobalSpawnCommon.GLOBAL_SPAWN_CONFIG.alwaysSpawnAtGlobalSpawnOnJoin) {
        currentCompound = GlobalSpawnMixinHandler.modifySpawnRegistryPositionAndDimensionForExistingPlayer(currentCompound);
        player.readNbt(currentCompound);
        cir.setReturnValue(currentCompound);
    }
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 74 with NbtCompound

use of net.minecraft.nbt.NbtCompound in project Sprout by ThatGravyBoat.

the class BounceBugBottleItem method getTextureId.

public static float getTextureId(ItemStack stack) {
    NbtCompound nbt = stack.getNbt();
    if (!stack.hasNbt() || nbt == null)
        return 0f;
    NbtCompound bug = nbt.getCompound("bug");
    return bug == null ? 0 : BounceBugVariant.getVariant(bug.getString("bugType")).ordinal();
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound)

Example 75 with NbtCompound

use of net.minecraft.nbt.NbtCompound in project como-client by gingerchicken.

the class TrollagePotion method getStack.

@Override
public ItemStack getStack() {
    ItemStack stack = new ItemStack(itemType);
    NbtCompound effect = new NbtCompound();
    effect.putInt("Amplifier", 125);
    effect.putInt("Id", 6);
    effect.putInt("Duration", 2000);
    NbtList effects = new NbtList();
    effects.add(effect);
    NbtCompound nbt = new NbtCompound();
    nbt.put("CustomPotionEffects", effects);
    stack.setNbt(nbt);
    return stack;
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) NbtList(net.minecraft.nbt.NbtList) ItemStack(net.minecraft.item.ItemStack)

Aggregations

NbtCompound (net.minecraft.nbt.NbtCompound)515 NbtList (net.minecraft.nbt.NbtList)149 ItemStack (net.minecraft.item.ItemStack)129 NbtElement (net.minecraft.nbt.NbtElement)40 Identifier (net.minecraft.util.Identifier)40 IOException (java.io.IOException)39 LiteralText (net.minecraft.text.LiteralText)33 BlockPos (net.minecraft.util.math.BlockPos)30 Inject (org.spongepowered.asm.mixin.injection.Inject)27 NbtString (net.minecraft.nbt.NbtString)20 TranslatableText (net.minecraft.text.TranslatableText)17 Item (net.minecraft.item.Item)15 PacketByteBuf (net.minecraft.network.PacketByteBuf)15 File (java.io.File)14 BlockState (net.minecraft.block.BlockState)14 UUID (java.util.UUID)13 MinecraftClient (net.minecraft.client.MinecraftClient)13 PlayerEntity (net.minecraft.entity.player.PlayerEntity)13 Text (net.minecraft.text.Text)13 HashMap (java.util.HashMap)12