Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: Add hooks to API enabling addons to selectively toggle visibility of overlay elements #640

Open
Endgineer opened this issue Sep 8, 2023 · 5 comments

Comments

@Endgineer
Copy link

Endgineer commented Sep 8, 2023

Describe the new feature.

It would be nice to have the option to only show certain elements of the overall JourneyMap overlay IFF a player has certain items (might be from external mods, ideally specified by modid:itemid through configs) in their inventory (preferably should also check curio slots, which would also be a request to support curios in this feature).

For example, I hope to be able to do the following:

  • Show XYZ Coordinates IFF hasCompass
  • Show Time of Day IFF hasClock
  • Show Current Biome IFF hasNaturesCompass

Images

No response

@mysticdrew
Copy link
Member

mysticdrew commented Sep 9, 2023

Sorry, this is not something I will add to journeymap itself.
However, it may be something that I could add hooks into the API for other mods to implement. Like GameStages or another specific addon.

Also note, journeymap for mc 1.18.x is no longer in development. Only 1.20.1+ versions.

@Endgineer
Copy link
Author

Yeah, I was wondering if this was out of scope and I guess it is. Understandable.

Though the API hooks would probably be nice; giving the community the ability to create addons for JourneyMap controlling when certain elements of the overlay are shown/hidden, I mean.

Apologies about the version; it's been a while. It makes sense that 1.18 would be abandoned by lots of mods by now.

@Endgineer Endgineer changed the title [Feature Request | 1.18.2]: Make certain overlay elements conditional on items [Feature Request]: Make certain overlay elements conditional on items Sep 9, 2023
@mysticdrew
Copy link
Member

mysticdrew commented Sep 11, 2023

Someone just sent me some KubeJS scripts for disabling the minimap. This could also be used for what you want, KubeJS is a mod that you can use to modify other mods by using a javascript.
client_script.js

onEvent('client.tick', e => {
	if (e.level.time % 5 == 0.0) { // we could have this be more or less frequent if we wanted
	if (Client.player && Client.player.stages.has('journeymap')) {
		//global.JMmanager.setMiniMapEnabled(true);
		// If this is toggled, mini map will always be active
	}
	else {
		global.JMmanager.setMiniMapEnabled(false);
		global.JMwaypoints.getAll().forEach(point => {
			point.setEnable(false);
			point.setDirty();
		})
	}}
})

startup_script.js

const $JMFS = java('journeymap.client.ui.fullscreen.Fullscreen')
const $JMWE = java('journeymap.client.ui.waypoint.WaypointEditor')
const $JMWM = java('journeymap.client.ui.waypoint.WaypointManager')

console.info('Limiting Journeymap...')
onEvent('client.logged_in', e => {
	const $JMM = java('journeymap.client.ui.UIManager')
	const $JMW = java('journeymap.client.waypoint.WaypointStore')

	global.JMmanager = $JMM.INSTANCE
	global.JMwaypoints = $JMW.INSTANCE

	if (Client.player && !Client.player.stages.has('journeymap')) {
	global.JMmanager.setMiniMapEnabled(false); // No mini map for u :(

	global.JMwaypoints.getAll().forEach(point => {
		point.setEnable(false); // This makes waypoints invisible since they can still be shared/created on death
		point.setDirty(); // We need this to force a refresh of waypoints so that they're hidden
	})
}})

onForgeEvent('net.minecraftforge.client.event.ScreenOpenEvent', e => {
        // We check for e.screen and Client.player otherwise we get an error during startup when neither exist yet
	if (e.screen && Client.player && !Client.player.stages.has('journeymap')) {
		if (e.screen instanceof $JMFS || e.screen instanceof $JMWE || e.screen instanceof $JMWM) e.setCanceled(true);
}})

If you want to attempt to modify this for your needs, come into our discord and I help you with the hooks in JM that are needed to disable/enable JM things.

@Endgineer
Copy link
Author

Had no clue this was possible. I probably wont do this anytime soon, but when I decide to, I'll be sure to pass by. Thanks!

Can I close this issue?

@mysticdrew
Copy link
Member

No, let's leave it open to remind to add hooks for things in our api.

@Endgineer Endgineer changed the title [Feature Request]: Make certain overlay elements conditional on items [Feature Request]: Add hooks to API enabling addons to selectively toggle visibility of overlay elements Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants