mirror of
https://github.com/Minestom/Minestom.git
synced 2024-10-01 07:57:41 +02:00
Merge pull request #56 from Minestom/addition-recipes
Add more recipe types and support for Smithing.
This commit is contained in:
commit
81db2dbdf9
@ -44,14 +44,20 @@ public class DeclareRecipesPacket implements ServerPacket {
|
||||
// ++ ingredients
|
||||
// ++ result
|
||||
|
||||
// smelting
|
||||
// smelting, blasting, smoking and campfire
|
||||
// ++ group
|
||||
public Ingredient ingredient;
|
||||
// ++ ingredient
|
||||
// ++ result
|
||||
public float experience;
|
||||
public int cookingTime;
|
||||
|
||||
// smithing
|
||||
// ++ ingredient (base)
|
||||
public Ingredient additionIngredient;
|
||||
// ++ result
|
||||
|
||||
|
||||
public Ingredient ingredient;
|
||||
public Ingredient[] ingredients;
|
||||
public ItemStack result;
|
||||
|
||||
@ -80,7 +86,10 @@ public class DeclareRecipesPacket implements ServerPacket {
|
||||
writer.writeItemStack(result);
|
||||
break;
|
||||
}
|
||||
case "smelting": {
|
||||
case "smelting":
|
||||
case "blasting":
|
||||
case "smoking":
|
||||
case "campfire_cooking": {
|
||||
writer.writeSizedString(group);
|
||||
ingredient.write(writer);
|
||||
writer.writeItemStack(result);
|
||||
@ -94,9 +103,14 @@ public class DeclareRecipesPacket implements ServerPacket {
|
||||
writer.writeItemStack(result);
|
||||
break;
|
||||
}
|
||||
case "smithing": {
|
||||
ingredient.write(writer);
|
||||
additionIngredient.write(writer);
|
||||
writer.writeItemStack(result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Ingredient {
|
||||
|
52
src/main/java/net/minestom/server/recipe/BlastingRecipe.java
Normal file
52
src/main/java/net/minestom/server/recipe/BlastingRecipe.java
Normal file
@ -0,0 +1,52 @@
|
||||
package net.minestom.server.recipe;
|
||||
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.network.packet.server.play.DeclareRecipesPacket;
|
||||
|
||||
public abstract class BlastingRecipe extends Recipe {
|
||||
|
||||
private DeclareRecipesPacket.Ingredient ingredient;
|
||||
|
||||
private ItemStack result = ItemStack.getAirItem();
|
||||
|
||||
private float experience;
|
||||
|
||||
private int cookingTime;
|
||||
|
||||
public BlastingRecipe(String recipeId, String group) {
|
||||
super(RecipeType.SMELTING, recipeId);
|
||||
setGroup(group);
|
||||
}
|
||||
|
||||
public DeclareRecipesPacket.Ingredient getIngredient() {
|
||||
return ingredient;
|
||||
}
|
||||
|
||||
public void setIngredient(DeclareRecipesPacket.Ingredient ingredient) {
|
||||
this.ingredient = ingredient;
|
||||
}
|
||||
|
||||
public ItemStack getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(ItemStack result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public float getExperience() {
|
||||
return experience;
|
||||
}
|
||||
|
||||
public void setExperience(float experience) {
|
||||
this.experience = experience;
|
||||
}
|
||||
|
||||
public int getCookingTime() {
|
||||
return cookingTime;
|
||||
}
|
||||
|
||||
public void setCookingTime(int cookingTime) {
|
||||
this.cookingTime = cookingTime;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package net.minestom.server.recipe;
|
||||
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.network.packet.server.play.DeclareRecipesPacket;
|
||||
|
||||
public abstract class CampfireCookingRecipe extends Recipe {
|
||||
|
||||
private DeclareRecipesPacket.Ingredient ingredient;
|
||||
|
||||
private ItemStack result = ItemStack.getAirItem();
|
||||
|
||||
private float experience;
|
||||
|
||||
private int cookingTime;
|
||||
|
||||
public CampfireCookingRecipe(String recipeId, String group) {
|
||||
super(RecipeType.SMELTING, recipeId);
|
||||
setGroup(group);
|
||||
}
|
||||
|
||||
public DeclareRecipesPacket.Ingredient getIngredient() {
|
||||
return ingredient;
|
||||
}
|
||||
|
||||
public void setIngredient(DeclareRecipesPacket.Ingredient ingredient) {
|
||||
this.ingredient = ingredient;
|
||||
}
|
||||
|
||||
public ItemStack getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(ItemStack result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public float getExperience() {
|
||||
return experience;
|
||||
}
|
||||
|
||||
public void setExperience(float experience) {
|
||||
this.experience = experience;
|
||||
}
|
||||
|
||||
public int getCookingTime() {
|
||||
return cookingTime;
|
||||
}
|
||||
|
||||
public void setCookingTime(int cookingTime) {
|
||||
this.cookingTime = cookingTime;
|
||||
}
|
||||
}
|
@ -32,7 +32,14 @@ public abstract class Recipe {
|
||||
}
|
||||
|
||||
protected enum RecipeType {
|
||||
SHAPELESS, SHAPED, SMELTING, STONECUTTER
|
||||
SHAPELESS,
|
||||
SHAPED,
|
||||
SMELTING,
|
||||
BLASTING,
|
||||
SMOKING,
|
||||
CAMPFIRE_COOKING,
|
||||
STONECUTTING,
|
||||
SMITHING
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,7 +46,9 @@ public class RecipeManager {
|
||||
case SHAPELESS: {
|
||||
packetRecipe.recipeType = "crafting_shapeless";
|
||||
packetRecipe.group = recipe.getGroup();
|
||||
|
||||
ShapelessRecipe shapelessRecipe = (ShapelessRecipe) recipe;
|
||||
|
||||
List<DeclareRecipesPacket.Ingredient> ingredients = shapelessRecipe.getIngredients();
|
||||
packetRecipe.ingredients = ingredients.toArray(new DeclareRecipesPacket.Ingredient[0]);
|
||||
packetRecipe.result = shapelessRecipe.getResult();
|
||||
@ -55,7 +57,9 @@ public class RecipeManager {
|
||||
case SHAPED: {
|
||||
packetRecipe.recipeType = "crafting_shaped";
|
||||
packetRecipe.group = recipe.getGroup();
|
||||
|
||||
ShapedRecipe shapedRecipe = (ShapedRecipe) recipe;
|
||||
|
||||
List<DeclareRecipesPacket.Ingredient> ingredients2 = shapedRecipe.getIngredients();
|
||||
packetRecipe.ingredients = ingredients2.toArray(new DeclareRecipesPacket.Ingredient[0]);
|
||||
packetRecipe.result = shapedRecipe.getResult();
|
||||
@ -64,21 +68,71 @@ public class RecipeManager {
|
||||
case SMELTING: {
|
||||
packetRecipe.recipeType = "smelting";
|
||||
packetRecipe.group = recipe.getGroup();
|
||||
|
||||
SmeltingRecipe smeltingRecipe = (SmeltingRecipe) recipe;
|
||||
|
||||
packetRecipe.ingredient = smeltingRecipe.getIngredient();
|
||||
packetRecipe.result = smeltingRecipe.getResult();
|
||||
packetRecipe.experience = smeltingRecipe.getExperience();
|
||||
packetRecipe.cookingTime = smeltingRecipe.getCookingTime();
|
||||
break;
|
||||
}
|
||||
case STONECUTTER: {
|
||||
case BLASTING: {
|
||||
packetRecipe.recipeType = "blasting";
|
||||
packetRecipe.group = recipe.getGroup();
|
||||
|
||||
BlastingRecipe blastingRecipe = (BlastingRecipe) recipe;
|
||||
|
||||
packetRecipe.ingredient = blastingRecipe.getIngredient();
|
||||
packetRecipe.result = blastingRecipe.getResult();
|
||||
packetRecipe.experience = blastingRecipe.getExperience();
|
||||
packetRecipe.cookingTime = blastingRecipe.getCookingTime();
|
||||
break;
|
||||
}
|
||||
case SMOKING: {
|
||||
packetRecipe.recipeType = "smoking";
|
||||
packetRecipe.group = recipe.getGroup();
|
||||
|
||||
SmokingRecipe smokingRecipe = (SmokingRecipe) recipe;
|
||||
|
||||
packetRecipe.ingredient = smokingRecipe.getIngredient();
|
||||
packetRecipe.result = smokingRecipe.getResult();
|
||||
packetRecipe.experience = smokingRecipe.getExperience();
|
||||
packetRecipe.cookingTime = smokingRecipe.getCookingTime();
|
||||
break;
|
||||
}
|
||||
case CAMPFIRE_COOKING: {
|
||||
packetRecipe.recipeType = "campfire_cooking";
|
||||
packetRecipe.group = recipe.getGroup();
|
||||
|
||||
CampfireCookingRecipe campfireCookingRecipe = (CampfireCookingRecipe) recipe;
|
||||
|
||||
packetRecipe.ingredient = campfireCookingRecipe.getIngredient();
|
||||
packetRecipe.result = campfireCookingRecipe.getResult();
|
||||
packetRecipe.experience = campfireCookingRecipe.getExperience();
|
||||
packetRecipe.cookingTime = campfireCookingRecipe.getCookingTime();
|
||||
break;
|
||||
}
|
||||
case STONECUTTING: {
|
||||
packetRecipe.recipeType = "stonecutting";
|
||||
packetRecipe.group = recipe.getGroup();
|
||||
|
||||
StonecutterRecipe stonecuttingRecipe = (StonecutterRecipe) recipe;
|
||||
|
||||
packetRecipe.ingredient = stonecuttingRecipe.getIngredient();
|
||||
packetRecipe.result = stonecuttingRecipe.getResult();
|
||||
break;
|
||||
}
|
||||
case SMITHING: {
|
||||
packetRecipe.recipeType = "smithing";
|
||||
|
||||
SmithingRecipe smithingRecipe = (SmithingRecipe) recipe;
|
||||
|
||||
packetRecipe.ingredient = smithingRecipe.getBaseIngredient();
|
||||
packetRecipe.additionIngredient = smithingRecipe.getAdditionIngredient();
|
||||
packetRecipe.result = smithingRecipe.getResult();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
packetRecipe.recipeId = recipe.recipeId;
|
||||
|
41
src/main/java/net/minestom/server/recipe/SmithingRecipe.java
Normal file
41
src/main/java/net/minestom/server/recipe/SmithingRecipe.java
Normal file
@ -0,0 +1,41 @@
|
||||
package net.minestom.server.recipe;
|
||||
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.network.packet.server.play.DeclareRecipesPacket;
|
||||
|
||||
public abstract class SmithingRecipe extends Recipe {
|
||||
|
||||
private DeclareRecipesPacket.Ingredient baseIngredient;
|
||||
private DeclareRecipesPacket.Ingredient additionIngredient;
|
||||
|
||||
private ItemStack result = ItemStack.getAirItem();
|
||||
|
||||
protected SmithingRecipe(String recipeId, String group) {
|
||||
super(RecipeType.SMITHING, recipeId);
|
||||
setGroup(group);
|
||||
}
|
||||
|
||||
public DeclareRecipesPacket.Ingredient getBaseIngredient() {
|
||||
return baseIngredient;
|
||||
}
|
||||
|
||||
public void setBaseIngredient(DeclareRecipesPacket.Ingredient baseIngredient) {
|
||||
this.baseIngredient = baseIngredient;
|
||||
}
|
||||
|
||||
public DeclareRecipesPacket.Ingredient getAdditionIngredient() {
|
||||
return additionIngredient;
|
||||
}
|
||||
|
||||
public void setAdditionIngredient(DeclareRecipesPacket.Ingredient additionIngredient) {
|
||||
this.additionIngredient = additionIngredient;
|
||||
}
|
||||
|
||||
public ItemStack getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(ItemStack result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
52
src/main/java/net/minestom/server/recipe/SmokingRecipe.java
Normal file
52
src/main/java/net/minestom/server/recipe/SmokingRecipe.java
Normal file
@ -0,0 +1,52 @@
|
||||
package net.minestom.server.recipe;
|
||||
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.network.packet.server.play.DeclareRecipesPacket;
|
||||
|
||||
public abstract class SmokingRecipe extends Recipe {
|
||||
|
||||
private DeclareRecipesPacket.Ingredient ingredient;
|
||||
|
||||
private ItemStack result = ItemStack.getAirItem();
|
||||
|
||||
private float experience;
|
||||
|
||||
private int cookingTime;
|
||||
|
||||
public SmokingRecipe(String recipeId, String group) {
|
||||
super(RecipeType.SMELTING, recipeId);
|
||||
setGroup(group);
|
||||
}
|
||||
|
||||
public DeclareRecipesPacket.Ingredient getIngredient() {
|
||||
return ingredient;
|
||||
}
|
||||
|
||||
public void setIngredient(DeclareRecipesPacket.Ingredient ingredient) {
|
||||
this.ingredient = ingredient;
|
||||
}
|
||||
|
||||
public ItemStack getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(ItemStack result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public float getExperience() {
|
||||
return experience;
|
||||
}
|
||||
|
||||
public void setExperience(float experience) {
|
||||
this.experience = experience;
|
||||
}
|
||||
|
||||
public int getCookingTime() {
|
||||
return cookingTime;
|
||||
}
|
||||
|
||||
public void setCookingTime(int cookingTime) {
|
||||
this.cookingTime = cookingTime;
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ public abstract class StonecutterRecipe extends Recipe {
|
||||
private ItemStack result = ItemStack.getAirItem();
|
||||
|
||||
protected StonecutterRecipe(String recipeId, String group) {
|
||||
super(RecipeType.STONECUTTER, recipeId);
|
||||
super(RecipeType.STONECUTTING, recipeId);
|
||||
setGroup(group);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user