use of com.nukkitx.nbt.NbtMap in project JukeboxMC by LucGamesYT.
the class BlockEntityShulkerBox method toCompound.
@Override
public NbtMapBuilder toCompound() {
NbtMapBuilder builder = super.toCompound();
List<NbtMap> itemsCompoundList = new ArrayList<>();
for (int slot = 0; slot < this.shulkerBoxInventory.getSize(); slot++) {
NbtMapBuilder itemCompound = NbtMap.builder();
Item item = this.shulkerBoxInventory.getItem(slot);
itemCompound.putByte("Slot", (byte) slot);
this.fromItem(item, itemCompound);
itemsCompoundList.add(itemCompound.build());
}
builder.putList("Items", NbtType.COMPOUND, itemsCompoundList);
builder.putByte("facing", this.facing);
builder.putBoolean("isUndyed", this.undyed);
return builder;
}
use of com.nukkitx.nbt.NbtMap in project JukeboxMC by LucGamesYT.
the class BlockEntityShulkerBox method fromCompound.
@Override
public void fromCompound(NbtMap compound) {
super.fromCompound(compound);
List<NbtMap> items = compound.getList("Items", NbtType.COMPOUND);
for (NbtMap nbtMap : items) {
Item item = this.toItem(nbtMap);
byte slot = nbtMap.getByte("Slot", (byte) 127);
if (slot == 127) {
this.shulkerBoxInventory.addItem(item, false);
} else {
this.shulkerBoxInventory.setItem(slot, item, false);
}
}
this.facing = compound.getByte("facing");
this.undyed = compound.getBoolean("isUndyed");
}
use of com.nukkitx.nbt.NbtMap in project JukeboxMC by LucGamesYT.
the class BlockEntityBanner method toCompound.
@Override
public NbtMapBuilder toCompound() {
NbtMapBuilder compound = super.toCompound();
compound.putInt("Base", this.baseColor);
compound.putInt("Type", this.type);
if (this.patterns.size() > 0) {
List<NbtMap> pattern = new ArrayList<>();
for (Map.Entry<String, Integer> entry : this.patterns.entrySet()) {
NbtMapBuilder patternBuilder = NbtMap.builder();
patternBuilder.putString("Pattern", entry.getKey());
patternBuilder.putInt("Color", entry.getValue());
pattern.add(patternBuilder.build());
}
compound.putList("Patterns", NbtType.COMPOUND, pattern);
}
return compound;
}
use of com.nukkitx.nbt.NbtMap in project JukeboxMC by LucGamesYT.
the class BlockEntityBarrel method fromCompound.
@Override
public void fromCompound(NbtMap compound) {
super.fromCompound(compound);
List<NbtMap> items = compound.getList("Items", NbtType.COMPOUND);
for (NbtMap nbtMap : items) {
Item item = this.toItem(nbtMap);
byte slot = nbtMap.getByte("Slot", (byte) 127);
if (slot == 127) {
this.barrelInventory.addItem(item, false);
} else {
this.barrelInventory.setItem(slot, item, false);
}
}
}
use of com.nukkitx.nbt.NbtMap in project JukeboxMC by LucGamesYT.
the class BlockEntityBarrel method toCompound.
@Override
public NbtMapBuilder toCompound() {
NbtMapBuilder builder = super.toCompound();
List<NbtMap> itemsCompoundList = new ArrayList<>();
for (int slot = 0; slot < this.barrelInventory.getSize(); slot++) {
NbtMapBuilder itemCompound = NbtMap.builder();
Item item = this.barrelInventory.getItem(slot);
itemCompound.putByte("Slot", (byte) slot);
this.fromItem(item, itemCompound);
itemsCompoundList.add(itemCompound.build());
}
builder.putList("Items", NbtType.COMPOUND, itemsCompoundList);
return builder;
}
Aggregations