use of net.minecraft.nbt.CompoundNBT in project Overloaded by CJ-MC-Mods.
the class TilePlayerInterface method getUpdatePacket.
@Nullable
@Override
public SUpdateTileEntityPacket getUpdatePacket() {
CompoundNBT tag = new CompoundNBT();
save(tag);
return new SUpdateTileEntityPacket(getBlockPos(), 1, tag);
}
use of net.minecraft.nbt.CompoundNBT in project Overloaded by CJ-MC-Mods.
the class GenericDataStorage method readNBT.
@Override
public void readNBT(Capability<IGenericDataStorage> capability, IGenericDataStorage instance, Direction side, INBT nbt) {
if (!(nbt instanceof CompoundNBT))
return;
CompoundNBT tagCompound = ((CompoundNBT) nbt);
Map<String, Integer> integers = instance.getIntegerMap();
Map<String, Boolean> booleans = instance.getBooleanMap();
Map<String, Float> floats = instance.getFloatMap();
Map<String, Double> doubles = instance.getDoubleMap();
for (String key : tagCompound.getAllKeys()) {
switch(tagCompound.getTagType(key)) {
case Constants.NBT.TAG_INT:
integers.put(key, tagCompound.getInt(key));
break;
case Constants.NBT.TAG_BYTE:
booleans.put(key, tagCompound.getBoolean(key));
break;
case Constants.NBT.TAG_FLOAT:
floats.put(key, tagCompound.getFloat(key));
break;
case Constants.NBT.TAG_DOUBLE:
doubles.put(key, tagCompound.getDouble(key));
break;
}
}
}
use of net.minecraft.nbt.CompoundNBT in project Overloaded by CJ-MC-Mods.
the class GenericDataStorage method writeNBT.
@Nullable
@Override
public CompoundNBT writeNBT(Capability<IGenericDataStorage> capability, IGenericDataStorage instance, Direction side) {
CompoundNBT tagCompound = new CompoundNBT();
Map<String, Integer> integers = instance.getIntegerMap();
Map<String, Boolean> booleans = instance.getBooleanMap();
Map<String, Float> floats = instance.getFloatMap();
Map<String, Double> doubles = instance.getDoubleMap();
for (String key : integers.keySet()) {
tagCompound.putInt(key, integers.get(key));
}
for (String key : booleans.keySet()) {
tagCompound.putBoolean(key, booleans.get(key));
}
for (String key : floats.keySet()) {
tagCompound.putFloat(key, floats.get(key));
}
for (String key : doubles.keySet()) {
tagCompound.putDouble(key, doubles.get(key));
}
return tagCompound;
}
use of net.minecraft.nbt.CompoundNBT in project Overloaded by CJ-MC-Mods.
the class EnergyInventoryBasedRecipeProcessor method serializeNBT.
@Override
public CompoundNBT serializeNBT() {
CompoundNBT storage = new CompoundNBT();
storage.put("Input", NBTHelper.serializeItems(input));
storage.put("Output", NBTHelper.serializeItems(output));
storage.putInt("Energy", currentEnergy);
return storage;
}
use of net.minecraft.nbt.CompoundNBT in project Overloaded by CJ-MC-Mods.
the class BigIntFluidStorage method serializeNBT.
@Override
public CompoundNBT serializeNBT() {
CompoundNBT compound = new CompoundNBT();
if (storedFluid.fluidStack != null) {
CompoundNBT tag = new CompoundNBT();
storedFluid.fluidStack.writeToNBT(tag);
compound.put("Fluid", tag);
compound.putByteArray("Count", storedFluid.amount.toByteArray());
}
return compound;
}
Aggregations