Search in sources :

Example 86 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project ct.js by ChatTriggers.

the class Book method setPage.

/**
 * Sets a page of the book to the specified message.
 *
 * @param pageNumber the number of the page to set
 * @param message    the message to set the page to
 * @return the current book to allow method chaining
 */
public Book setPage(int pageNumber, Message message) {
    NBTTagList pages = (NBTTagList) bookData.getTag("pages");
    pages.set(pageNumber, new NBTTagString(IChatComponent.Serializer.componentToJson(message.getChatMessage())));
    updateBookScreen(pages);
    return this;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagString(net.minecraft.nbt.NBTTagString)

Example 87 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project ImmersiveEngineering by BluSunrize.

the class TileEntityFeedthrough method getTileDrops.

@Override
public NonNullList<ItemStack> getTileDrops(@Nullable EntityPlayer player, IBlockState state) {
    WireApi.FeedthroughModelInfo info = INFOS.get(reference);
    if (info.canReplace()) {
        if (offset == 0)
            return Utils.getDrops(stateForMiddle);
        else {
            // If it's marked as replaceable it should have a state to replace with
            assert info.conn != null;
            return NonNullList.from(ItemStack.EMPTY, new ItemStack(info.conn.getBlock(), 1, info.conn.getBlock().getMetaFromState(info.conn)));
        }
    } else {
        ItemStack stack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state));
        stack.setTagInfo(WIRE, new NBTTagString(reference.getUniqueName()));
        NBTTagCompound stateNbt = new NBTTagCompound();
        Utils.stateToNBT(stateNbt, stateForMiddle);
        stack.setTagInfo(MIDDLE_STATE, stateNbt);
        return NonNullList.from(ItemStack.EMPTY, stack);
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagString(net.minecraft.nbt.NBTTagString) ItemStack(net.minecraft.item.ItemStack)

Example 88 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project ImmersiveEngineering by BluSunrize.

the class TileEntityTurret method getTileDrop.

@Override
public ItemStack getTileDrop(EntityPlayer player, IBlockState state) {
    ItemStack stack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state));
    TileEntityTurret turret = this;
    if (dummy) {
        TileEntity t = world.getTileEntity(getPos().down());
        if (t instanceof TileEntityTurret)
            turret = (TileEntityTurret) t;
        else
            return stack;
    }
    NBTTagCompound tag = new NBTTagCompound();
    // Only writing values when they are different from defaults
    if (turret.owner != null && (player == null || !player.getName().equalsIgnoreCase(turret.owner)))
        tag.setString("owner", turret.owner);
    if (turret.targetList.size() != 1 || !isListedName(turret.targetList, turret.owner)) {
        NBTTagList list = new NBTTagList();
        for (String s : turret.targetList) list.appendTag(new NBTTagString(s));
        tag.setTag("targetList", list);
    }
    if (turret.whitelist)
        tag.setBoolean("whitelist", turret.whitelist);
    if (turret.attackAnimals)
        tag.setBoolean("attackAnimals", turret.attackAnimals);
    if (!turret.attackPlayers)
        tag.setBoolean("attackPlayers", turret.attackPlayers);
    if (turret.attackNeutrals)
        tag.setBoolean("attackNeutrals", turret.attackNeutrals);
    if (turret.redstoneControlInverted)
        tag.setBoolean("redstoneControlInverted", turret.redstoneControlInverted);
    if (!tag.isEmpty())
        stack.setTagCompound(tag);
    return stack;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagString(net.minecraft.nbt.NBTTagString) NBTTagString(net.minecraft.nbt.NBTTagString) ItemStack(net.minecraft.item.ItemStack)

Example 89 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project ImmersiveEngineering by BluSunrize.

the class IESaveData method writeToNBT.

