Search in sources :

Example 51 with CompoundNBT

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);
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) SUpdateTileEntityPacket(net.minecraft.network.play.server.SUpdateTileEntityPacket) Nullable(javax.annotation.Nullable)

Example 52 with CompoundNBT

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;
        }
    }
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT)

Example 53 with CompoundNBT

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;
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) Nullable(javax.annotation.Nullable)

Example 54 with CompoundNBT

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;
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT)

Example 55 with CompoundNBT

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;
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT)

Aggregations

CompoundNBT (net.minecraft.nbt.CompoundNBT)119 ItemStack (net.minecraft.item.ItemStack)33 ListNBT (net.minecraft.nbt.ListNBT)15 Nonnull (javax.annotation.Nonnull)12 PlayerEntity (net.minecraft.entity.player.PlayerEntity)10 ResourceLocation (net.minecraft.util.ResourceLocation)8 BlockPos (net.minecraft.util.math.BlockPos)8 TileEntity (net.minecraft.tileentity.TileEntity)7 StringTextComponent (net.minecraft.util.text.StringTextComponent)7 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)6 DimensionType (net.minecraft.world.dimension.DimensionType)6 TileBPMultipart (com.bluepowermod.tile.TileBPMultipart)5 Block (net.minecraft.block.Block)5 BlockState (net.minecraft.block.BlockState)5 ArrayList (java.util.ArrayList)4 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)4 SUpdateTileEntityPacket (net.minecraft.network.play.server.SUpdateTileEntityPacket)4 LongItemStack (com.cjm721.overloaded.storage.stacks.intint.LongItemStack)3 Nullable (javax.annotation.Nullable)3 IItemProvider (net.minecraft.util.IItemProvider)3