use of com.nukkitx.nbt.NbtMap in project JukeboxMC by LucGamesYT.
the class BlockEntityBlastFurnace method toCompound.
@Override
public NbtMapBuilder toCompound() {
NbtMapBuilder builder = super.toCompound();
List<NbtMap> itemsCompoundList = new ArrayList<>();
for (int slot = 0; slot < this.blastFurnaceInventory.getSize(); slot++) {
NbtMapBuilder itemCompound = NbtMap.builder();
Item item = this.blastFurnaceInventory.getItem(slot);
itemCompound.putByte("Slot", (byte) slot);
this.fromItem(item, itemCompound);
itemsCompoundList.add(itemCompound.build());
}
builder.putList("Items", NbtType.COMPOUND, itemsCompoundList);
return builder;
}
use of com.nukkitx.nbt.NbtMap in project JukeboxMC by LucGamesYT.
the class BlockEntityFurnace method toCompound.
@Override
public NbtMapBuilder toCompound() {
NbtMapBuilder builder = super.toCompound();
List<NbtMap> itemsCompoundList = new ArrayList<>();
for (int slot = 0; slot < this.furnaceInventory.getSize(); slot++) {
NbtMapBuilder itemCompound = NbtMap.builder();
Item item = this.furnaceInventory.getItem(slot);
itemCompound.putByte("Slot", (byte) slot);
this.fromItem(item, itemCompound);
itemsCompoundList.add(itemCompound.build());
}
builder.putList("Items", NbtType.COMPOUND, itemsCompoundList);
return builder;
}
use of com.nukkitx.nbt.NbtMap in project JukeboxMC by LucGamesYT.
the class BlockEntityFurnace 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.furnaceInventory.addItem(item, false);
} else {
this.furnaceInventory.setItem(slot, item, false);
}
}
}
use of com.nukkitx.nbt.NbtMap in project JukeboxMC by LucGamesYT.
the class BlockUndyedShulkerBox method toItem.
@Override
public ItemUndyedShulkerBox toItem() {
ItemUndyedShulkerBox itemShulkerBox = new ItemUndyedShulkerBox();
BlockEntityShulkerBox blockEntity = this.getBlockEntity();
if (blockEntity == null) {
return itemShulkerBox;
}
ShulkerBoxInventory shulkerBoxInventory = blockEntity.getShulkerBoxInventory();
NbtMapBuilder builder = NbtMap.builder();
List<NbtMap> itemsCompoundList = new ArrayList<>();
for (int slot = 0; slot < shulkerBoxInventory.getSize(); slot++) {
Item item = shulkerBoxInventory.getItem(slot);
if (item != null && !(item instanceof ItemAir)) {
NbtMapBuilder itemCompound = NbtMap.builder();
itemCompound.putByte("Slot", (byte) slot);
blockEntity.fromItem(item, itemCompound);
itemsCompoundList.add(itemCompound.build());
}
}
builder.putList("Items", NbtType.COMPOUND, itemsCompoundList);
itemShulkerBox.setNBT(builder.build());
return itemShulkerBox;
}
use of com.nukkitx.nbt.NbtMap in project JukeboxMC by LucGamesYT.
the class BlockShulkerBox method toItem.
@Override
public ItemShulkerBox toItem() {
ItemShulkerBox itemShulkerBox = new ItemShulkerBox(this.runtimeId);
BlockEntityShulkerBox blockEntity = this.getBlockEntity();
if (blockEntity == null) {
return itemShulkerBox;
}
ShulkerBoxInventory shulkerBoxInventory = blockEntity.getShulkerBoxInventory();
NbtMapBuilder builder = NbtMap.builder();
List<NbtMap> itemsCompoundList = new ArrayList<>();
for (int slot = 0; slot < shulkerBoxInventory.getSize(); slot++) {
Item item = shulkerBoxInventory.getItem(slot);
if (item != null && !(item instanceof ItemAir)) {
NbtMapBuilder itemCompound = NbtMap.builder();
itemCompound.putByte("Slot", (byte) slot);
blockEntity.fromItem(item, itemCompound);
itemsCompoundList.add(itemCompound.build());
}
}
builder.putList("Items", NbtType.COMPOUND, itemsCompoundList);
itemShulkerBox.setNBT(builder.build());
return itemShulkerBox;
}
Aggregations