Jump to content

Hooking to Criteria Triggers?


Lyinginbedmon

Recommended Posts

In the vanilla code there's nearly 30 different criteria triggers that are natively updated and managed and almost none of them also connect to events. At a rough estimate, maybe 21 of them could be replicated using Forge events but this would be impractical and laggy in the extreme. However, the criteria triggers will only add listeners from the PlayerAdvancements class.

 

Criteria seem like a really configurable way of adding special effects and such, but is there any way to use them for more than just add new advancements given this hard-coded restriction?

Link to comment
Share on other sites

What is your use-case here?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

6 minutes ago, Draco18s said:

What is your use-case here?

I can see a number of possible contexts it'd be useful but I ran into this issue trying to make a progression system similar to that of Witchery's vampirism and lycanthropy, but able to configured with the same triggers of advancements.

 

Users provide a config/data pack file with a given "pact" contained within it, it gets broken down into tiers and each is accessed in turn based on given criteria. Just about every step of it I can already implement, but I'm flummoxed by how to interface it with the criteria triggers.

Edited by Lyinginbedmon
Link to comment
Share on other sites

You'd have to see how Advancements uses them, I'm pretty sure you can utilize the existing systems for your own use.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

12 hours ago, Draco18s said:

You'd have to see how Advancements uses them, I'm pretty sure you can utilize the existing systems for your own use.

This much I've already ascertained, more or less.

 

  • Criteria Triggers are held as static final values in the CriteriaTriggers class, each as their own class (ImpossibleTrigger, KilledTrigger, TickTrigger, etc.) and not as a generic.
  • The vanilla code then directly triggers them whenever they are needed, and they update a list of attached listeners when they are so updated.
  • Listeners are added to each trigger via the AddListener method specified in ICriterionTrigger (which only declares 3 methods: addListener, removeListener, and removeAllListeners). This method (and all methods in ICriterionTrigger) requires a PlayerAdvancements input value to register the listener in a hashmap.

 

My problem is finding a way to add a listener to the criteria without using advancements, because no other route seems evident, but so far I've not found anything. I could theoretically extend from PlayerAdvancements, but that's about 500 lines of code that I'm not dreadfully sure of the operation.

Edited by Lyinginbedmon
Link to comment
Share on other sites

Use player.getAdvancements() as your PlayerAdvancements object. The way trigger works is that trigger is passed a player and calls getAdvancements on it in order to get all the listeners. You'll have to do that for every player that joins the server (and call remove when they leave).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

17 hours ago, Draco18s said:

Use player.getAdvancements() as your PlayerAdvancements object. The way trigger works is that trigger is passed a player and calls getAdvancements on it in order to get all the listeners. You'll have to do that for every player that joins the server (and call remove when they leave).

Unfortunately the trouble doesn't just end there, as the Listener we have to manage also requires an Advancement object and makes active use of the value (so we can't just feed it a null). One feasible solution would be to creatively generate dummy advancements but that could cause some considerable bloat in the advancement screen.

	private static final Criterion testCriteria;
	private static final Listener testListener;

	/** Add listeners on login */
	@SideOnly(Side.SERVER)
	@SubscribeEvent
	public void onPlayerLogin(PlayerLoggedInEvent event)
	{
		EntityPlayerMP player = (EntityPlayerMP)event.player;
		PlayerAdvancements advancements = player.getAdvancements();
		CriteriaTriggers.PLAYER_KILLED_ENTITY.addListener(advancements, testListener);
	}
	
	/** Remove listeners on logout */
	@SideOnly(Side.SERVER)
	@SubscribeEvent
	public void onPlayerLogout(PlayerLoggedOutEvent event)
	{
		EntityPlayerMP player = (EntityPlayerMP)event.player;
		PlayerAdvancements advancements = player.getAdvancements();
		CriteriaTriggers.PLAYER_KILLED_ENTITY.removeListener(advancements, testListener);
	}
	
	static
	{
		testCriteria = PactHandler.getPact(new ResourceLocation(Reference.ModInfo.MOD_ID, "feyWitch")).getTiers()[1].getCriteria().get("vax");
		testListener = new ICriterionTrigger.Listener(testCriteria.getCriterionInstance(), null, "vax");
	}

In this quick test example, the criteria (under the name "vax") being added is to kill 1 pig, retrieved from what I've already assembled for a configurable JSON folder.

Edited by Lyinginbedmon
Link to comment
Share on other sites

