Search in sources :

Example 71 with CompoundTag

use of net.minecraft.nbt.CompoundTag in project MC-Prefab by Brian-Wuest.

the class StructureTagMessage method encode.

public static void encode(StructureTagMessage message, FriendlyByteBuf buf) {
    CompoundTag tag = new CompoundTag();
    tag.putInt("config", message.structureConfig.identifier);
    tag.put("dataTag", message.tagMessage);
    buf.writeNbt(tag);
}
Also used : CompoundTag(net.minecraft.nbt.CompoundTag)

Example 72 with CompoundTag

use of net.minecraft.nbt.CompoundTag in project MC-Prefab by Brian-Wuest.

the class StructureConfiguration method WriteToCompoundTag.

/**
 * Writes the properties to an CompoundTag.
 *
 * @return An CompoundTag with the updated properties.
 */
public CompoundTag WriteToCompoundTag() {
    CompoundTag tag = new CompoundTag();
    if (this.pos != null) {
        tag.putInt(StructureConfiguration.hitXTag, this.pos.getX());
        tag.putInt(StructureConfiguration.hitYTag, this.pos.getY());
        tag.putInt(StructureConfiguration.hitZTag, this.pos.getZ());
    }
    tag.putString(StructureConfiguration.houseFacingTag, this.houseFacing.getSerializedName());
    tag = this.CustomWriteToCompoundTag(tag);
    return tag;
}
Also used : CompoundTag(net.minecraft.nbt.CompoundTag)

Example 73 with CompoundTag

use of net.minecraft.nbt.CompoundTag in project MC-Prefab by Brian-Wuest.

the class HouseConfiguration method WriteToCompoundTag.

@Override
public CompoundTag WriteToCompoundTag() {
    CompoundTag tag = new CompoundTag();
    // This tag should only be written for options which will NOT be overwritten by server options.
    // Server configuration settings will be used for all other options.
    // This is so the server admin can force a player to not use something.
    tag.putBoolean(HouseConfiguration.addTorchesTag, this.addTorches);
    tag.putBoolean(HouseConfiguration.addBedTag, this.addBed);
    tag.putBoolean(HouseConfiguration.addCraftingTableTag, this.addCraftingTable);
    tag.putBoolean(HouseConfiguration.addFurnaceTag, this.addFurnace);
    tag.putBoolean(HouseConfiguration.addChestTag, this.addChest);
    tag.putBoolean(HouseConfiguration.addChestContentsTag, this.addChestContents);
    tag.putBoolean(HouseConfiguration.addMineShaftTag, this.addMineShaft);
    tag.putInt(HouseConfiguration.hitXTag, this.pos.getX());
    tag.putInt(HouseConfiguration.hitYTag, this.pos.getY());
    tag.putInt(HouseConfiguration.hitZTag, this.pos.getZ());
    tag.putString(HouseConfiguration.houseFacingTag, this.houseFacing.getSerializedName());
    tag.putInt(HouseConfiguration.houseStyleTag, this.houseStyle.value);
    tag.putString(HouseConfiguration.glassColorTag, this.glassColor.getSerializedName().toUpperCase());
    tag.putString(HouseConfiguration.bedColorTag, this.bedColor.getSerializedName().toUpperCase());
    return tag;
}
Also used : CompoundTag(net.minecraft.nbt.CompoundTag)

Example 74 with CompoundTag

use of net.minecraft.nbt.CompoundTag in project MC-Prefab by Brian-Wuest.

the class EntityPlayerConfiguration method loadFromEntityData.

/**
 * Creates an EntityPlayerConfiguration from an entity player object.
 *
 * @param player The player to create the instance from.
 * @return A new instance of EntityPlayerConfiguration.
 */
public static EntityPlayerConfiguration loadFromEntityData(Player player) {
    EntityPlayerConfiguration config = new EntityPlayerConfiguration();
    CompoundTag compoundTag = config.getModIsPlayerNewTag(player);
    config.loadFromNBTTagCompound(compoundTag);
    return config;
}
Also used : CompoundTag(net.minecraft.nbt.CompoundTag)

Example 75 with CompoundTag

use of net.minecraft.nbt.CompoundTag in project MC-Prefab by Brian-Wuest.

the class EntityPlayerConfiguration method saveToPlayer.

/**
 * Saves this instance's data to the player tag.
 *
 * @param player The player to save the data too.
 */
public void saveToPlayer(Player player) {
    CompoundTag compoundTag = this.getModIsPlayerNewTag(player);
    compoundTag.putBoolean(EntityPlayerConfiguration.Built_Starter_house_Tag, this.builtStarterHouse);
    compoundTag.putBoolean(EntityPlayerConfiguration.GIVEN_HOUSEBUILDER_TAG, this.givenHouseBuilder);
}
Also used : CompoundTag(net.minecraft.nbt.CompoundTag)

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