Search in sources :

Example 1 with AbstractData

use of hellfirepvp.astralsorcery.common.data.sync.base.AbstractData in project AstralSorcery by HellFirePvP.

the class SyncDataHolder method tick.

@Override
public void tick(TickEvent.Type type, Object... context) {
    if (dirtyData.isEmpty()) {
        return;
    }
    Map<ResourceLocation, CompoundNBT> pktData = new HashMap<>();
    synchronized (lck) {
        for (ResourceLocation key : dirtyData) {
            AbstractData dat = serverData.get(key);
            if (dat != null) {
                CompoundNBT nbt = new CompoundNBT();
                dat.writeDiffDataToPacket(nbt);
                pktData.put(key, nbt);
            }
        }
        dirtyData.clear();
    }
    PktSyncData dataSync = new PktSyncData(pktData);
    PacketChannel.CHANNEL.sendToAll(dataSync);
}
Also used : AbstractData(hellfirepvp.astralsorcery.common.data.sync.base.AbstractData) CompoundNBT(net.minecraft.nbt.CompoundNBT) PktSyncData(hellfirepvp.astralsorcery.common.network.play.server.PktSyncData) ResourceLocation(net.minecraft.util.ResourceLocation)

Aggregations

AbstractData (hellfirepvp.astralsorcery.common.data.sync.base.AbstractData)1 PktSyncData (hellfirepvp.astralsorcery.common.network.play.server.PktSyncData)1 CompoundNBT (net.minecraft.nbt.CompoundNBT)1 ResourceLocation (net.minecraft.util.ResourceLocation)1