Jump to content

Recommended Posts

Posted

Hello again,

I have finally gotten my advancements to work but now i need a functionality that im not sure exists.  I have an item that has an integer stored in its nbt and i would like my advancement to trigger when it is above a certain value.  Under some circumstances i could just list every number above the number i want but since the number can range from 0 to 100 that would not be reasonable.  So my question is how can i trigger the advancement when said value is greater than a certain amount.

Posted

In the code that modifies that integer (I mean...you wrote it...)...check to see if that integer is greater than the desired number and if so, give the player the advancement (check vanilla code for how to award advancements).

  • Like 1

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.

Posted
  On 8/19/2017 at 3:06 PM, Draco18s said:

In the code that modifies that integer (I mean...you wrote it...)...check to see if that integer is greater than the desired number and if so, give the player the advancement (check vanilla code for how to award advancements).

Expand  

Well i was hoping to have that as one requirement and another requirement if possible.  But if this is the only way to do it other than making a custom trigger or something then i will just split the advancement in half.

Posted

You should be able to extend ItemPredicate, override ItemPredicate#test and then register it with ItemPredicates.register.

 

You can then use this anywhere an item predicate is expected (e.g. in the inventory_changed trigger).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 8/19/2017 at 3:25 PM, Choonster said:

You should be able to extend ItemPredicate, override ItemPredicate#test and then register it with ItemPredicates.register.

 

You can then use this anywhere an item predicate is expected (e.g. in the inventory_changed trigger).

Expand  

Can you explain a bit more?  Im confused.

Posted
  On 8/19/2017 at 4:43 PM, drok0920 said:

Can you explain a bit more?  Im confused.

Expand  

 

Was there one part in particular that you didn't understand?

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 8/19/2017 at 4:48 PM, drok0920 said:

What is an item predicate and how do i use one.

Expand  

 

Item predicates are used by advancement criteria like inventory_changed to determine whether or not the item matches the requirements. The inventory_changed criterion will be met when all of the specified item predicates match the item in any slot of the player's inventory (i.e. the player has every required item).

 

The vanilla JSON format is documented on the wiki. For the inventory_changed criterion, each object in the items array is an item predicate.

 

If you set the type element of an item predicate to a string, Forge will use the custom ItemPredicate factory that was registered with that name (via ItemPredicates.register) instead of creating a vanilla ItemPredicate instance.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 8/19/2017 at 7:41 PM, drok0920 said:

Eclipse is saying that ItemPredicates is not a class so i am unable to register it.  Is it called something else now?

Expand  

ItemPredicate not ItemPredicates.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

I spent some time to figure out what Choonster is talking about but couldn't follow the code in a meaningful way. As mentioned, there is no ItemPredicates class and ItemPredicate doesn't have a register method. So I'm assuming that he's created his own custom factory or registry class that he calls ItemPredicates but for the life of me I can't see where the various JSON derserializer methods will look for custom ItemPredicates. So I guess we'll have to wait for Choonster to clarify what he's talking about -- he usually knows what he's talking about!

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

The ItemPredicates class was added in commit ee449e4 (version 1.12.1-14.22.0.2452). Make sure you're using the latest version of Forge.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 8/20/2017 at 4:29 AM, jabelar said:

Actually, I usually update from the Forge download site. The "latest" there is still 14.21.1.2443. Do you really recommend downloading from github instead or weiting until it is posted at the official download site?

Expand  

 

You're looking at 1.12 (the current recommended version), you need to go to the 1.12.1 page.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 8/21/2017 at 3:29 PM, drok0920 said:

How do i use the register method?  It asks for a function what should i give it?

Expand  

 

It needs a Function<JsonObject, ItemPredicate>, i.e. a function that takes a JsonObject and deserialises it into an ItemPredicate. You can implement this with a lambda, method reference (e.g. a constructor method reference) or an anonymous class.

 

Look at the static initialiser block in ItemPredicates and the OredictItemPredicate constructor it references for an example of this.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted (edited)

So i think i have gotten it to work but would this be how i use the predicate:

