use of com.minecolonies.api.colony.IVisitorData in project minecolonies by ldtteam.
the class VisitorManager method sendPackets.
@Override
public void sendPackets(@NotNull final Set<ServerPlayerEntity> closeSubscribers, @NotNull final Set<ServerPlayerEntity> newSubscribers) {
Set<ServerPlayerEntity> players = new HashSet<>(newSubscribers);
players.addAll(closeSubscribers);
Set<IVisitorData> toSend = new HashSet<>();
boolean refresh = !newSubscribers.isEmpty() || this.isDirty;
if (refresh) {
toSend = new HashSet<>(visitorMap.values());
for (final IVisitorData data : visitorMap.values()) {
data.clearDirty();
}
this.clearDirty();
} else {
for (final IVisitorData data : visitorMap.values()) {
if (data.isDirty()) {
toSend.add(data);
}
data.clearDirty();
}
}
if (toSend.isEmpty()) {
return;
}
final ColonyVisitorViewDataMessage message = new ColonyVisitorViewDataMessage(colony, toSend, refresh);
for (final ServerPlayerEntity player : players) {
Network.getNetwork().sendToPlayer(message, player);
}
}
use of com.minecolonies.api.colony.IVisitorData in project minecolonies by ldtteam.
the class VisitorData method loadVisitorFromNBT.
/**
* Loads this citizen data from nbt
*
* @param colony colony to load for
* @param nbt nbt compound to read from
* @return new CitizenData
*/
public static IVisitorData loadVisitorFromNBT(final IColony colony, final CompoundNBT nbt) {
final IVisitorData data = new VisitorData(nbt.getInt(TAG_ID), colony);
data.deserializeNBT(nbt);
return data;
}
use of com.minecolonies.api.colony.IVisitorData in project AdvancedPeripherals by Seniorendi.
the class ColonyPeripheral method getVisitors.
@LuaFunction(mainThread = true)
public final Object getVisitors() throws LuaException {
IColony colony = getColony();
List<Object> list = new ArrayList<>();
for (ICivilianData civilian : colony.getVisitorManager().getCivilianDataMap().values()) {
if (!(civilian instanceof IVisitorData))
continue;
list.add(MineColonies.visitorToObject((IVisitorData) civilian));
}
return list;
}
Aggregations