Make backwards compatible
- Reverts method to use incorrect shaping - Adds new method to use correct shaping
This commit is contained in:
parent
4ad1b80068
commit
31247d39ca
1 changed files with 75 additions and 0 deletions
|
@ -31,6 +31,11 @@ public class Anvil {
|
|||
ModTweaker.LATE_ADDITIONS.add(new AddShaped(output, inputs));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addShapedFixed(IItemStack output, IIngredient[][] inputs) {
|
||||
ModTweaker.LATE_ADDITIONS.add(new AddShapedFixed(output, inputs));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addShapeless(IItemStack output, IIngredient[] inputs) {
|
||||
ModTweaker.LATE_ADDITIONS.add(new AddShapeless(output, inputs));
|
||||
|
@ -41,6 +46,11 @@ public class Anvil {
|
|||
ModTweaker.LATE_REMOVALS.add(new RemoveShaped(output, ingredients));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeShapedFixed(IItemStack output, @Optional IIngredient[][] ingredients) {
|
||||
ModTweaker.LATE_REMOVALS.add(new RemoveShapedFixed(output, ingredients));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeShapeless(IItemStack output, @Optional IIngredient[] ingredients) {
|
||||
ModTweaker.LATE_REMOVALS.add(new RemoveShapeless(output, ingredients));
|
||||
|
@ -73,6 +83,18 @@ public class Anvil {
|
|||
}
|
||||
}
|
||||
|
||||
public static class AddShapedFixed extends AddShaped {
|
||||
|
||||
public AddShapedFixed(IItemStack output, IIngredient[][] ingredients) {
|
||||
super(output, ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
AnvilRecipes.addSteelShapedRecipe(new ResourceLocation("crafttweaker", this.name), InputHelper.toStack(output), toShapedAnvilObjectsFixed(ingredients));
|
||||
}
|
||||
}
|
||||
|
||||
public static class AddShapeless extends BaseAction {
|
||||
|
||||
private final IItemStack output;
|
||||
|
@ -101,6 +123,33 @@ public class Anvil {
|
|||
else {
|
||||
ArrayList<Object> prep = new ArrayList<>();
|
||||
char chr = 'a';
|
||||
for(int y = 0; y < 4; y++) {
|
||||
StringBuilder matrix = new StringBuilder();
|
||||
for(int x = 0; x < 4; x++) {
|
||||
if(x < ingredients.length && ingredients[x] != null && y < ingredients[x].length) {
|
||||
if(ingredients[x][y] != null) {
|
||||
prep.add(chr);
|
||||
prep.add(InputHelper.toObject(ingredients[x][y]));
|
||||
matrix.append(chr);
|
||||
chr++;
|
||||
} else {
|
||||
matrix.append(' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
if(matrix.length() > 0)
|
||||
prep.add(y, matrix.toString());
|
||||
}
|
||||
return prep.toArray();
|
||||
}
|
||||
}
|
||||
|
||||
public static Object[] toShapedAnvilObjectsFixed(IIngredient[][] ingredients) {
|
||||
if(ingredients == null)
|
||||
return null;
|
||||
else {
|
||||
ArrayList prep = new ArrayList();
|
||||
char chr = 'a';
|
||||
for(int x = 0; x < 4; x++) {
|
||||
StringBuilder matrix = new StringBuilder();
|
||||
for(int y = 0; y < 4; y++) {
|
||||
|
@ -159,6 +208,32 @@ public class Anvil {
|
|||
}
|
||||
}
|
||||
|
||||
public static class RemoveShapedFixed extends RemoveShaped {
|
||||
|
||||
protected RemoveShapedFixed(IItemStack output, IIngredient[][] ingredients) {
|
||||
super(output, ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
if(ingredients != null) {
|
||||
IRecipe removal = new ShapedAnvilRecipe(new ResourceLocation("crafttweaker", this.name), InputHelper.toStack(output), toShapedAnvilObjectsFixed(ingredients));
|
||||
for(Iterator<IRecipe> iterator = AnvilCraftingManager.ANVIL_CRAFTING.iterator(); iterator.hasNext(); ) {
|
||||
IRecipe recipe = iterator.next();
|
||||
if(recipe.getRecipeOutput().isItemEqual(removal.getRecipeOutput()) && removal.getIngredients().equals(recipe.getIngredients()))
|
||||
iterator.remove();
|
||||
}
|
||||
} else {
|
||||
for(Iterator<IRecipe> iterator = AnvilCraftingManager.ANVIL_CRAFTING.iterator(); iterator.hasNext(); ) {
|
||||
IRecipe recipe = iterator.next();
|
||||
if(recipe.getRecipeOutput().isItemEqual(InputHelper.toStack(output))) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class RemoveShapeless extends BaseAction {
|
||||
|
||||
private final IItemStack output;
|
||||
|
|
Loading…
Reference in a new issue