{
    "display": {
        "icon": {
            "item": "minecraft:stone"
        },
        "title": "Stone Age",
		"description": "Hunter - Gatherers"
    },
    "criteria": {
        "tick": {
            "trigger": "modid:predicateregistryname"
			{
				"item": "poverhaul:rock",
				"quality": 1
			}
        }
    }
}

Assuming that my predicate class is the fallowing:

	package net.drok.poverhaul.predicate;
	import javax.annotation.Nullable;
	import com.google.gson.JsonObject;
	import net.drok.poverhaul.ModRegistry;
import net.drok.poverhaul.item.ItemRock;
import net.minecraft.advancements.critereon.ItemPredicate;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.JsonUtils;
	public class ItemQualityPredicate extends ItemPredicate {
	    private final Item item;
    private final Integer quality;
    
    public ItemQualityPredicate(JsonObject jsonObject) {
        this(JsonUtils.getItem(jsonObject, "item"), JsonUtils.getInt(jsonObject, "quality"));
        
    }
	    public ItemQualityPredicate(@Nullable Item i, int q)
    {
        this.item = i;
        this.quality = q;
    }
    
    @Override
    public boolean test(ItemStack stack)
    {
        if(this.item != null && stack.getItem() == this.item) {
            ItemRock rock = (ItemRock) ModRegistry.rock;
            int q = rock.getQuality(stack);
            
            if(q >= this.quality) {
                return true;
            }
        } else if(stack.getItem() == this.item) {
            ItemRock rock = (ItemRock) ModRegistry.rock;
            int q = rock.getQuality(stack);
            
            if(q >= this.quality) {
                return true;
            }
        }
        return false;
    }
    
}
 
	

Edited by drok0920
Posted

What you've created is an item predicate, not a criterion trigger. You need to use an existing criterion trigger like inventory_changed but use your custom item predicate instead of the vanilla one.

 

As I said before, each object in the items array for the inventory_changed criterion is an item predicate. You need to set the type element of an item predicate object to the registry name of your custom item predicate.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted (edited)

So would this be correct:

 

{
    "display": {
        "icon": {
            "item": "minecraft:stick"
        },
        "title": "Sticks and Stones",
		"description": "Find your first basic materials scattered around your world."
    },
    "parent": "poverhaul:stoneage/sticks_and_stones",
    "criteria": {
		"rock": {
            "trigger": "minecraft:inventory_changed",
            "conditions": {
                "items": [
                    {
                        "item": "poverhaul:rock"
                    },
					{
						"type": "poverhaul:quality",
						"quality": 1
					}
                ]
            }
        }
    }
}

 

Edit:

I got a chance to test it and it works great.  Thank you for all your help!

