use of journeymap.client.api.display.Waypoint in project Geolosys by oitsjustjose.
the class ForgeEventListener method registerEvent.
@SubscribeEvent
public void registerEvent(RightClickBlock event) {
try {
IBlockState state = event.getWorld().getBlockState(event.getPos());
if (state.getBlock() == Geolosys.getInstance().ORE_SAMPLE || state.getBlock() == Geolosys.getInstance().ORE_SAMPLE_VANILLA) {
if (event.getEntityPlayer().isSneaking() && event.getWorld().isRemote) {
if (jmAPI.playerAccepts(Lib.MODID, DisplayType.Waypoint)) {
String name = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)).getDisplayName();
String id = Lib.MODID + " - " + name + " - " + event.getWorld().getChunkFromBlockCoords(event.getPos()).getPos();
try {
jmAPI.show(new Waypoint(Lib.MODID, id, name, event.getWorld().provider.getDimension(), event.getPos()));
} catch (Throwable t) {
Geolosys.getInstance().LOGGER.info(t.getMessage());
}
}
}
}
} catch (NullPointerException ignored) {
}
}
use of journeymap.client.api.display.Waypoint in project minecolonies by Minecolonies.
the class ColonyDeathpoints method updateGraves.
/**
* Synchronise the list of currently-existing graves in the colony.
* (Can be called when there is no change.)
*
* @param jmap The JourneyMap API
* @param colony The colony.
* @param graves The list of grave positions.
*/
public static void updateGraves(@NotNull final Journeymap jmap, @NotNull final IColonyView colony, @NotNull final Set<BlockPos> graves) {
final Map<BlockPos, Waypoint> waypoints = overlays.computeIfAbsent(colony.getDimension(), k -> new HashMap<>()).computeIfAbsent(colony.getID(), k -> new HashMap<>());
final boolean permitted = colony.getPermissions().hasPermission(Minecraft.getInstance().player, Action.MAP_DEATHS) && JourneymapOptions.getDeathpoints(jmap.getOptions());
final Iterator<Map.Entry<BlockPos, Waypoint>> iterator = waypoints.entrySet().iterator();
while (iterator.hasNext()) {
final Map.Entry<BlockPos, Waypoint> waypointEntry = iterator.next();
if (!permitted || !graves.contains(waypointEntry.getKey())) {
if (waypointEntry.getValue() != null) {
jmap.getApi().remove(waypointEntry.getValue());
}
iterator.remove();
}
}
if (permitted) {
for (final BlockPos grave : graves) {
waypoints.computeIfAbsent(grave, k -> tryCreatingWaypoint(jmap, colony, k));
}
}
}
use of journeymap.client.api.display.Waypoint in project minecolonies by Minecolonies.
the class ColonyDeathpoints method tryCreatingWaypoint.
@Nullable
private static Waypoint tryCreatingWaypoint(@NotNull final Journeymap jmap, @NotNull final IColonyView colony, @NotNull final IChunk chunk, @NotNull final BlockPos pos) {
if (!jmap.getApi().playerAccepts(MOD_ID, DisplayType.Waypoint))
return null;
final TileEntity blockEntity = chunk.getBlockEntity(pos);
if (blockEntity instanceof AbstractTileEntityGrave) {
final IGraveData grave = ((AbstractTileEntityGrave) blockEntity).getGraveData();
if (grave != null) {
final String text = grave.getCitizenJobName() == null ? LanguageHandler.format(COM_MINECOLONIES_JMAP_PREFIX + "deathpoint_name", grave.getCitizenName()) : LanguageHandler.format(COM_MINECOLONIES_JMAP_PREFIX + "deathpoint_namejob", grave.getCitizenName(), grave.getCitizenJobName());
final Waypoint waypoint = new Waypoint(MOD_ID, text, colony.getDimension(), pos);
waypoint.setEditable(true).setPersistent(false).setIcon(deathIcon.get()).setColor(0x888888);
jmap.show(waypoint);
return waypoint;
}
}
return null;
}
use of journeymap.client.api.display.Waypoint in project minecolonies by ldtteam.
the class ColonyDeathpoints method tryCreatingWaypoint.
@Nullable
private static Waypoint tryCreatingWaypoint(@NotNull final Journeymap jmap, @NotNull final IColonyView colony, @NotNull final IChunk chunk, @NotNull final BlockPos pos) {
if (!jmap.getApi().playerAccepts(MOD_ID, DisplayType.Waypoint))
return null;
final TileEntity blockEntity = chunk.getBlockEntity(pos);
if (blockEntity instanceof AbstractTileEntityGrave) {
final IGraveData grave = ((AbstractTileEntityGrave) blockEntity).getGraveData();
if (grave != null) {
final String text = grave.getCitizenJobName() == null ? LanguageHandler.format(COM_MINECOLONIES_JMAP_PREFIX + "deathpoint_name", grave.getCitizenName()) : LanguageHandler.format(COM_MINECOLONIES_JMAP_PREFIX + "deathpoint_namejob", grave.getCitizenName(), grave.getCitizenJobName());
final Waypoint waypoint = new Waypoint(MOD_ID, text, colony.getDimension(), pos);
waypoint.setEditable(true).setPersistent(false).setIcon(deathIcon.get()).setColor(0x888888);
jmap.show(waypoint);
return waypoint;
}
}
return null;
}
use of journeymap.client.api.display.Waypoint in project minecolonies by ldtteam.
the class ColonyDeathpoints method updateGraves.
/**
* Synchronise the list of currently-existing graves in the colony.
* (Can be called when there is no change.)
*
* @param jmap The JourneyMap API
* @param colony The colony.
* @param graves The list of grave positions.
*/
public static void updateGraves(@NotNull final Journeymap jmap, @NotNull final IColonyView colony, @NotNull final Set<BlockPos> graves) {
final Map<BlockPos, Waypoint> waypoints = overlays.computeIfAbsent(colony.getDimension(), k -> new HashMap<>()).computeIfAbsent(colony.getID(), k -> new HashMap<>());
final boolean permitted = colony.getPermissions().hasPermission(Minecraft.getInstance().player, Action.MAP_DEATHS) && JourneymapOptions.getDeathpoints(jmap.getOptions());
final Iterator<Map.Entry<BlockPos, Waypoint>> iterator = waypoints.entrySet().iterator();
while (iterator.hasNext()) {
final Map.Entry<BlockPos, Waypoint> waypointEntry = iterator.next();
if (!permitted || !graves.contains(waypointEntry.getKey())) {
if (waypointEntry.getValue() != null) {
jmap.getApi().remove(waypointEntry.getValue());
}
iterator.remove();
}
}
if (permitted) {
for (final BlockPos grave : graves) {
waypoints.computeIfAbsent(grave, k -> tryCreatingWaypoint(jmap, colony, k));
}
}
}
Aggregations