Mekanism

Mekanism

111M Downloads

[API] Having issues with the IMC-based recipe removal

TehNut opened this issue ยท 4 comments

commented

Following this Wiki page, I produced the following code to allow myself to remove Enrichment Chamber recipes.

removeRecipe("EnrichmentChamber", new ItemStack(Items.diamond), new ItemStack(compressedDiamond));
public static void removeRecipe(String recipeType, ItemStack input, ItemStack output) {
    NBTTagCompound recipeTag = new NBTTagCompound();
    recipeTag.setTag("input", input.writeToNBT(new NBTTagCompound()));
    recipeTag.setTag("output", output.writeToNBT(new NBTTagCompound()));
    FMLInterModComms.sendMessage("Mekanism", "Remove" + recipeType + "Recipe", recipeTag);
}

Theoretically, this should work. I triple checked everything and see nothing wrong with it. However, when Mekanism handles the it produces the following error:

[19:15:15] [Client thread/ERROR] [Mekanism]: [Mekanism] recipetweakingcore sent unknown IMC message with key 'RemoveEnrichmentChamberRecipe.'

When looking through IMCHandler.java to see if I could pinpoint my error, it appeared to require Delete instead of Remove, so I tried that as well. Still no dice. I asked in the IRC channel, but nobody else seemed to know either.

commented

Duh, Strings aren't mutable. Fixed.

commented

Just to be certain, when you tried using DeleteEnrichmentChamberRecipe, it says unknown IMC message with key 'DeleteEnrichmentChamberRecipe' ?

commented

Correct.

commented

Ok then there's the problem

if(msg.key.startsWith("Delete"))
{
    msg.key.replace("Delete", "");
    delete = true;
}

Isn't running. If it ran the key is supposed to lose the Delete portion since the log is logging msg.key, which the above code modifies.

so...
msg.key.startsWith("Delete")
is returning false? Hmm

The only thing I can think of that MIGHT fail that section is characters that look the same but with different charcodes...

I only looked at the source though.