Edited by drok0920

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

    • Looks like an issue with biomeswevegone
    • In the server.properties, set max-tick-time to -1   if there are further issues, make a test without distanthorizons
    • Verified user can get a $300 off TℰℳU Coupon code using the code ((“{{ '[''com31844'']}}”)). This TℰℳU $100Off code is specifically for new and existing customers both and can be redeemed to receive a $100discount on your purchase. Our exclusive TℰℳU Coupon code offers a flat $100off your purchase, plus an additional 100% discount on top of that. You can slash prices by up to $100as a new TℰℳU customer using code ((“{{ '[''com31844'']}}”)). Existing users can enjoy $100off their next haul with this code. But that’s not all! With our TℰℳU Coupon codes for 2025, you can get up to 90% discount on select items and clearance sales. Whether you’re a new customer or an existing shopper, our TℰℳU codes provide extra discounts tailored just for you. Save up to 100% with these current TℰℳU Coupons ["^"{{ '[''com31844'']}} "^"] for April 2025. The latest TℰℳU coupon codes at here. New users at TℰℳU receive a $100discount on orders over $100Use the code ((“{{ '[''com31844'']}}”)) during checkout to get TℰℳU Coupon $100Off For New Users. You can save $100Off your first order with the coupon code available for a limited time only. TℰℳU 90% Off promo code ((“{{ '[''com31844'']}}”)) will save you $100on your order. To get a discount, click on the item to purchase and enter the coe. Yes, offers $100Off coupon code “{{ '[''com31844'']}}” for first time users. You can get a $100bonus plus $100Off any purchase at TℰℳU with the $100Coupon Bundle at TℰℳU if you sign up with the referral code ((“{{ '[''com31844'']}}”)) and make a first purchase of $100or more. Free TℰℳU codes $100off — ((“{{ '[''com31844'']}}”)) Get a $100discount on your TℰℳU order with the promo code "{{ '[''com31844'']}}". You can get a discount by clicking on the item to purchase and entering this TℰℳU Coupon code $100off ((“{{ '[''com31844'']}}”)). ŢℰNew User Coupon ((“{{ '[''com31844'']}})): Up To $100OFF For First-Time Users Our TℰℳU first-time user coupon codes are designed just for new customers, offering the biggest discounts and the best deals currently available on TℰℳU To maximize your savings, download the TℰℳU app and apply our TℰℳU new user coupon during checkout. TℰℳU Coupon Codes For Existing Users ((“{{ '[''com31844'']}}”)): $100Price Slash Have you been shopping on TℰℳU or a while? Our TℰℳU Coupon for existing customers is here to reward you for your continued support, offering incredible discounts on your favorite products. TℰℳU Coupon For $100Off ((“{{ '[''com31844'']}}”)): Get A Flat $100Discount On Order Value Get ready to save big with our incredible TℰℳU Coupon for $100off! Our amazing ŢℰM$100off coupon code will give you a flat $100discount on your order value, making your shopping experience even more rewarding. TℰℳU Coupon Code For $100Off ((“{{ '[''com31844'']}}”)): For Both New And Existing Customers Our incredible TℰℳU Coupon code for $100off is here to help you save big on your purchases. Whether you’re a new user or an existing customer, our $100off code for TℰℳU will give you an additional discount! TℰℳU Coupon Bundle ((“{{ '[''com31844'']}}”)): Flat $100Off + Up To $100Discount Get ready for an unbelievable deal with our TℰℳU Coupon bundle for 2025! Our TℰℳU Coupon bundles will give you a flat $100discount and an additional $100off on top of it. Free TℰℳU Coupons ((“{{ '[''com31844'']}}”)): Unlock Unlimited Savings! Get ready to unlock a world of savings with our free TℰℳU Coupons! We’ve got you covered with a wide range of TℰℳU Coupon code options that will help you maximize your shopping experience. 100% Off TℰℳU Coupons, Promo Codes + 25% Cash Back ((“{{ '[''com31844'']}}”)) Redeem TℰℳU Coupon Code ((“{{ '[''com31844'']}}”)) TℰℳU Coupon $100OFF ((“{{ '[''com31844'']}}”)) TℰℳU Coupon $100OFF FOR EXISTING CUSTOMERS ((“{{ '[''com31844'']}}”)) TℰℳU Coupon $100OFF FIRST ORDER ((“{{ '[''com31844'']}}”)) TℰℳU Coupon $100OFF REDDIT ((“{{ '[''com31844'']}}”)) TℰℳU Coupon $100OFF FOR EXISTING CUSTOMERS REDDIT ((“{{ '[''com31844'']}}”)) TℰℳU $100OFF CODE ((“{{ '[''com31844'']}}”)) TℰℳU 70 OFF COUPON 2025 ((“{{ '[''com31844'']}}”)) DOMINOS 70 RS OFF COUPON CODE ((“{{ '[''com31844'']}}”)) WHAT IS A COUPON RATE ((“{{ '[''com31844'']}}”)) TℰℳU $100OFF FOR EXISTING CUSTOMERS ((“{{ '[''com31844'']}}”)) TℰℳU $100OFF FIRST ORDER ((“{{ '[''com31844'']}}”)) TℰℳU $100OFF FREE SHIPPING ((“{{ '[''com31844'']}}”)) You can get an exclusive $100off discount on your TℰℳU purchase with the code [{{ '[''com31844'']}}] Or [{{ '[''com31844'']}}].This code is specially designed for new customers and offers a significant price cut on your shopping. Make your first purchase on TℰℳU more rewarding by using this code to get $100off instantly.   TℰℳU Coupon Code For $100Off [{{ '[''com31844'']}}] Or [{{ '[''com31844'']}}]: Get A Flat $100Discount On Order Value Get ready to save big with our incredible TℰℳU coupon for $100off! Our coupon code will give you a flat $100discount on your order value, making your shopping experience even more rewarding.   Exclusive TℰℳU Discount Code [{{ '[''com31844'']}}] Or [{{ '[''com31844'']}}]: Flat $300 OFF for New and Existing Customers Using our TℰℳU promo code you can get A$ 200 off your order and 100% off using our TℰℳU promo code [{{ '[''com31844'']}}] Or [{{ '[''com31844'']}}]. As a new TℰℳU customer, you can save up to $100using this promo code. For returning users, our TℰℳU promo code offers a $100price slash on your next shopping spree. This is our way of saying thank you for shopping with us! Get ready to save big with our incredible TℰℳU Coupon code for $300 off! Our amazing TℰℳU $300 off coupon code will give you a flat $300 discount on your order value, making your shopping experience even more rewarding.   TℰℳU Coupon Code For 40% Off ["{com31844}"] For Both New And Existing Customers   Our incredible TℰℳU Coupon code for 40% off is here to help you save big on your purchases. Whether you’re a new user or an existing customer, our 40% off code for TℰℳU will give you an additional discount!   TℰℳU Coupon Bundle ["{com31844}"]: Flat $300 Off + Up To 90% Discount   Get ready for an unbelievable deal with our TℰℳU Coupon bundle for 2025! Our TℰℳU Coupon bundles will give you a flat $300 discount and an additional 40% off on top of it.   Free TℰℳU Coupons ["{com31844}"]: Unlock Unlimited Savings!   Get ready to unlock a world of savings with our free TℰℳU Coupons! We’ve got you covered with a wide range of TℰℳU Coupon code options that will help you maximize your shopping experience.   50% Off TℰℳU Coupons, Promo Codes + 25% Cash Back ["{com31844}"]   Redeem TℰℳU Coupon Code ["{com31844}"]   TℰℳU Coupon $300 OFF ["{com31844}"]   TℰℳU Coupon $300 OFF ["{com31844}"]   TℰℳU Coupon $300 OFF FOR EXISTING CUSTOMERS ["{com31844}"]   TℰℳU Coupon $300 OFF FIRST ORDER ["{com31844}"]   TℰℳU Coupon $300 OFF FIRST ORDER ["{com31844}"]   TℰℳU Coupon $300 OFF FOR EXISTING CUSTOMERS FREE SHIPPING USA ["{com31844}"]   TℰℳU Coupon $300 OFF HOW DOES IT WORK ["{com31844}"]   TℰℳU Coupon $300 OFF FOR EXISTING CUSTOMERS CANADA ["{com31844}"]   TℰℳU Coupon $300 OFF 2025 ["{com31844}"]   TℰℳU Coupon $300 OFF FOR NEW CUSTOMERS ["{com31844}"]   TℰℳU Coupon $300 OFF CANADA ["{com31844}"]   TℰℳU Coupon $300 OFF FOR EXISTING CUSTOMERS FIRST ORDER ["{com31844}"]   TℰℳU 300 OFF COUPON BUNDLE ["{com31844}"]   This TℰℳU coupon $300 off is designed to provide substantial savings on your purchases, making shopping for your favorite items easier than ever. With our $300 off TℰℳU coupon, you'll be amazed at how much you can save on your next order. Here are the key benefits you can expect when using our coupon code {com31844} "OR" {com31844}: {com31844} "OR" {com31844}: Flat $300 off on your purchase {com31844} "OR" {com31844}: $300 coupon pack for multiple uses {com31844} "OR" {com31844}: $300 flat discount for new customers {com31844} "OR" {com31844}: Extra $300 promo code for existing customers {com31844} "OR" {com31844}: $300 coupon exclusively for USA/Canada users H2: TℰℳU Coupon Code $300 Off For New Users In 2024 New users can reap the highest benefits by using our coupon code on the TℰℳU app. This TℰℳU coupon $300 off is specifically designed to welcome new customers with incredible savings  
    • Now the serve runs for a bit, then crashes after 20 minutes of running, what's the issue here? apologies if I need to start a new post and didn't https://pastebin.com/uBpp5bCz  
  • Topics

×
×
  • Create New...

Important Information

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