use of net.minecraft.util.io.CompoundTag in project StationAPI by ModificationStation.
the class TileEntityFreezer method readIdentifyingData.
@Override
public void readIdentifyingData(CompoundTag nbttagcompound) {
super.readIdentifyingData(nbttagcompound);
ListTag nbttaglist = nbttagcompound.getListTag("Items");
frozenItemStacks = new ItemInstance[getInventorySize()];
for (int i = 0; i < nbttaglist.size(); i++) {
CompoundTag nbttagcompound1 = (CompoundTag) nbttaglist.get(i);
byte byte0 = nbttagcompound1.getByte("Slot");
if (byte0 >= 0 && byte0 < frozenItemStacks.length) {
frozenItemStacks[byte0] = new ItemInstance(nbttagcompound1);
}
}
frozenProgress = nbttagcompound.getShort("BurnTime");
frozenTimeForItem = nbttagcompound.getShort("CookTime");
}
use of net.minecraft.util.io.CompoundTag in project StationAPI by ModificationStation.
the class TileEntityFreezer method writeIdentifyingData.
@Override
public void writeIdentifyingData(CompoundTag nbttagcompound) {
super.writeIdentifyingData(nbttagcompound);
nbttagcompound.put("BurnTime", (short) frozenProgress);
nbttagcompound.put("CookTime", (short) frozenTimeForItem);
ListTag nbttaglist = new ListTag();
for (int i = 0; i < frozenItemStacks.length; i++) {
if (frozenItemStacks[i] != null) {
CompoundTag nbttagcompound1 = new CompoundTag();
nbttagcompound1.put("Slot", (byte) i);
frozenItemStacks[i].toTag(nbttagcompound1);
nbttaglist.add(nbttagcompound1);
}
}
nbttagcompound.put("Items", nbttaglist);
}
use of net.minecraft.util.io.CompoundTag in project StationAPI by ModificationStation.
the class NBTItem method useOnTile.
@Override
public boolean useOnTile(ItemInstance item, PlayerBase player, Level level, int x, int y, int z, int facing) {
CompoundTag nbt = StationNBT.cast(item).getStationNBT();
if (!nbt.containsKey(of(MODID, "rand_num").toString()))
nbt.put(of(MODID, "rand_num").toString(), new Random().nextInt(3));
player.sendMessage("Woah: " + nbt.getInt(of(MODID, "rand_num").toString()));
return true;
}
use of net.minecraft.util.io.CompoundTag in project StationAPI by ModificationStation.
the class ServerRegistrySender method sendLevelRegistry.
@EventListener(priority = ListenerPriority.HIGH)
private static void sendLevelRegistry(PlayerPacketHandlerSetEvent event) {
if (((ModdedPacketHandler) event.player.packetHandler).isModded()) {
LOGGER.info("Sending level registries to \"" + event.player.name + "\"...");
CompoundTag registries = new CompoundTag();
LevelSerialRegistry.saveAll(registries);
ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
NBTIO.writeGzipped(registries, byteOutputStream);
Message message = new Message(of(MODID, "server_registry_sync"));
message.bytes = byteOutputStream.toByteArray();
PacketHelper.sendTo(event.player, message);
}
}
Aggregations