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 IntEnergyWrapper method getStorage.
@Nonnull
private EnergyStorage getStorage() {
if (stack.getTag() == null) {
Overloaded.logger.error((CharSequence) "Something has changed private internal state in an invalid way. Resetting State.", new IllegalStateException("private internal state changed. Stack's Tag Compound is null"));
stack.setTag(new CompoundNBT());
}
int energy = stack.getTag().getInt("IntEnergyStorage");
return new EnergyStorage(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, energy);
}
use of net.minecraft.nbt.CompoundNBT in project Overloaded by CJ-MC-Mods.
the class ProcessingItemStorage method serializeNBT.
@Override
public CompoundNBT serializeNBT() {
CompoundNBT storage = new CompoundNBT();
CompoundNBT inputNBT = new CompoundNBT();
CompoundNBT outputNBT = new CompoundNBT();
ItemStackHelper.saveAllItems(inputNBT, input);
ItemStackHelper.saveAllItems(outputNBT, output);
storage.put("Input", inputNBT);
storage.put("Output", outputNBT);
return storage;
}
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);
}
Aggregations