@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
    Integer[] relDim = ImmersiveNetHandler.INSTANCE.getRelevantDimensions().toArray(new Integer[0]);
    int[] savedDimensions = new int[relDim.length];
    for (int ii = 0; ii < relDim.length; ii++) savedDimensions[ii] = relDim[ii];
    nbt.setIntArray("savedDimensions", savedDimensions);
    for (int dim : savedDimensions) {
        NBTTagList connectionList = new NBTTagList();
        for (Connection con : ImmersiveNetHandler.INSTANCE.getAllConnections(dim)) {
            connectionList.appendTag(con.writeToNBT());
        }
        nbt.setTag("connectionList" + dim, connectionList);
    }
    NBTTagList proxies = new NBTTagList();
    for (IICProxy iic : ImmersiveNetHandler.INSTANCE.proxies.values()) proxies.appendTag(iic.writeToNBT());
    nbt.setTag("iicProxies", proxies);
    NBTTagList mineralList = new NBTTagList();
    for (Map.Entry<DimensionChunkCoords, MineralWorldInfo> e : ExcavatorHandler.mineralCache.entrySet()) if (e.getKey() != null && e.getValue() != null) {
        NBTTagCompound tag = e.getKey().writeToNBT();
        tag.setTag("info", e.getValue().writeToNBT());
        mineralList.appendTag(tag);
    }
    nbt.setTag("mineralDepletion", mineralList);
    NBTTagList receivedShaderList = new NBTTagList();
    for (String player : ShaderRegistry.receivedShaders.keySet()) {
        NBTTagCompound tag = new NBTTagCompound();
        tag.setString("player", player);
        NBTTagList playerReceived = new NBTTagList();
        for (String shader : ShaderRegistry.receivedShaders.get(player)) if (shader != null && !shader.isEmpty())
            playerReceived.appendTag(new NBTTagString(shader));
        tag.setTag("received", playerReceived);
        receivedShaderList.appendTag(tag);
    }
    nbt.setTag("receivedShaderList", receivedShaderList);
    return nbt;
}
Also used : MineralWorldInfo(blusunrize.immersiveengineering.api.tool.ExcavatorHandler.MineralWorldInfo) IICProxy(blusunrize.immersiveengineering.api.energy.wires.IICProxy) Connection(blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagString(net.minecraft.nbt.NBTTagString) NBTTagList(net.minecraft.nbt.NBTTagList) DimensionChunkCoords(blusunrize.immersiveengineering.api.DimensionChunkCoords) NBTTagString(net.minecraft.nbt.NBTTagString) Map(java.util.Map)

Example 90 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project RecurrentComplex by Ivorforce.

the class RCCommunicationAdapter method writeNBTStrings.

public static void writeNBTStrings(String id, Collection<String> strings, NBTTagCompound compound) {
    if (strings != null) {
        NBTTagList nbtTagList = new NBTTagList();
        for (String s : strings) nbtTagList.appendTag(new NBTTagString(s));
        compound.setTag(id, nbtTagList);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagString(net.minecraft.nbt.NBTTagString) NBTTagString(net.minecraft.nbt.NBTTagString)

Aggregations

NBTTagString (net.minecraft.nbt.NBTTagString)101 NBTTagList (net.minecraft.nbt.NBTTagList)82 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)57 ItemStack (net.minecraft.item.ItemStack)18 NBTTagIntArray (net.minecraft.nbt.NBTTagIntArray)11 NBTBase (net.minecraft.nbt.NBTBase)10 NBTTagByteArray (net.minecraft.nbt.NBTTagByteArray)10 NBTTagInt (net.minecraft.nbt.NBTTagInt)10 NBTTagDouble (net.minecraft.nbt.NBTTagDouble)9 NBTTagFloat (net.minecraft.nbt.NBTTagFloat)9 NBTTagByte (net.minecraft.nbt.NBTTagByte)8 NBTTagLong (net.minecraft.nbt.NBTTagLong)8 ResourceLocation (net.minecraft.util.ResourceLocation)8 List (java.util.List)7 NBTTagShort (net.minecraft.nbt.NBTTagShort)7 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 Item (net.minecraft.item.Item)4