Search in sources :

Example 11 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project BluePower by Qmunity.

the class WorldConverter method convertRegion.

private void convertRegion(File file) {
    RegionFile reg = new RegionFile(file);
    for (int x = 0; x < 32; x++) {
        for (int z = 0; z < 32; z++) {
            NBTTagCompound chunk = getChunk(reg, x, z);
            if (chunk == null)
                continue;
            NBTTagList tileEntities = chunk.getTagList("TileEntities", new NBTTagCompound().getId());
            boolean changed = false;
            for (int i = 0; i < tileEntities.tagCount(); i++) {
                NBTTagCompound te = tileEntities.getCompoundTagAt(i);
                if (te.getString("id").equals("savedMultipart"))
                    changed |= convertTile(te);
            }
            if (changed)
                saveChunk(reg, x, z, chunk);
        }
    }
    try {
        reg.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) RegionFile(net.minecraft.world.chunk.storage.RegionFile) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IOException(java.io.IOException)

Example 12 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project BluePower by Qmunity.

the class WorldConverter method getChunk.

private NBTTagCompound getChunk(RegionFile reg, int x, int y) {
    try {
        DataInputStream inputStream = reg.getChunkDataInputStream(x & 31, y & 31);
        if (inputStream == null)
            return null;
        NBTTagCompound tag = CompressedStreamTools.read(inputStream).getCompoundTag("Level");
        return tag;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) DataInputStream(java.io.DataInputStream) IOException(java.io.IOException)

Example 13 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project BluePower by Qmunity.

the class WorldConverter method saveChunk.

private void saveChunk(RegionFile reg, int x, int y, NBTTagCompound chunkData) {
    NBTTagCompound tag = new NBTTagCompound();
    tag.setTag("Level", chunkData);
    try {
        DataOutputStream outputStream = reg.getChunkDataOutputStream(x & 31, y & 31);
        CompressedStreamTools.write(tag, outputStream);
        outputStream.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : DataOutputStream(java.io.DataOutputStream) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IOException(java.io.IOException)

Example 14 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project BluePower by Qmunity.

the class PartConverterWire method convert.

@Override
public IPart convert(NBTTagCompound old) {
    String id = old.getString("part_id").replace("bluestoneWire", "wire.bluestone").replace("silver", "light_gray");
    PartInfo info = PartManager.getPartInfo(id);
    if (info == null)
        return null;
    PartRedwireFace part = (PartRedwireFace) info.create();
    NBTTagCompound data = old.getCompoundTag("partData");
    part.setFace(ForgeDirection.getOrientation(data.getInteger("face")));
    return part;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) PartInfo(com.bluepowermod.part.PartInfo) PartRedwireFace(com.bluepowermod.part.wire.redstone.PartRedwireFace)

Example 15 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project BluePower by Qmunity.

the class GateIntegratedCircuit method readParts.

private void readParts(NBTTagList l) {
    for (int i = 0; i < l.tagCount(); i++) {
        NBTTagCompound tag = l.getCompoundTagAt(i);
        int x = tag.getInteger("x");
        int z = tag.getInteger("z");
        IPart p = getPart(x, z);
        if (p == null) {
            p = PartRegistry.createPart(tag.getString("type"), false);
            if (p == null || !(p instanceof IIntegratedCircuitPart))
                continue;
            setPart(x, z, (IIntegratedCircuitPart) p);
        }
        p.readFromNBT(tag.getCompoundTag("data"));
    }
}
Also used : IPart(uk.co.qmunity.lib.part.IPart) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IIntegratedCircuitPart(com.bluepowermod.api.gate.IIntegratedCircuitPart)

Aggregations

NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3985 NBTTagList (net.minecraft.nbt.NBTTagList)1052 ItemStack (net.minecraft.item.ItemStack)883 BlockPos (net.minecraft.util.math.BlockPos)229 TileEntity (net.minecraft.tileentity.TileEntity)173 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)148 ArrayList (java.util.ArrayList)99 Block (net.minecraft.block.Block)98 ResourceLocation (net.minecraft.util.ResourceLocation)96 IBlockState (net.minecraft.block.state.IBlockState)92 EntityPlayer (net.minecraft.entity.player.EntityPlayer)81 NBTTagString (net.minecraft.nbt.NBTTagString)79 Nonnull (javax.annotation.Nonnull)74 Map (java.util.Map)71 UUID (java.util.UUID)69 NBTBase (net.minecraft.nbt.NBTBase)66 HashMap (java.util.HashMap)64 EnumFacing (net.minecraft.util.EnumFacing)61 NotNull (org.jetbrains.annotations.NotNull)60 Item (net.minecraft.item.Item)55