Search in sources :

Example 86 with NBTTagList

use of net.minecraft.nbt.NBTTagList in project MineFactoryReloaded by powercrystals.

the class TileEntityRedNetLogic method writeToNBT.

@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
    super.writeToNBT(nbttagcompound);
    NBTTagList circuits = new NBTTagList();
    for (int c = 0; c < _circuits.length; c++) {
        NBTTagCompound circuit = new NBTTagCompound();
        circuit.setString("circuit", _circuits[c].getClass().getName());
        NBTTagList inputPins = new NBTTagList();
        for (int p = 0; p < _pinMappingInputs[c].length; p++) {
            NBTTagCompound pin = new NBTTagCompound();
            pin.setInteger("buffer", _pinMappingInputs[c][p].buffer);
            pin.setInteger("pin", _pinMappingInputs[c][p].pin);
            inputPins.appendTag(pin);
        }
        circuit.setTag("inputPins", inputPins);
        NBTTagList outputPins = new NBTTagList();
        for (int p = 0; p < _pinMappingOutputs[c].length; p++) {
            NBTTagCompound pin = new NBTTagCompound();
            pin.setInteger("buffer", _pinMappingOutputs[c][p].buffer);
            pin.setInteger("pin", _pinMappingOutputs[c][p].pin);
            outputPins.appendTag(pin);
        }
        circuit.setTag("outputPins", outputPins);
        NBTTagCompound circuitState = new NBTTagCompound();
        _circuits[c].writeToNBT(circuitState);
        circuit.setTag("state", circuitState);
        circuits.appendTag(circuit);
    }
    nbttagcompound.setTag("circuits", circuits);
    nbttagcompound.setIntArray("upgrades", _upgradeLevel);
    nbttagcompound.setIntArray("vars", _buffers[13]);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 87 with NBTTagList

use of net.minecraft.nbt.NBTTagList in project MineFactoryReloaded by powercrystals.

the class TileEntityFactoryPowered method writeToNBT.

@Override
public void writeToNBT(NBTTagCompound tag) {
    super.writeToNBT(tag);
    tag.setInteger("energyStored", _energyStored);
    tag.setInteger("workDone", _workDone);
    tag.setInteger("ueBuffer", _ueBuffer);
    NBTTagCompound pp = new NBTTagCompound();
    _powerProvider.writeToNBT(pp);
    tag.setCompoundTag("powerProvider", pp);
    if (failedDrops != null) {
        NBTTagList nbttaglist = new NBTTagList();
        for (ItemStack item : failedDrops) {
            NBTTagCompound nbttagcompound1 = new NBTTagCompound();
            item.writeToNBT(nbttagcompound1);
            nbttaglist.appendTag(nbttagcompound1);
        }
        tag.setTag("DropItems", nbttaglist);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 88 with NBTTagList

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

the class MultiFluidTank method writeToNBT.

public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
    NBTTagList tagList = new NBTTagList();
    for (FluidStack fs : this.fluids) if (fs != null)
        tagList.appendTag(fs.writeToNBT(new NBTTagCompound()));
    nbt.setTag("fluids", tagList);
    return nbt;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) FluidStack(net.minecraftforge.fluids.FluidStack) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 89 with NBTTagList

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

the class TConstructHelper method sendAlloyForMelting.

public static void sendAlloyForMelting(FluidStack output, Object... input) {
    assert (input.length % 2 == 0);
    FluidStack[] inputStacks = new FluidStack[input.length / 2];
    for (int i = 0; i < inputStacks.length; i++) if (input[i * 2] instanceof String && input[i * 2 + 1] instanceof Integer) {
        Fluid f = FluidRegistry.getFluid((String) input[i * 2]);
        if (f != null)
            inputStacks[i] = new FluidStack(f, (Integer) input[i * 2 + 1]);
    }
    NBTTagList tagList = new NBTTagList();
    tagList.appendTag(output.writeToNBT(new NBTTagCompound()));
    for (FluidStack stack : inputStacks) if (stack != null)
        tagList.appendTag(stack.writeToNBT(new NBTTagCompound()));
    NBTTagCompound message = new NBTTagCompound();
    message.setTag("alloy", tagList);
    //		FMLInterModComms.sendMessage("tconstruct", "alloy", message);
    //	For some reason IMC on this is broken? So direct interaction is required. Oh well.
    TinkerRegistry.registerAlloy(output, inputStacks);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) FluidStack(net.minecraftforge.fluids.FluidStack) Fluid(net.minecraftforge.fluids.Fluid) BlockIEFluid(blusunrize.immersiveengineering.common.blocks.BlockIEFluid) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 90 with NBTTagList

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

the class Utils method writeInventory.

public static NBTTagList writeInventory(Collection<ItemStack> inv) {
    NBTTagList invList = new NBTTagList();
    byte slot = 0;
    for (ItemStack s : inv) {
        if (s != null) {
            NBTTagCompound itemTag = new NBTTagCompound();
            itemTag.setByte("Slot", slot);
            s.writeToNBT(itemTag);
            invList.appendTag(itemTag);
        }
        slot++;
    }
    return invList;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Aggregations

NBTTagList (net.minecraft.nbt.NBTTagList)451 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)385 ItemStack (net.minecraft.item.ItemStack)69 NBTTagString (net.minecraft.nbt.NBTTagString)42 BlockPos (net.minecraft.util.math.BlockPos)18 HashMap (java.util.HashMap)17 Map (java.util.Map)17 NotNull (org.jetbrains.annotations.NotNull)17 ArrayList (java.util.ArrayList)14 AMVector3 (am2.api.math.AMVector3)9 ChunkPosition (net.minecraft.world.ChunkPosition)9 NBTBase (net.minecraft.nbt.NBTBase)8 EntityPlayer (net.minecraft.entity.player.EntityPlayer)7 Vec3d (net.minecraft.util.math.Vec3d)7 WorldCoordinate (mods.railcraft.api.core.WorldCoordinate)6 Block (net.minecraft.block.Block)6 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)5 Entity (net.minecraft.entity.Entity)5 TileEntity (net.minecraft.tileentity.TileEntity)5 ChunkPos (net.minecraft.util.math.ChunkPos)5