Jump to content

How to handle with a utility item that is meant to "contain" two other items?


Recommended Posts

Posted (edited)

Hello,
I added a utility item that is meant to "consists of" two other items. It's crafted like this:

GameRegistry.addShapelessRecipe(
	new ResourceLocation("modid:itemA_and_itemB_merge"), null,
	new ItemStack(ItemInit.ITEM_A_AND_ITEM_B, 2),
	Ingredient.fromItem(ItemInit.ITEM_A),
	Ingredient.fromItem(ItemInit.ITEM_B)
);

cr1.png

 

But I also want to make it uncraftable without any uncrafting table mod. I tried this:

GameRegistry.addShapelessRecipe(
	new ResourceLocation("modid:itemA_and_itemB_separate"), null,
	new ItemStack(ItemInit.ITEM_A, 1),
	Ingredient.fromItem(ItemInit.ITEM_A_AND_ITEM_B
		.setContainerItem(ItemInit.ITEM_B)),
	Ingredient.fromItem(ItemInit.ITEM_A_AND_ITEM_B)
);

Where only one ITEM_A_AND_ITEM_B is meant to change to ITEM_B after grabbing ITEM_A from the crafting output.

cr2.png

But instead, both of the ITEM_A_AND_ITEM_B-s change to IITEM_B...:

cr3.png


I also just noticed that the ITEM_A_AND_ITEM_B gets changed into ITEM_B after grabbing the output in every recipe that I've added
 

---

So, how can I make it work as I want?
Thanks in advance!

Edited by Xander402
+anotherBug

A few bytes about me:

public class Xander402 extends Modder implements IForumMember {
    int javaExperience, moddingExperience;
    LearningWay preferredLearningWay;
    public Xander402() {
        this.javaExperience = BIG;
        this.moddingExperience = NOT_SO_BIG;
        this.preferredLearningWay = LearningWay.through("exampes");
      	super(/*displayName*/"Xander402", /*moddingSince*/"1.9", preferredLearningWay);
    }
    @Override
    public Goal getReasonOfJoining(Forum forum) { return new Goal(() -> { while (true) moddingExperience++; }); }
}

 

Posted
37 minutes ago, Xander402 said:

Ingredient.fromItem(ItemInit.ITEM_A_AND_ITEM_B .setContainerItem(ItemInit.ITEM_B)),

Wow that's disgusting. This will permanently change the container item (until your recipe comes along and changes it again). Every other recipe using the item will return a copy. 

 

That is not how that was ever meant to be used. 

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 (edited)
7 minutes ago, Draco18s said:

That is not how that was ever meant to be used. 

Yeah, I know that too, because it simply does what you said:

7 minutes ago, Draco18s said:

This will permanently change the container item (until your recipe comes along and changes it again). Every other recipe using the item will return a copy. 

But I haven't found any other method for putting an item in the crafting grid after grabbing the output, that's just why I used setContainerItem(). I would be happy to know if there is one that would solve my problem.

Edited by Xander402

A few bytes about me:

public class Xander402 extends Modder implements IForumMember {
    int javaExperience, moddingExperience;
    LearningWay preferredLearningWay;
    public Xander402() {
        this.javaExperience = BIG;
        this.moddingExperience = NOT_SO_BIG;
        this.preferredLearningWay = LearningWay.through("exampes");
      	super(/*displayName*/"Xander402", /*moddingSince*/"1.9", preferredLearningWay);
    }
    @Override
    public Goal getReasonOfJoining(Forum forum) { return new Goal(() -> { while (true) moddingExperience++; }); }
}

 

Posted

Use JSON

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted

You'll need to create your own IRecipe implementation (optionally extending an existing one like ShapelessRecipes) that implements IRecipe#getRemainingItems to return the appropriate remaining items.

 

You'll also need an IRecipeFactory to parse your recipe from JSON, this needs to be registered in _factories.json.

 

You can see some examples of custom recipes and factories here and the _factories.json file here.

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.

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



×
×
  • Create New...

Important Information

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