use of net.minecraft.nbt.NBTTagString in project BuildCraft by BuildCraft.
the class RetroGenData method writeToNBT.
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
Set<String> allNames = new HashSet<>();
for (Set<String> used : gennedChunks.values()) {
allNames.addAll(used);
}
TObjectByteHashMap<String> map = new TObjectByteHashMap<>();
List<String> list = new ArrayList<>(allNames);
NBTTagList registry = new NBTTagList();
for (int i = 0; i < list.size(); i++) {
String name = list.get(i);
map.put(name, (byte) i);
registry.appendTag(new NBTTagString(name));
}
nbt.setTag("registry", registry);
NBTTagCompound data = new NBTTagCompound();
for (Entry<ChunkPos, Set<String>> entry : gennedChunks.entrySet()) {
String key = serializeChunkPos(entry.getKey());
Set<String> names = entry.getValue();
TByteArrayList ids = new TByteArrayList();
for (String s : names) {
byte b = map.get(s);
ids.add(b);
}
data.setByteArray(key, ids.toArray());
}
nbt.setTag("data", data);
return nbt;
}
use of net.minecraft.nbt.NBTTagString in project BuildCraft by BuildCraft.
the class GatePluggable method writeToNBT.
@Override
public void writeToNBT(NBTTagCompound nbt) {
nbt.setByte(ItemGate.NBT_TAG_MAT, (byte) material.ordinal());
nbt.setByte(ItemGate.NBT_TAG_LOGIC, (byte) logic.ordinal());
NBTTagList expansionsList = nbt.getTagList(ItemGate.NBT_TAG_EX, Constants.NBT.TAG_STRING);
for (IGateExpansion expansion : expansions) {
expansionsList.appendTag(new NBTTagString(expansion.getUniqueIdentifier()));
}
nbt.setTag(ItemGate.NBT_TAG_EX, expansionsList);
}
use of net.minecraft.nbt.NBTTagString in project BuildCraft by BuildCraft.
the class TileAssemblyTable method writeToNBT.
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
NBTTagList list = new NBTTagList();
for (String recipe : plannedOutput) {
list.appendTag(new NBTTagString(recipe));
}
nbt.setTag("plannedIds", list);
if (currentRecipe != null) {
nbt.setString("recipeId", currentRecipe.getId());
}
}
use of net.minecraft.nbt.NBTTagString in project BuildCraft by BuildCraft.
the class NbtSquishMap method addTag.
public void addTag(NBTBase nbt) {
if (nbt instanceof NBTTagString) {
String val = ((NBTTagString) nbt).getString();
if (!strings.contains(val)) {
strings.add(val);
}
} else if (nbt instanceof NBTTagByte) {
byte val = ((NBTTagByte) nbt).getByte();
if (!bytes.contains(val)) {
bytes.add(val);
}
} else if (nbt instanceof NBTTagShort) {
short val = ((NBTTagShort) nbt).getShort();
if (!shorts.contains(val)) {
shorts.add(val);
}
} else if (nbt instanceof NBTTagInt) {
int val = ((NBTTagInt) nbt).getInt();
if (!ints.contains(val)) {
ints.add(val);
}
} else if (nbt instanceof NBTTagLong) {
long val = ((NBTTagLong) nbt).getLong();
if (!longs.contains(val)) {
longs.add(val);
}
} else if (nbt instanceof NBTTagFloat) {
float val = ((NBTTagFloat) nbt).getFloat();
if (!floats.contains(val)) {
floats.add(val);
}
} else if (nbt instanceof NBTTagDouble) {
double val = ((NBTTagDouble) nbt).getDouble();
if (!doubles.contains(val)) {
doubles.add(val);
}
} else if (nbt instanceof NBTTagByteArray) {
byte[] val = ((NBTTagByteArray) nbt).getByteArray();
TByteArrayList array = new TByteArrayList(val);
if (!byteArrays.contains(array)) {
byteArrays.add(array);
}
} else if (nbt instanceof NBTTagIntArray) {
int[] val = ((NBTTagIntArray) nbt).getIntArray();
TIntArrayList array = new TIntArrayList(val);
if (!intArrays.contains(array)) {
intArrays.add(array);
}
} else if (nbt instanceof NBTTagList) {
NBTTagList list = (NBTTagList) nbt;
if (!complex.contains(list)) {
for (int i = 0; i < list.tagCount(); i++) {
addTag(list.get(i));
}
complex.add(list);
}
} else if (nbt instanceof NBTTagCompound) {
NBTTagCompound compound = (NBTTagCompound) nbt;
if (!complex.contains(compound)) {
for (String key : compound.getKeySet()) {
if (!strings.contains(key)) {
strings.add(key);
}
addTag(compound.getTag(key));
}
complex.add(compound);
}
} else {
throw new IllegalArgumentException("Cannot handle tag " + nbt);
}
}
use of net.minecraft.nbt.NBTTagString in project BuildCraft by BuildCraft.
the class NbtSquishMap method indexOfTag.
public int indexOfTag(NBTBase nbt) {
int offset = 0;
if (nbt instanceof NBTTagByte) {
return bytes.indexOf(((NBTTagByte) nbt).getByte());
} else {
offset += bytes.size();
}
if (nbt instanceof NBTTagShort) {
return offset + shorts.indexOf(((NBTTagShort) nbt).getShort());
} else {
offset += shorts.size();
}
if (nbt instanceof NBTTagInt) {
return offset + ints.indexOf(((NBTTagInt) nbt).getInt());
} else {
offset += ints.size();
}
if (nbt instanceof NBTTagLong) {
return offset + longs.indexOf(((NBTTagLong) nbt).getLong());
} else {
offset += longs.size();
}
if (nbt instanceof NBTTagFloat) {
return offset + floats.indexOf(((NBTTagFloat) nbt).getFloat());
} else {
offset += floats.size();
}
if (nbt instanceof NBTTagDouble) {
return offset + doubles.indexOf(((NBTTagDouble) nbt).getDouble());
} else {
offset += doubles.size();
}
if (nbt instanceof NBTTagByteArray) {
byte[] val = ((NBTTagByteArray) nbt).getByteArray();
TByteArrayList array = new TByteArrayList(val);
return offset + byteArrays.indexOf(array);
} else {
offset += byteArrays.size();
}
if (nbt instanceof NBTTagIntArray) {
int[] val = ((NBTTagIntArray) nbt).getIntArray();
TIntArrayList array = new TIntArrayList(val);
return offset + intArrays.indexOf(array);
} else {
offset += intArrays.size();
}
if (nbt instanceof NBTTagString) {
return offset + strings.indexOf(((NBTTagString) nbt).getString());
} else {
offset += strings.size();
}
if (nbt instanceof NBTTagList) {
return offset + complex.indexOf(nbt);
} else if (nbt instanceof NBTTagCompound) {
return offset + complex.indexOf(nbt);
}
throw new IllegalArgumentException("Cannot handle tag " + nbt);
}
Aggregations