Jump to content

[1.12.2] Problem with entchanted items in recipes


Tomson124

Recommended Posts

Someone reported a bug with my mod where you cannot combine the jetpack and the armor plating after you entchanted the the jetpack with a book in an anvil.

I also could reproduce this. The strange thing is, that my custom recipe class which is extending ShapelessOreRecipe looks very similar to e.g. CoFH's but their recipes do work with entchanted ingredients and mine don't. I am still using "old" java recipes over the JSON ones, as I did not have the time to look into that and port everything over to this system.

 

"UpgradingRecipeShapeless":

Spoiler

 


public class UpgradingRecipeShapeless extends ShapelessOreRecipe {

	public UpgradingRecipeShapeless(ItemStack result, Object... recipe) {
		super(null, result, recipe);
		setRegistryName(SimplyJetpacks.MODID, "upgradeRecipeShapeless" + j);
		j++;
	}

	public ItemStack getCraftingResult(@Nonnull InventoryCrafting inv) {

		ItemStack inputStack = ItemStack.EMPTY;
		ItemStack outputStack = output.copy();
		IEnergyContainerItem outputItem = (IEnergyContainerItem) outputStack.getItem();

		int addedEnergy = 0;
		ParticleType particleType = null;
		NBTTagCompound tags = null;

		for (int i = 0; i < inv.getSizeInventory(); ++i) {
			ItemStack stack = inv.getStackInSlot(i);

			if (!stack.isEmpty()) {
				inputStack = stack;
				if (inputStack.getItem() instanceof IEnergyContainerItem) {
					addedEnergy += ((IEnergyContainerItem) inputStack.getItem()).getEnergyStored(inputStack);
				} else if (OreDictionary.containsMatch(false, CommonProxy.oresListParticles, inputStack)) {
					particleType = ParticleType.values()[inputStack.getItemDamage()];
				}
			}
		}

		if (inputStack.isEmpty()) {
			return ItemStack.EMPTY;
		}
		outputStack = ItemHelper.copyTag(outputStack, inputStack);

		NBTHelper.setInt(outputStack, "Energy", Math.min(addedEnergy, outputItem.getMaxEnergyStored(outputStack)));

		if (outputItem instanceof ItemJetpack && particleType != null) {
			((ItemJetpack) outputItem).setParticleType(outputStack, particleType);
		}

		return outputStack;
	}

	@Override
	public boolean isDynamic() {

		return true;
	}
}

 

Link to comment
Share on other sites

honestly for this stuff your better off keeping your old recipes. though if your trying to keep the enchantments

        ItemStack input = playerIn.getHeldItem(hand);
        ItemStack morph1 = new ItemStack(Item.getByNameOrId(this.morph), is.getCount(), is.getMetadata());
            if (is.hasTagCompound()) {
                morph1.setTagCompound(is.getTagCompound());
            }
            if (hand == EnumHand.MAIN_HAND) {
                playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, morph1);
            }}

this might not be entirely related or the best way to handle it but if your wanting it to work with enchanted items you should have it take the nbtdata from the input item and set it to the output something similar to this. there might be better ways but I figured I'd toss this here incase its of help

Edited by Blaez
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



×
×
  • Create New...

Important Information

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