Hmm, not sure then. I've not tried to do something like this.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Selamat datang di OLXTOTO, situs slot gacor terpanas yang sedang booming di industri perjudian online. Jika Anda mencari pengalaman bermain yang luar biasa, maka OLXTOTO adalah tempat yang tepat untuk Anda. Dapatkan sensasi tidak biasa dengan variasi slot online terlengkap dan peluang memenangkan jackpot slot maxwin yang sering. Di sini, Anda akan merasakan keseruan yang luar biasa dalam bermain judi slot. DAFTAR OLXTOTO DISINI LOGIN OLXTOTO DISINI AKUN PRO OLXTOTO DISINI   Slot Gacor untuk Sensasi Bermain Maksimal Olahraga cepat dan seru dengan slot gacor di OLXTOTO. Rasakan sensasi bermain maksimal dengan mesin slot yang memberikan kemenangan beruntun. Temukan keberuntungan Anda di antara berbagai pilihan slot gacor yang tersedia dan rasakan kegembiraan bermain judi slot yang tak terlupakan. Situs Slot Terpercaya dengan Pilihan Terlengkap OLXTOTO adalah situs slot terpercaya yang menawarkan pilihan terlengkap dalam perjudian online. Nikmati berbagai genre dan tema slot online yang menarik, dari slot klasik hingga slot video yang inovatif. Dipercaya oleh jutaan pemain, OLXTOTO memberikan pengalaman bermain yang aman dan terjamin.   Jackpot Slot Maxwin Sering Untuk Peluang Besar Di OLXTOTO, kami tidak hanya memberikan hadiah slot biasa, tapi juga memberikan kesempatan kepada pemain untuk memenangkan jackpot slot maxwin yang sering. Dengan demikian, Anda dapat meraih keberuntungan besar dan memenangkan ribuan rupiah sebagai hadiah jackpot slot maxwin kami. Jackpot slot maxwin merupakan peluang besar bagi para pemain judi slot untuk meraih keuntungan yang lebih besar. Dalam permainan kami, Anda tidak harus terpaku pada kemenangan biasa saja. Kami hadir dengan jackpot slot maxwin yang sering, sehingga Anda memiliki peluang yang lebih besar untuk meraih kemenangan besar dengan hadiah yang menggiurkan. Dalam permainan judi slot, pengalaman bermain bukan hanya tentang keseruan dan hiburan semata. Kami memahami bahwa para pemain juga menginginkan kesempatan untuk meraih keberuntungan besar. Oleh karena itu, OLXTOTO hadir dengan jackpot slot maxwin yang sering untuk memberikan peluang besar kepada para pemain kami. Peluang Besar Menang Jackpot Slot Maxwin Peluang menang jackpot slot maxwin di OLXTOTO sangatlah besar. Anda tidak perlu khawatir tentang batasan atau pembatasan dalam meraih jackpot tersebut. Kami ingin memberikan kesempatan kepada semua pemain kami untuk merasakan sensasi menang dalam jumlah yang luar biasa. Jackpot slot maxwin kami dibuka untuk semua pemain judi slot di OLXTOTO. Anda memiliki peluang yang sama dengan pemain lainnya untuk memenangkan hadiah jackpot yang besar. Kami percaya bahwa semua orang memiliki kesempatan untuk meraih keberuntungan besar, dan itulah mengapa kami menyediakan jackpot slot maxwin yang sering untuk memenuhi harapan dan keinginan Anda.  
    • LOGIN DAN DAFTAR DISINI SEKARANG !!!! Blacktogel adalah situs judi slot online yang menjadi pilihan banyak penggemar judi slot gacor di Indonesia. Dengan platform yang sangat user-friendly dan berbagai macam permainan slot yang tersedia, Blacktogel menjadi tempat yang tepat untuk penggemar judi slot online. Dalam artikel ini, kami akan membahas tentang Blacktogel dan keunggulan situs slot gacor online yang disediakan.  
    • Situs bandar slot online Gacor dengan bonus terbesar saat ini sedang menjadi sorotan para pemain judi online. Dengan persaingan yang semakin ketat dalam industri perjudian online, pemain mencari situs yang tidak hanya menawarkan permainan slot yang gacor (sering memberikan kemenangan), tetapi juga bonus terbesar yang bisa meningkatkan peluang menang. Daftar disini : https://gesit.io/googlegopek
    • Situs bandar slot online Gacor dengan bonus terbesar saat ini sedang menjadi sorotan para pemain judi online. Dengan persaingan yang semakin ketat dalam industri perjudian online, pemain mencari situs yang tidak hanya menawarkan permainan slot yang gacor (sering memberikan kemenangan), tetapi juga bonus terbesar yang bisa meningkatkan peluang menang. Daftar disini : https://gesit.io/googlegopek
    • Situs bandar slot online Gacor dengan bonus terbesar saat ini sedang menjadi sorotan para pemain judi online. Dengan persaingan yang semakin ketat dalam industri perjudian online, pemain mencari situs yang tidak hanya menawarkan permainan slot yang gacor (sering memberikan kemenangan), tetapi juga bonus terbesar yang bisa meningkatkan peluang menang. Daftar disini : https://gesit.io/googlegopek
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.