Search in sources :

Example 61 with CompoundTag

use of net.minecraft.nbt.CompoundTag in project Tropicraft by Tropicraft.

the class AirCompressorBlockEntity method save.

@Override
@Nonnull
public CompoundTag save(@Nonnull CompoundTag nbt) {
    super.save(nbt);
    nbt.putBoolean("Compressing", compressing);
    CompoundTag var4 = new CompoundTag();
    this.stack.save(var4);
    nbt.put("Tank", var4);
    return nbt;
}
Also used : CompoundTag(net.minecraft.nbt.CompoundTag) Nonnull(javax.annotation.Nonnull)

Example 62 with CompoundTag

use of net.minecraft.nbt.CompoundTag in project Tropicraft by Tropicraft.

the class DrinkMixerBlockEntity method save.

@Override
@Nonnull
public CompoundTag save(@Nonnull CompoundTag nbt) {
    super.save(nbt);
    nbt.putInt("MixTicks", ticks);
    nbt.putBoolean("Mixing", mixing);
    for (int i = 0; i < MAX_NUM_INGREDIENTS; i++) {
        CompoundTag ingredientNbt = new CompoundTag();
        ingredients.get(i).save(ingredientNbt);
        nbt.put("Ingredient" + i, ingredientNbt);
    }
    CompoundTag resultNbt = new CompoundTag();
    result.save(resultNbt);
    nbt.put("Result", resultNbt);
    return nbt;
}
Also used : CompoundTag(net.minecraft.nbt.CompoundTag) Nonnull(javax.annotation.Nonnull)

Example 63 with CompoundTag

use of net.minecraft.nbt.CompoundTag in project Tropicraft by Tropicraft.

the class HomeTreeBranchPiece method createJigsawNbt.

private static CompoundTag createJigsawNbt() {
    CompoundTag nbt = new CompoundTag();
    nbt.putString("name", "minecraft:bottom");
    nbt.putString("final_state", "minecraft:air");
    nbt.putString("pool", "minecraft:empty");
    nbt.putString("target", "minecraft:empty");
    nbt.putString("joint", JigsawBlockEntity.JointType.ROLLABLE.getSerializedName());
    return nbt;
}
Also used : CompoundTag(net.minecraft.nbt.CompoundTag)

Example 64 with CompoundTag

use of net.minecraft.nbt.CompoundTag in project Tropicraft by Tropicraft.

the class EntityKoaBase method readAdditionalSaveData.

@Override
public void readAdditionalSaveData(CompoundTag compound) {
    super.readAdditionalSaveData(compound);
    if (compound.contains("home_X")) {
        this.restrictTo(new BlockPos(compound.getInt("home_X"), compound.getInt("home_Y"), compound.getInt("home_Z")), MAX_HOME_DISTANCE);
    }
    if (compound.contains("fireplace_X")) {
        this.setFirelacePos(new BlockPos(compound.getInt("fireplace_X"), compound.getInt("fireplace_Y"), compound.getInt("fireplace_Z")));
    }
    lastTimeFished = compound.getLong("lastTimeFished");
    if (compound.contains("koa_inventory", 9)) {
        ListTag nbttaglist = compound.getList("koa_inventory", 10);
        for (int i = 0; i < nbttaglist.size(); ++i) {
            CompoundTag nbttagcompound = nbttaglist.getCompound(i);
            int j = nbttagcompound.getByte("Slot") & 255;
            this.inventory.setItem(j, ItemStack.of(nbttagcompound));
        }
    }
    this.villageID = compound.getInt("village_id");
    // backwards compat
    if (!compound.contains("village_dimension")) {
        this.villageDimension = level.dimension();
    } else {
        this.villageDimension = ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(compound.getString("village_dim_id")));
    }
    if (compound.contains("role_id")) {
        this.getEntityData().set(ROLE, compound.getInt("role_id"));
    } else {
        rollDiceRole();
    }
    if (compound.contains("gender_id")) {
        this.getEntityData().set(GENDER, compound.getInt("gender_id"));
    } else {
        rollDiceGender();
    }
    this.lastTradeTime = compound.getLong("lastTradeTime");
    for (int i = 0; i < MAX_DRUMS; i++) {
        if (compound.contains("drum_" + i + "_X")) {
            this.listPosDrums.add(new BlockPos(compound.getInt("drum_" + i + "_X"), compound.getInt("drum_" + i + "_Y"), compound.getInt("drum_" + i + "_Z")));
        }
    }
    druggedTime = compound.getInt("druggedTime");
    updateUniqueEntityAI();
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) BlockPos(net.minecraft.core.BlockPos) ListTag(net.minecraft.nbt.ListTag) CompoundTag(net.minecraft.nbt.CompoundTag)

Example 65 with CompoundTag

use of net.minecraft.nbt.CompoundTag in project Tropicraft by Tropicraft.

the class CocktailItem method appendHoverText.

@Override
@OnlyIn(Dist.CLIENT)
public void appendHoverText(ItemStack stack, @Nullable Level world, List<Component> tooltip, TooltipFlag flag) {
    Drink drink = getDrink(stack);
    if (drink == Drink.COCKTAIL && stack.hasTag() && stack.getTag().contains("Ingredients")) {
        final ListTag ingredients = stack.getTag().getList("Ingredients", 10);
        for (int i = 0; i < ingredients.size(); ++i) {
            CompoundTag ingredient = ingredients.getCompound(i);
            int id = ingredient.getByte("IngredientID");
            Component ingredientName = Ingredient.ingredientsList[id].getDisplayName();
            int ingredientColor = Ingredient.ingredientsList[id].getColor();
            // String lvl = StatCollector.translateToLocal("enchantment.level." + count);
            // par3List.add(ingredientName + " " + lvl);
            tooltip.add(ingredientName);
        }
    }
}
Also used : Drink(net.tropicraft.core.common.drinks.Drink) Component(net.minecraft.network.chat.Component) ListTag(net.minecraft.nbt.ListTag) CompoundTag(net.minecraft.nbt.CompoundTag) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Aggregations

CompoundTag (net.minecraft.nbt.CompoundTag)146 ListTag (net.minecraft.nbt.ListTag)41 ItemStack (net.minecraft.world.item.ItemStack)22 TagCompound (de.keyle.knbt.TagCompound)12 ResourceLocation (net.minecraft.resources.ResourceLocation)12 Nullable (org.checkerframework.checker.nullness.qual.Nullable)10 Keys (org.spongepowered.api.data.Keys)9 DataProviderRegistrator (org.spongepowered.common.data.provider.DataProviderRegistrator)9 Constants (org.spongepowered.common.util.Constants)9 TagList (de.keyle.knbt.TagList)8 ArrayList (java.util.ArrayList)8 List (java.util.List)8 IntArrayTag (net.minecraft.nbt.IntArrayTag)8 Tag (net.minecraft.nbt.Tag)8 ResourceKey (org.spongepowered.api.ResourceKey)8 DataContainer (org.spongepowered.api.data.persistence.DataContainer)8 DataView (org.spongepowered.api.data.persistence.DataView)8 ByteArrayTag (net.minecraft.nbt.ByteArrayTag)7 TagString (de.keyle.knbt.TagString)6 Block (net.minecraft.world.level.block.Block)6