How to separately gate certain items from a mod
SheReyy opened this issue ยท 1 comments
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(item:immersiveengineering:cokebrick, "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(item:tconstruct:tinkers_anvil, "era_2");
worked just fine. Also, it doesn't work if I reverse those two lines. Is this a bug?
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.
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.