Skip to content

Commit

Permalink
Cleanup mirrored things in ShapedOreRecipe to address issue 208 and i…
Browse files Browse the repository at this point in the history
…ssue 210
  • Loading branch information
LexManos committed Oct 22, 2012
1 parent a09ea82 commit ad51183
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions common/net/minecraftforge/oredict/ShapedOreRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,30 @@ public class ShapedOreRecipe implements IRecipe
private Object[] input = null;
private int width = 0;
private int height = 0;
private boolean mirriored = true;
private boolean mirrored = true;

public ShapedOreRecipe(Block result, Object... recipe){ this(result, true, recipe);}
public ShapedOreRecipe(Item result, Object... recipe){ this(result, true, recipe); }
public ShapedOreRecipe(ItemStack result, Object... recipe){ this(result, true, recipe); }
public ShapedOreRecipe(Block result, boolean mirrior, Object... recipe){ this(new ItemStack(result), mirrior, recipe);}
public ShapedOreRecipe(Item result, boolean mirrior, Object... recipe){ this(new ItemStack(result), mirrior, recipe); }

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

This comment has been minimized.

Copy link
@celestefox

celestefox Oct 22, 2012

Should some comments, now the fact that you can mirror the recipe in the constructor has been obfuscated.

This comment has been minimized.

Copy link
@LexManos

LexManos Oct 23, 2012

Author Member

Only here for legacy support, users should use the setMirrored method.

This comment has been minimized.

Copy link
@celestefox

celestefox Oct 23, 2012

Nice, good idea there. Also lets you get away without writing javadocs... ;)

public ShapedOreRecipe(Block result, Object... recipe){ this(new ItemStack(result), recipe); }
public ShapedOreRecipe(Item result, Object... recipe){ this(new ItemStack(result), recipe); }
public ShapedOreRecipe(ItemStack result, Object... recipe)
{
output = result.copy();
mirriored = mirrior;


String shape = "";
int idx = 0;

if (recipe[idx] instanceof Boolean)
{
mirrored = (Boolean)recipe[idx];
if (recipe[idx+1] instanceof Object[])
{
recipe = (Object[])recipe[idx+1];
}
else
{
idx = 1;
}
}

if (recipe[idx] instanceof String[])
{
String[] parts = ((String[])recipe[idx++]);
Expand All @@ -59,7 +67,7 @@ public ShapedOreRecipe(ItemStack result, boolean mirrior, Object... recipe)
height++;
}
}

if (width * height != shape.length())
{
String ret = "Invalid shaped ore recipe: ";
Expand Down Expand Up @@ -136,7 +144,7 @@ public boolean matches(InventoryCrafting inv, World world)
return true;
}

if (mirriored && checkMatch(inv, x, y, false))
if (mirrored && checkMatch(inv, x, y, false))
{
return true;
}
Expand All @@ -146,7 +154,7 @@ public boolean matches(InventoryCrafting inv, World world)
return false;
}

private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirrior)
private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror)
{
for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++)
{
Expand All @@ -158,7 +166,7 @@ private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolea

if (subX >= 0 && subY >= 0 && subX < width && subY < height)
{
if (mirrior)
if (mirror)
{
target = input[width - subX - 1 + subY * width];
}
Expand Down Expand Up @@ -210,8 +218,9 @@ private boolean checkItemEquals(ItemStack target, ItemStack input)
return (target.itemID == input.itemID && (target.getItemDamage() == -1 || target.getItemDamage() == input.getItemDamage()));
}

public void setMirriored(boolean mirrior)
public ShapedOreRecipe setMirrored(boolean mirror)

This comment has been minimized.

Copy link
@celestefox

celestefox Oct 22, 2012

This line here broke any mods that used setMirriored, too, as you didn't deprecate setMirriored. :L
The only way I see this being good is if this is intended for 1.4, but 1.4 MCP isn't out yet...

This comment has been minimized.

Copy link
@Silwing

Silwing Oct 22, 2012

MCP has had a pre-release for 1.4 since saturday some time I think... Forge has also been updated for 1.4 pre-release.

This comment has been minimized.

Copy link
@celestefox

celestefox Oct 22, 2012

OK, then I agree with this change... Just think some javadocs should be added to explain the constructors.

This comment has been minimized.

Copy link
@celestefox

celestefox Oct 22, 2012

Actually, do you know where the prerelease is? Cause it isn't in the normal place.

This comment has been minimized.

Copy link
@Myrathi

Myrathi Oct 22, 2012

See Searge's twitter feed.

{
mirriored = mirrior;
mirrored = mirror;
return this;
}
}

0 comments on commit ad51183

Please sign in to comment.