Fixed formatting

This commit is contained in:
Jared 2017-07-25 22:56:19 +02:00
parent d4a9c12add
commit 03f8eed67b
14 changed files with 111 additions and 104 deletions

View file

@ -25,73 +25,73 @@ import java.util.Iterator;
@ZenClass("mods.betterwithmods.Anvil")
@Handler("betterwithmods")
public class Anvil {
@ZenMethod
public static void addShaped(IItemStack output, IIngredient[][] inputs) {
CraftTweakerAPI.apply(new AddShaped(output, inputs));
}
@ZenMethod
public static void addShapeless(IItemStack output, IIngredient[] inputs) {
CraftTweakerAPI.apply(new AddShapeless(output, inputs));
}
@ZenMethod
public static void removeShaped(IItemStack output, @Optional IIngredient[][] ingredients) {
CraftTweakerAPI.apply(new RemoveShaped(output, ingredients));
}
@ZenMethod
public static void removeShapeless(IItemStack output, @Optional IIngredient[] ingredients) {
CraftTweakerAPI.apply(new RemoveShapeless(output, ingredients));
}
public static class AddShaped extends BaseUndoable {
private final IItemStack output;
private final IIngredient[][] ingredients;
public AddShaped(IItemStack output, IIngredient[][] ingredients) {
super("Add Anvil Shaped Recipe");
this.output = output;
this.ingredients = ingredients;
}
@Override
public void apply() {
AnvilRecipes.addSteelShapedRecipe(new ResourceLocation("crafttweaker", this.name), InputHelper.toStack(output), toShapedAnvilObjects(ingredients));
}
@Override
protected String getRecipeInfo() {
return output.getDisplayName();
}
}
public static class AddShapeless extends BaseUndoable {
private final IItemStack output;
private final IIngredient[] ingredients;
public AddShapeless(IItemStack output, IIngredient[] ingredients) {
super("Add Anvil Shapeless Recipe");
this.output = output;
this.ingredients = ingredients;
}
@Override
public void apply() {
AnvilRecipes.addSteelShapelessRecipe(new ResourceLocation("crafttweaker", this.name), InputHelper.toStack(output), InputHelper.toObjects(ingredients));
}
@Override
protected String getRecipeInfo() {
return output.getDisplayName();
}
}
public static Object[] toShapedAnvilObjects(IIngredient[][] ingredients) {
if (ingredients == null)
if(ingredients == null)
return null;
else {
ArrayList prep = new ArrayList();
@ -100,10 +100,10 @@ public class Anvil {
prep.add("ijkl");
prep.add("mnop");
char[][] map = new char[][]{{'a', 'b', 'c', 'd'}, {'e', 'f', 'g', 'h'}, {'i', 'j', 'k', 'l'}, {'m', 'n', 'o', 'p'}};
for (int x = 0; x < ingredients.length; x++) {
if (ingredients[x] != null) {
for (int y = 0; y < ingredients[x].length; y++) {
if (ingredients[x][y] != null && x < map.length && y < map[x].length) {
for(int x = 0; x < ingredients.length; x++) {
if(ingredients[x] != null) {
for(int y = 0; y < ingredients[x].length; y++) {
if(ingredients[x][y] != null && x < map.length && y < map[x].length) {
prep.add(map[x][y]);
prep.add(InputHelper.toObject(ingredients[x][y]));
}
@ -113,73 +113,75 @@ public class Anvil {
return prep.toArray();
}
}
public static class RemoveShaped extends BaseUndoable {
private final IItemStack output;
private final IIngredient[][] ingredients;
protected RemoveShaped(IItemStack output, IIngredient[][] ingredients) {
super("Remove Shaped Anvil");
this.output = output;
this.ingredients = ingredients;
}
@Override
public void apply() {
if (ingredients != null) {
if(ingredients != null) {
IRecipe removal = new ShapedAnvilRecipe(new ResourceLocation("crafttweaker", this.name), InputHelper.toStack(output), toShapedAnvilObjects(ingredients));
for (Iterator<IRecipe> iterator = AnvilCraftingManager.VANILLA_CRAFTING.iterator(); iterator.hasNext(); ) {
for(Iterator<IRecipe> iterator = AnvilCraftingManager.VANILLA_CRAFTING.iterator(); iterator.hasNext(); ) {
IRecipe recipe = iterator.next();
if (recipe.getRecipeOutput().isItemEqual(removal.getRecipeOutput()) && removal.getIngredients().equals(recipe.getIngredients()))
if(recipe.getRecipeOutput().isItemEqual(removal.getRecipeOutput()) && removal.getIngredients().equals(recipe.getIngredients()))
iterator.remove();
}
} else {
for (Iterator<IRecipe> iterator = AnvilCraftingManager.VANILLA_CRAFTING.iterator(); iterator.hasNext(); ) {
for(Iterator<IRecipe> iterator = AnvilCraftingManager.VANILLA_CRAFTING.iterator(); iterator.hasNext(); ) {
IRecipe recipe = iterator.next();
if (recipe.getRecipeOutput().isItemEqual(InputHelper.toStack(output))) {
if(recipe.getRecipeOutput().isItemEqual(InputHelper.toStack(output))) {
iterator.remove();
}
}
}
}
@Override
protected String getRecipeInfo() {
return output.getDisplayName();
}
}
public static class RemoveShapeless extends BaseUndoable {
private final IItemStack output;
private final IIngredient[] ingredients;
protected RemoveShapeless(IItemStack output, IIngredient[] ingredients) {
super("Remove Shapeless Anvil");
this.output = output;
this.ingredients = ingredients;
}
@Override
public void apply() {
if (ingredients != null) {
if(ingredients != null) {
IRecipe removal = new ShapelessAnvilRecipe(new ResourceLocation("crafttweaker", this.name), InputHelper.toStack(output), InputHelper.toObjects(ingredients));
for (Iterator<IRecipe> iterator = AnvilCraftingManager.VANILLA_CRAFTING.iterator(); iterator.hasNext(); ) {
for(Iterator<IRecipe> iterator = AnvilCraftingManager.VANILLA_CRAFTING.iterator(); iterator.hasNext(); ) {
IRecipe recipe = iterator.next();
if (recipe.getRecipeOutput().isItemEqual(removal.getRecipeOutput()) && removal.getIngredients().equals(recipe.getIngredients()))
if(recipe.getRecipeOutput().isItemEqual(removal.getRecipeOutput()) && removal.getIngredients().equals(recipe.getIngredients()))
iterator.remove();
}
} else {
for (Iterator<IRecipe> iterator = AnvilCraftingManager.VANILLA_CRAFTING.iterator(); iterator.hasNext(); ) {
for(Iterator<IRecipe> iterator = AnvilCraftingManager.VANILLA_CRAFTING.iterator(); iterator.hasNext(); ) {
IRecipe recipe = iterator.next();
if (recipe.getRecipeOutput().isItemEqual(InputHelper.toStack(output))) {
if(recipe.getRecipeOutput().isItemEqual(InputHelper.toStack(output))) {
iterator.remove();
}
}
}
}
@Override
protected String getRecipeInfo() {
return output.getDisplayName();

View file

@ -17,23 +17,24 @@ import java.util.Map;
@ZenClass("mods.betterwithmods.Buoyancy")
@Handler("betterwithmods")
public class Buoyancy {
@ZenMethod
public static void set(IItemStack stack, float value) {
StackMap<Float> map = new StackMap(1.0);
map.put(new Stack(InputHelper.toStack(stack)),value);
map.put(new Stack(InputHelper.toStack(stack)), value);
CraftTweakerAPI.apply(new Set(map));
}
public static class Set extends BaseMapAddition<Stack, Float> {
protected Set(StackMap<Float> map) {
super("Set Item Buoyancy", HCBuoy.buoyancy, map);
}
@Override
protected String getRecipeInfo(Map.Entry<Stack, Float> recipe) {
return recipe.getKey().toString() + " -> " + recipe.getValue();
}
}
}

View file

@ -20,21 +20,21 @@ import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.betterwithmods.Cauldron")
@Handler("betterwithmods")
public class Cauldron {
@ZenMethod
public static void add(IItemStack output, @Optional IItemStack secondaryOutput, @NotNull IIngredient[] inputs) {
CauldronRecipe r = new CauldronRecipe(InputHelper.toStack(output), InputHelper.toStack(secondaryOutput), InputHelper.toObjects(inputs));
ModTweaker.LATE_ADDITIONS.add(new BulkAdd("Set Cauldron Recipe", CauldronManager.getInstance(), r));
}
@ZenMethod
public static void remove(IItemStack output) {
ModTweaker.LATE_REMOVALS.add(new BulkRemove("Set Cauldron Recipe", CauldronManager.getInstance(), InputHelper.toStack(output), ItemStack.EMPTY));
}
@ZenMethod
public static void remove(IItemStack output,@Optional IItemStack secondary, IIngredient[] inputs) {
ModTweaker.LATE_REMOVALS.add(new BulkRemove("Remove Cauldron Recipe", CauldronManager.getInstance(), InputHelper.toStack(output), secondary != null ? InputHelper.toStack(secondary) : ItemStack.EMPTY, InputHelper.toObjects(inputs)));
public static void remove(IItemStack output, @Optional IItemStack secondary, IIngredient[] inputs) {
ModTweaker.LATE_REMOVALS.add(new BulkRemove("Remove Cauldron Recipe", CauldronManager.getInstance(), InputHelper.toStack(output), secondary != null ? InputHelper.toStack(secondary) : ItemStack.EMPTY, InputHelper.toObjects(inputs)));
}
}

View file

@ -20,18 +20,18 @@ import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.betterwithmods.Crucible")
@Handler("betterwithmods")
public class Crucible {
@ZenMethod
public static void add(IItemStack output, @Optional IItemStack secondaryOutput, @NotNull IIngredient[] inputs) {
CrucibleRecipe r = new CrucibleRecipe(InputHelper.toStack(output), InputHelper.toStack(secondaryOutput), InputHelper.toObjects(inputs));
ModTweaker.LATE_ADDITIONS.add(new BulkAdd("Set Crucible Recipe", CrucibleManager.getInstance(), r));
}
@ZenMethod
public static void remove(IItemStack output) {
ModTweaker.LATE_REMOVALS.add(new BulkRemove("Set Crucible Recipe", CrucibleManager.getInstance(), InputHelper.toStack(output), ItemStack.EMPTY));
}
@ZenMethod
public static void remove(IItemStack output, IItemStack secondary, IIngredient[] inputs) {
ModTweaker.LATE_REMOVALS.add(new BulkRemove("Remove Crucible Recipe", CrucibleManager.getInstance(), InputHelper.toStack(output), secondary != null ? InputHelper.toStack(secondary) : ItemStack.EMPTY, InputHelper.toObjects(inputs)));

View file

@ -27,38 +27,39 @@ import java.util.Arrays;
@ZenClass("mods.betterwithmods.Kiln")
@Handler("betterwithmods")
public class Kiln {
@ZenMethod
public static void add(IItemStack[] output, @NotNull IItemStack input) {
ItemStack stack = InputHelper.toStack(input);
if (InputHelper.isABlock(stack)) {
if(InputHelper.isABlock(stack)) {
Block block = ((ItemBlock) stack.getItem()).getBlock();
ItemStack[] outputs = InputHelper.toStacks(output);
KilnRecipe r = new KilnRecipe(block, stack.getMetadata(), Arrays.asList(outputs));
ModTweaker.LATE_ADDITIONS.add(new BMAdd("Set Kiln Recipe", KilnManager.INSTANCE, Lists.newArrayList(r)));
}
}
@ZenMethod
public static void remove(IItemStack input) {
ModTweaker.LATE_REMOVALS.add(new BMRemove("Set Kiln Recipe", KilnManager.INSTANCE, InputHelper.toStack(input)));
}
@ZenMethod
public static void registerBlock(IItemStack block) {
ModTweaker.LATE_ADDITIONS.add(new KilnBlock(BWMRecipes.getStateFromStack(InputHelper.toStack(block))));
}
public static class KilnBlock extends BaseUndoable {
private IBlockState state;
protected KilnBlock(IBlockState state) {
super("Set Kiln Structure Block");
this.state = state;
}
@Override
public void apply() {
KilnStructureManager.registerKilnBlock(state);

View file

@ -20,20 +20,20 @@ import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.betterwithmods.Mill")
@Handler("betterwithmods")
public class Mill {
@ZenMethod
public static void add(IItemStack output, @Optional IItemStack secondaryOutput, @NotNull IIngredient[] inputs) {
MillRecipe r = new MillRecipe(0,InputHelper.toStack(output),InputHelper.toStack(secondaryOutput),InputHelper.toObjects(inputs));
ModTweaker.LATE_ADDITIONS.add(new BulkAdd("Set Mill Recipe", MillManager.getInstance(),r));
MillRecipe r = new MillRecipe(0, InputHelper.toStack(output), InputHelper.toStack(secondaryOutput), InputHelper.toObjects(inputs));
ModTweaker.LATE_ADDITIONS.add(new BulkAdd("Set Mill Recipe", MillManager.getInstance(), r));
}
@ZenMethod
public static void remove(IItemStack output) {
ModTweaker.LATE_REMOVALS.add(new BulkRemove("Remove Mill Recipe", MillManager.getInstance(),InputHelper.toStack(output), ItemStack.EMPTY));
ModTweaker.LATE_REMOVALS.add(new BulkRemove("Remove Mill Recipe", MillManager.getInstance(), InputHelper.toStack(output), ItemStack.EMPTY));
}
@ZenMethod
public static void remove(IItemStack output, IIngredient[] inputs) {
ModTweaker.LATE_REMOVALS.add(new BulkRemove("Remove Mill Recipe", MillManager.getInstance(),InputHelper.toStack(output), ItemStack.EMPTY, InputHelper.toObjects(inputs)));
ModTweaker.LATE_REMOVALS.add(new BulkRemove("Remove Mill Recipe", MillManager.getInstance(), InputHelper.toStack(output), ItemStack.EMPTY, InputHelper.toObjects(inputs)));
}
}

View file

@ -24,21 +24,21 @@ import java.util.Arrays;
@ZenClass("mods.betterwithmods.Saw")
@Handler("betterwithmods")
public class Saw {
@ZenMethod
public static void add(IItemStack[] output, @NotNull IItemStack input) {
ItemStack stack = InputHelper.toStack(input);
if (InputHelper.isABlock(stack)) {
if(InputHelper.isABlock(stack)) {
Block block = ((ItemBlock) stack.getItem()).getBlock();
ItemStack[] outputs = InputHelper.toStacks(output);
SawRecipe r = new SawRecipe(block, stack.getMetadata(), Arrays.asList(outputs));
ModTweaker.LATE_ADDITIONS.add(new BMAdd("Set Saw Recipe", SawManager.INSTANCE, Lists.newArrayList(r)));
}
}
@ZenMethod
public static void remove(IItemStack input) {
ModTweaker.LATE_REMOVALS.add(new BMRemove("Remove Saw Recipe", SawManager.INSTANCE, InputHelper.toStack(input)));
}
}

View file

@ -21,20 +21,20 @@ import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.betterwithmods.StokedCauldron")
@Handler("betterwithmods")
public class StokedCauldron {
@ZenMethod
public static void add(IItemStack output, @Optional IItemStack secondaryOutput, @NotNull IIngredient[] inputs) {
StokedCauldronRecipe r = new StokedCauldronRecipe(InputHelper.toStack(output), InputHelper.toStack(secondaryOutput),InputHelper.toObjects(inputs));
ModTweaker.LATE_ADDITIONS.add(new BulkAdd("Set Stoked Cauldron Recipe", StokedCauldronManager.getInstance(),r));
StokedCauldronRecipe r = new StokedCauldronRecipe(InputHelper.toStack(output), InputHelper.toStack(secondaryOutput), InputHelper.toObjects(inputs));
ModTweaker.LATE_ADDITIONS.add(new BulkAdd("Set Stoked Cauldron Recipe", StokedCauldronManager.getInstance(), r));
}
@ZenMethod
public static void remove(IItemStack output) {
ModTweaker.LATE_REMOVALS.add(new BulkRemove("Remove Stoked Cauldron Recipe", StokedCauldronManager.getInstance(),InputHelper.toStack(output), ItemStack.EMPTY));
ModTweaker.LATE_REMOVALS.add(new BulkRemove("Remove Stoked Cauldron Recipe", StokedCauldronManager.getInstance(), InputHelper.toStack(output), ItemStack.EMPTY));
}
@ZenMethod
public static void remove(IItemStack output, IIngredient[] inputs) {
ModTweaker.LATE_REMOVALS.add(new BulkRemove("Remove Stoked Cauldron Recipe", StokedCauldronManager.getInstance(),InputHelper.toStack(output), ItemStack.EMPTY, InputHelper.toObjects(inputs)));
ModTweaker.LATE_REMOVALS.add(new BulkRemove("Remove Stoked Cauldron Recipe", StokedCauldronManager.getInstance(), InputHelper.toStack(output), ItemStack.EMPTY, InputHelper.toObjects(inputs)));
}
}

View file

@ -20,18 +20,18 @@ import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.betterwithmods.StokedCrucible")
@Handler("betterwithmods")
public class StokedCrucible {
@ZenMethod
public static void add(IItemStack output, @Optional IItemStack secondaryOutput, @NotNull IIngredient[] inputs) {
StokedCrucibleRecipe r = new StokedCrucibleRecipe(InputHelper.toStack(output), InputHelper.toStack(secondaryOutput), InputHelper.toObjects(inputs));
ModTweaker.LATE_ADDITIONS.add(new BulkAdd("Set Stoked Crucible Recipe", StokedCrucibleManager.getInstance(), r));
}
@ZenMethod
public static void remove(IItemStack output, @Optional IItemStack secondary) {
ModTweaker.LATE_REMOVALS.add(new BulkRemove("Set Stoked Crucible Recipe", StokedCrucibleManager.getInstance(), InputHelper.toStack(output), secondary != null ? InputHelper.toStack(secondary) : ItemStack.EMPTY));
}
@ZenMethod
public static void remove(IItemStack output, @Optional IItemStack secondary, @NotNull IIngredient[] inputs) {
ModTweaker.LATE_REMOVALS.add(new BulkRemove("Remove Stoked Crucible Recipe", StokedCrucibleManager.getInstance(), InputHelper.toStack(output), secondary != null ? InputHelper.toStack(secondary) : ItemStack.EMPTY, InputHelper.toObjects(inputs)));

View file

@ -23,37 +23,39 @@ import java.util.List;
@ZenClass("mods.betterwithmods.Turntable")
@Handler("betterwithmods")
public class Turntable {
@ZenMethod
public static void add(IItemStack inputBlock, IItemStack outputBlock, IItemStack[] additionalOutput) {
if (InputHelper.isABlock(inputBlock))
if(InputHelper.isABlock(inputBlock))
LogHelper.logError("Input must be a block", new IllegalArgumentException());
ModTweaker.LATE_ADDITIONS.add(new Add(InputHelper.toStack(inputBlock), InputHelper.toStack(outputBlock), Lists.newArrayList(InputHelper.toStacks(additionalOutput))));
}
public static class Add extends BMAdd {
public Add(ItemStack input, ItemStack output, List<ItemStack> scraps) {
super(TurntableRecipeCategory.UID, TurntableManager.INSTANCE, Lists.newArrayList(new TurntableRecipe(input, output, scraps)));
}
}
@ZenMethod
public static void remove(IItemStack inputBlock) {
if (!InputHelper.isABlock(inputBlock))
if(!InputHelper.isABlock(inputBlock))
LogHelper.logError("Input must be a block", new IllegalArgumentException());
ModTweaker.LATE_REMOVALS.add(new Remove(InputHelper.toStack(inputBlock)));
}
public static class Remove extends BaseListRemoval<TurntableRecipe> {
protected Remove(ItemStack input) {
super("Remove Turntable Recipe", TurntableManager.INSTANCE.getRecipes(), TurntableManager.INSTANCE.removeTurntableRecipe(input));
}
@Override
protected String getRecipeInfo(TurntableRecipe recipe) {
return recipe.getStack().getDisplayName();
}
}
}

View file

@ -7,14 +7,14 @@ import com.blamejared.mtlib.utils.BaseListAddition;
import java.util.List;
public class BMAdd<T extends BlockMetaRecipe> extends BaseListAddition<T> {
public BMAdd(String name, BlockMetaManager<T> handler, List<T> recipes) {
super(name, handler.getRecipes(), recipes);
}
@Override
protected String getRecipeInfo(BlockMetaRecipe recipe) {
return recipe.getStack().getDisplayName();
}
}

View file

@ -6,13 +6,14 @@ import com.blamejared.mtlib.utils.BaseListRemoval;
import net.minecraft.item.ItemStack;
public class BMRemove extends BaseListRemoval<BlockMetaRecipe> {
public BMRemove(String name, BlockMetaManager recipes, ItemStack input) {
super(name, recipes.getRecipes(), recipes.removeRecipes(input));
}
@Override
protected String getRecipeInfo(BlockMetaRecipe recipe) {
return recipe.getStack().getDisplayName();
}
}

View file

@ -6,14 +6,14 @@ import com.blamejared.mtlib.utils.BaseListAddition;
import com.google.common.collect.Lists;
public class BulkAdd<T extends BulkRecipe> extends BaseListAddition<T> {
public BulkAdd(String name, CraftingManagerBulk<T> recipes, T recipe) {
super(name, recipes.getRecipes(), Lists.newArrayList(recipe));
}
@Override
protected String getRecipeInfo(T recipe) {
return recipe.getOutput().getDisplayName();
}
}

View file

@ -8,14 +8,14 @@ import net.minecraft.item.ItemStack;
public class BulkRemove<T extends BulkRecipe> extends BaseListRemoval<T> {
public BulkRemove(String name, CraftingManagerBulk<T> recipes, ItemStack output, ItemStack secondary, Object... inputs) {
super(name, recipes.getRecipes(), recipes.findRecipeForRemoval(output, secondary, inputs));
}
@Override
protected String getRecipeInfo(BulkRecipe recipe) {
return recipe.getOutput().getDisplayName();
}
}