Permalink
Browse files

Add recipe "key" for furnace recipes

  • Loading branch information...
PseudoKnight committed Aug 5, 2018
1 parent ba68da7 commit f6fcd5badbbf3e87682f1a9a338643c8ad2f25cb
@@ -2,6 +2,8 @@
public interface MCFurnaceRecipe extends MCRecipe {
String getKey();
MCItemStack getInput();
void setInput(MCItemStack input);
@@ -639,18 +639,25 @@ public MCRecipe GetNewRecipe(String key, MCRecipeType type, MCItemStack result)
ItemStack is = ((BukkitMCItemStack) result).asItemStack();
switch(type) {
case FURNACE:
FurnaceRecipe recipe = new FurnaceRecipe(is, Material.PISTON_MOVING_PIECE);
return new BukkitMCFurnaceRecipe(recipe);
if(key != null) {
NamespacedKey nskey = new NamespacedKey(CommandHelperPlugin.self, key);
return new BukkitMCFurnaceRecipe(new FurnaceRecipe(nskey, is, Material.AIR, 0.0F, 200));
} else {
// deprecated in 1.13
return new BukkitMCFurnaceRecipe(new FurnaceRecipe(is, Material.AIR));
}
case SHAPED:
if(key != null) {
return new BukkitMCShapedRecipe(new ShapedRecipe(new NamespacedKey(CommandHelperPlugin.self, key), is));
NamespacedKey nskey = new NamespacedKey(CommandHelperPlugin.self, key);
return new BukkitMCShapedRecipe(new ShapedRecipe(nskey, is));
} else {
// deprecated in 1.12
return new BukkitMCShapedRecipe(new ShapedRecipe(is));
}
case SHAPELESS:
if(key != null) {
return new BukkitMCShapelessRecipe(new ShapelessRecipe(new NamespacedKey(CommandHelperPlugin.self, key), is));
NamespacedKey nskey = new NamespacedKey(CommandHelperPlugin.self, key);
return new BukkitMCShapelessRecipe(new ShapelessRecipe(nskey, is));
} else {
// deprecated in 1.12
return new BukkitMCShapelessRecipe(new ShapelessRecipe(is));
@@ -15,6 +15,11 @@ public BukkitMCFurnaceRecipe(FurnaceRecipe recipe) {
fr = recipe;
}
@Override
public String getKey() {
return fr.getKey().getKey();
}
@Override
public MCRecipeType getRecipeType() {
return MCRecipeType.FURNACE;
@@ -1292,17 +1292,17 @@ public Construct recipe(MCRecipe r, Target t) {
ret.set("type", new CString(r.getRecipeType().name(), t), t);
ret.set("result", item(r.getResult(), t), t);
if(r instanceof MCFurnaceRecipe) {
ret.set("input", item(((MCFurnaceRecipe) r).getInput(), t), t);
MCFurnaceRecipe furnace = (MCFurnaceRecipe) r;
ret.set("input", item(furnace.getInput(), t), t);
ret.set("key", furnace.getKey(), t);
} else if(r instanceof MCShapelessRecipe) {
MCShapelessRecipe shapeless = (MCShapelessRecipe) r;
CArray il = new CArray(t);
for(MCItemStack i : shapeless.getIngredients()) {
il.push(item(i, t), t);
}
ret.set("ingredients", il, t);
if(shapeless.getKey() != null) {
ret.set("key", shapeless.getKey(), t);
}
ret.set("key", shapeless.getKey(), t);
} else if(r instanceof MCShapedRecipe) {
MCShapedRecipe shaped = (MCShapedRecipe) r;
CArray shape = new CArray(t);
@@ -1315,9 +1315,7 @@ public Construct recipe(MCRecipe r, Target t) {
}
ret.set("shape", shape, t);
ret.set("ingredients", imap, t);
if(shaped.getKey() != null) {
ret.set("key", shaped.getKey(), t);
}
ret.set("key", shaped.getKey(), t);
}
return ret;
}
@@ -78,7 +78,7 @@ public String docs() {
+ " The RecipeArray can contain the following keys:"
+ " <pre>"
+ " type: The type of recipe. Expected to be 'SHAPED', 'SHAPELESS', or 'FURNACE'.\n"
+ " key: A unique string for this recipe. (shaped and shapeless recipes; MC 1.12+)\n"
+ " key: A unique string for this recipe.\n"
+ " result: The result item array of the recipe.\n"
+ " shape: The shape of the recipe. Represented as a 3 index normal array. (shaped recipes)\n"
+ " ingredients: Ingredients array of the recipe. See examples. (shaped and shapeless recipes)\n"
@@ -106,6 +106,7 @@ public String docs() {
+ " Furnace Recipe. Turns grass into dirt through smelting."
+ " <pre>"
+ "{\n"
+ " key: 'cook_grass_to_dirt'"
+ " type: 'FURNACE',\n"
+ " result: {name: 'DIRT'},\n"
+ " input: {name: 'GRASS'}\n"

0 comments on commit f6fcd5b

Please sign in to comment.