Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ShapedOreRecipe has ambiguous constructors #208

Closed
taralx opened this issue Oct 13, 2012 · 15 comments
Closed

ShapedOreRecipe has ambiguous constructors #208

taralx opened this issue Oct 13, 2012 · 15 comments

Comments

@taralx
Copy link

taralx commented Oct 13, 2012

The constructor:

new ShapedOreRecipe(myBlock, false, "AAA", 'A', Block.glass)

whines about ambiguous constructors. I'd fix it, but I don't know what the best way to solve it is.

@celestefox
Copy link

Scratch that, why the hell are you using an oredic recipe for this? That's probably your problem right there, really. See: http://www.minecraftforge.net/wiki/How_to_use_the_ore_dictionary

@taralx
Copy link
Author

taralx commented Oct 13, 2012

Um, that was example code. My actual code uses the oredict properly.

@celestefox
Copy link

Then don't give complete invalid pieces of demo code.
Here, let's look at this line from the wiki page I linked:
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(Item.bucketEmpty, true, new Object[]{"FF", Character.valueOf('F'), "ingotCopper"}));
First, it correctly get's the recipe list(I will assume you do this right). Then, the parameters of the recipe. The result, if it is mirrored, and an object array, which is the contents of the recipie. First, you want Character.valueOf('t') where t is the character used. You also use string used when registering the recipie if you want it to work with other mod items, usually in the form of OreOreBlockName of ingotNameOfIngot as shown here:
OreDictionary.registerOre("ingotCopper", new ItemStack(ingotCopper));

@taralx
Copy link
Author

taralx commented Oct 13, 2012

The specific issue I'm talking about has to do with the use of the variadic constructors declared in ShapedOreRecipe. My example points out the issue just fine.

@celestefox
Copy link

No, I really think it's your code, and unless you can give a more specific example, I can't help you(especially as I believe the error is happening because there isn't a constructor that matches your demo code, as of the Forge rewrite[or earlier], see https://github.com/MinecraftForge/MinecraftForge/blob/master/common/net/minecraftforge/oredict/ShapedOreRecipe.java)

@taralx
Copy link
Author

taralx commented Oct 14, 2012

Perhaps I should have been more specific.

public ShapedOreRecipe(ItemStack result, Object... recipe)

and

public ShapedOreRecipe(ItemStack result, boolean mirrior, Object... recipe)

are ambiguous. Here is code that, as per your request, actually uses an ore dictionary item:

        GameRegistry.addRecipe(new ShapedOreRecipe(routingPipe, false, "BGB", 'B', "ingotBronze", 'G', Block.glass));

@AbrarSyed
Copy link
Member

then you my freind.. don't understand just how awesome Object... recipe is.

you can use it either as...

public ShapedOreRecipe(ItemStack result, boolean mirrior, object1, object2, object3, object4)

or

public ShapedOreRecipe(ItemStack result, boolean mirrior, new Object[] {object1, object2, object3, object4})

@Myrathi
Copy link

Myrathi commented Oct 14, 2012

You're both missing his point: which is that of the parameters of the ShapedOreRecipe methods and not his example code, specifically.

The (Itemstack, Object...) version is ambiguous if the compiler is seeing (a) the first Object as accepting a Boolean, which could unbox to the boolean primitive (which would match the three-param version); or (b) the boolean as being boxable into a Boolean (which would satisfy the two-param version).

@AbrarSyed
Copy link
Member

hmmmm interresting... I don'tthe compiler will take that 1st boolean.. will it?

@Myrathi
Copy link

Myrathi commented Oct 14, 2012

Must be doing something squicky, if he's getting ambiguity warnings about it.

@AbrarSyed
Copy link
Member

I seee...... /me reccomends a pull

@celestefox
Copy link

Well, I've drafted several replies to this, and deleted each one. I see the problem now, and I believe the best solution is to remove the lines that add the mirrior variable, and check/set mirrior/mirriored only in the final constructor. This means removing the top three constuctors and checking if recipe[0] is a boolean and if so, set mirriored appropriately. Then, cut the first value from recipe with some sort of array building(guava lists?) and continue, or just set idx = 1 to start with. Not what should be done, just the problem and a solution idea. And I think this looks good enough to post, so...
EDIT: Apparently, Github doesn't show new comments when your'e writing one. Interesting...
EDIT 2: Myrathi, I finally got it after reading up on Variable numbers of objects, and yes, if your'e not using a Object[]{} the compiler isn't sure if the boolean is seperate or part of Object... recipie, which is the problem. I have written up a theoretical solution, but don't currently have time to try to code it(Damn classes).

@taralx
Copy link
Author

taralx commented Oct 14, 2012

Yes, I considered that option. It's a shame to lose the self-documenting effect of the explicit boolean constructors, but at least that works. I'd love to hear lex weigh in on this one, since he has a good sense of API aesthetics.

@celestefox
Copy link

Can I get confirmation on how to develop Forge? It's fork the repo, git
clone to forge dir in mcp, run setup to get working mc in eclipse with
latest forge, and then what? Do I just change the java and generate the
patch somehow? With a script? Can't find documentation anywhere, which is
annoying.

@LexManos
Copy link
Member

ad51183

cpw added a commit that referenced this issue Mar 22, 2013
MinecraftForge/FML@d1ff196 Fixed FMLRelaunchLog's Newline Handling
MinecraftForge/FML@591a257 Merge pull request #208 from jrtc27/patch-1
cpw added a commit that referenced this issue May 11, 2015
Fixed FMLRelaunchLog's Newline Handling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants