Darkhax-Minecraft / ItemStages

Allows items to be put into stages.
GNU Lesser General Public License v2.1
7 stars 18 forks source link

How to separately gate certain items from a mod #67

Closed SheReyy closed 3 years ago

SheReyy commented 3 years ago

How do you gate items from a mod separately from the mod itself? I'm trying to gate Immersive Engineering behind a stage, with some items from it, being gated to another stage. Here's what I tried:

// ItemStages.createModRestriction("immersiveengineering", "era_2"); // ItemStages.restrict(, "era_1");

This does not work. The Coke Brick stays gated to "era_2". Which is very odd, because this:

// ItemStages.createModRestriction("tconstruct", "era_1"); // ItemStages.restrict(, "era_2");

worked just fine. Also, it doesn't work if I reverse those two lines. Is this a bug?

Darkhax commented 3 years ago

There is no way to unstage or restage an item once you have staged it in your script. As the documentation for this method states.

Keep in mind that all items from that mod will be staged and you can not unstage or remove specific ones using this method.

This limitation exists because the restriction is checking the ID of the item as needed rather than creating a set of all possible items in advance. This approach is much more reliable and can lead to better performance. In your case you would want to create a new item tag and then loop over the mod's items and add the ones you do/don't want. Then simply stage that tag. There are discussions on ways to make this easier in the future, however there is nothing in CraftTweaker or ItemStages to simplify this yet.

The behavior you are experiencing with tconstruct and immersiveengineering is due to misusing the restriction system. You are not meant to create more than one restriction for a given item and there is no guarantee that they will load in the same order every time. The tconstruct restriction is loading in the order you expected it to, while the immersiveengineering restrictions are not.