use of com.minecolonies.api.colony.IColonyManager in project minecolonies by Minecolonies.
the class ColonyBorderMapping method updateChunk.
/**
* Flags the colony border overlay for update, if needed for a single just-loaded chunk.
*
* @param jmap The JourneyMap API
* @param dimension The dimension of the world. Nothing happens unless this is the client world.
* @param chunk The chunk that was just loaded.
*/
public static void updateChunk(@NotNull final Journeymap jmap, @NotNull final RegistryKey<World> dimension, @NotNull final Chunk chunk) {
final World world = Minecraft.getInstance().level;
if (world == null || !dimension.equals(world.dimension()))
return;
final Map<Integer, ColonyBorderOverlay> dimensionOverlays = overlays.get(dimension);
// not ready yet
if (dimensionOverlays == null)
return;
boolean changed = false;
final int id = getOwningColonyForChunk(chunk);
if (id == 0) {
for (final Map<Integer, ColonyBorderOverlay> overlayMap : overlays.values()) {
for (final ColonyBorderOverlay overlay : overlayMap.values()) {
changed |= overlay.updateChunks(Collections.emptySet(), Collections.singleton(chunk.getPos()));
}
}
} else {
final IColonyManager colonyManager = MinecoloniesAPIProxy.getInstance().getColonyManager();
final IColonyView colony = colonyManager.getColonyView(id, dimension);
final ColonyBorderOverlay overlay = dimensionOverlays.computeIfAbsent(id, k -> new ColonyBorderOverlay(dimension, id));
changed |= overlay.updateChunks(Collections.singleton(chunk.getPos()), Collections.emptySet());
changed |= overlay.updateInfo(colony, JourneymapOptions.getShowColonyName(jmap.getOptions()));
}
}
use of com.minecolonies.api.colony.IColonyManager in project minecolonies by ldtteam.
the class ColonyBorderMapping method updateChunk.
/**
* Flags the colony border overlay for update, if needed for a single just-loaded chunk.
*
* @param jmap The JourneyMap API
* @param dimension The dimension of the world. Nothing happens unless this is the client world.
* @param chunk The chunk that was just loaded.
*/
public static void updateChunk(@NotNull final Journeymap jmap, @NotNull final RegistryKey<World> dimension, @NotNull final Chunk chunk) {
final World world = Minecraft.getInstance().level;
if (world == null || !dimension.equals(world.dimension()))
return;
final Map<Integer, ColonyBorderOverlay> dimensionOverlays = overlays.get(dimension);
// not ready yet
if (dimensionOverlays == null)
return;
boolean changed = false;
final int id = getOwningColonyForChunk(chunk);
if (id == 0) {
for (final Map<Integer, ColonyBorderOverlay> overlayMap : overlays.values()) {
for (final ColonyBorderOverlay overlay : overlayMap.values()) {
changed |= overlay.updateChunks(Collections.emptySet(), Collections.singleton(chunk.getPos()));
}
}
} else {
final IColonyManager colonyManager = MinecoloniesAPIProxy.getInstance().getColonyManager();
final IColonyView colony = colonyManager.getColonyView(id, dimension);
final ColonyBorderOverlay overlay = dimensionOverlays.computeIfAbsent(id, k -> new ColonyBorderOverlay(dimension, id));
changed |= overlay.updateChunks(Collections.singleton(chunk.getPos()), Collections.emptySet());
changed |= overlay.updateInfo(colony, JourneymapOptions.getShowColonyName(jmap.getOptions()));
}
}
Aggregations