- Added /mt recipes command

- Added /mt recipes hand command
- Removed COMMAND: in front of lines generated from commands
This commit is contained in:
Stan Hebben committed 2014-10-08 23:23:17 +02:00
1 parent f5e467e9a4
commit 9fcf4b9a4e
25 files changed
+617 -42

No files matched your search

@@ -157,6 +157,14 @@ public interface IItemStack extends IIngredient {
@ZenMethod
public IItemStack withAmount(int amount);
/**
* Creates an item stack with wildcard stack size.
*
* @return new, modified item stack
*/
@ZenMethod
public IItemStack anyAmount();
/**
* Creates an item stack with the given nbt tag. Ignores existing tags.
*
@@ -38,7 +38,7 @@ public class FileLogger implements ILogger {
@Override
public void logCommand(String message) {
try {
writer.write("COMMAND: " + message + "\n");
writer.write(message + "\n");
writer.flush();
} catch (IOException ex) {
throw new RuntimeException(ex);
@@ -23,4 +23,6 @@ public interface ICraftingRecipe {
public boolean hasTransformers();
public void applyTransformers(ICraftingInventory inventory, IPlayer byPlayer);
public String toCommandString();
}
@@ -1,9 +1,11 @@
package minetweaker.api.recipes;
import java.util.List;
import minetweaker.api.item.IIngredient;
import minetweaker.api.item.IItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.Optional;
import stanhebben.zenscript.annotations.ZenGetter;
import stanhebben.zenscript.annotations.ZenMethod;
/**
@@ -14,6 +16,23 @@ import stanhebben.zenscript.annotations.ZenMethod;
*/
@ZenClass("minetweaker.recipes.IRecipeManager")
public interface IRecipeManager {
/**
* Returns all crafting recipes.
*
* @return all crafting recipes
*/
@ZenGetter("all")
public List<ICraftingRecipe> getAll();
/**
* Returns all crafting recipes resulting in the given ingredient.
*
* @param ingredient ingredient to find
* @return crafting recipes for the given item(s)
*/
@ZenMethod
public List<ICraftingRecipe> getRecipesFor(IIngredient ingredient);
/**
* Removes all crafting recipes crafting the specified item.
*
@@ -217,6 +217,39 @@ public class ShapedRecipe implements ICraftingRecipe {
}
}
@Override
public String toCommandString() {
StringBuilder result = new StringBuilder();
result.append("recipes.addShaped(");
result.append(output);
result.append(", [");
IIngredient[][] ingredientsArray = new IIngredient[height][width];
for (int i = 0; i < ingredients.length; i++) {
ingredientsArray[posy[i]][posx[i]] = ingredients[i];
}
for (int i = 0; i < ingredientsArray.length; i++) {
if (i > 0) {
result.append(", ");
}
result.append("[");
for (int j = 0; j < ingredientsArray[i].length; j++) {
if (j > 0)
result.append(", ");
result.append(ingredientsArray[i][j]);
}
result.append("]");
}
result.append("]);");
return result.toString();
}
private IItemStack doRecipe(
ICraftingInventory inventory,
IItemStack[] stacks,
@@ -80,6 +80,26 @@ public class ShapelessRecipe implements ICraftingRecipe {
}
}
@Override
public String toCommandString() {
StringBuilder result = new StringBuilder();
result.append("recipes.addShapeless(");
result.append(output);
result.append(", [");
for (int i = 0; i < ingredients.length; i++) {
if (i > 0)
result.append(", ");
result.append(ingredients[i]);
}
result.append("]);");
return result.toString();
}
/**
* Reorders ingredients to match the given shapeless recipe.
*
@@ -0,0 +1,47 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package minetweaker.api.recipes;
import minetweaker.api.item.IItemStack;
import minetweaker.api.player.IPlayer;
/**
*
* @author Stan
*/
public class UnknownRecipe implements ICraftingRecipe {
private final IItemStack output;
public UnknownRecipe(IItemStack output) {
this.output = output;
}
@Override
public boolean matches(ICraftingInventory inventory) {
return false;
}
@Override
public IItemStack getCraftingResult(ICraftingInventory inventory) {
return output;
}
@Override
public boolean hasTransformers() {
return false;
}
@Override
public void applyTransformers(ICraftingInventory inventory, IPlayer byPlayer) {
}
@Override
public String toCommandString() {
return "// unknown recipe type for " + output;
}
}