mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-01 05:58:00 +01:00
Merge pull request #28 from Minestom/add-stonecutting-recipes
Add recipes for Stonecutters.
This commit is contained in:
commit
cd1a936ede
@ -61,7 +61,7 @@ public class DeclareRecipesPacket implements ServerPacket {
|
||||
writer.writeSizedString(recipeId);
|
||||
|
||||
switch (recipeType) {
|
||||
case "crafting_shapeless":
|
||||
case "crafting_shapeless": {
|
||||
writer.writeSizedString(group);
|
||||
writer.writeVarInt(ingredients.length);
|
||||
for (Ingredient ingredient : ingredients) {
|
||||
@ -69,7 +69,8 @@ public class DeclareRecipesPacket implements ServerPacket {
|
||||
}
|
||||
writer.writeItemStack(result);
|
||||
break;
|
||||
case "crafting_shaped":
|
||||
}
|
||||
case "crafting_shaped": {
|
||||
writer.writeVarInt(width);
|
||||
writer.writeVarInt(height);
|
||||
writer.writeSizedString(group);
|
||||
@ -78,13 +79,21 @@ public class DeclareRecipesPacket implements ServerPacket {
|
||||
}
|
||||
writer.writeItemStack(result);
|
||||
break;
|
||||
case "smelting":
|
||||
}
|
||||
case "smelting": {
|
||||
writer.writeSizedString(group);
|
||||
ingredient.write(writer);
|
||||
writer.writeItemStack(result);
|
||||
writer.writeFloat(experience);
|
||||
writer.writeVarInt(cookingTime);
|
||||
break;
|
||||
}
|
||||
case "stonecutting": {
|
||||
writer.writeSizedString(group);
|
||||
ingredient.write(writer);
|
||||
writer.writeItemStack(result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ public abstract class Recipe {
|
||||
}
|
||||
|
||||
protected enum RecipeType {
|
||||
SHAPELESS, SHAPED, SMELTING
|
||||
SHAPELESS, SHAPED, SMELTING, STONECUTTER
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class RecipeManager {
|
||||
DeclareRecipesPacket.Recipe packetRecipe = new DeclareRecipesPacket.Recipe();
|
||||
|
||||
switch (recipe.recipeType) {
|
||||
case SHAPELESS:
|
||||
case SHAPELESS: {
|
||||
packetRecipe.recipeType = "crafting_shapeless";
|
||||
packetRecipe.group = recipe.getGroup();
|
||||
ShapelessRecipe shapelessRecipe = (ShapelessRecipe) recipe;
|
||||
@ -51,7 +51,8 @@ public class RecipeManager {
|
||||
packetRecipe.ingredients = ingredients.toArray(new DeclareRecipesPacket.Ingredient[0]);
|
||||
packetRecipe.result = shapelessRecipe.getResult();
|
||||
break;
|
||||
case SHAPED:
|
||||
}
|
||||
case SHAPED: {
|
||||
packetRecipe.recipeType = "crafting_shaped";
|
||||
packetRecipe.group = recipe.getGroup();
|
||||
ShapedRecipe shapedRecipe = (ShapedRecipe) recipe;
|
||||
@ -59,7 +60,8 @@ public class RecipeManager {
|
||||
packetRecipe.ingredients = ingredients2.toArray(new DeclareRecipesPacket.Ingredient[0]);
|
||||
packetRecipe.result = shapedRecipe.getResult();
|
||||
break;
|
||||
case SMELTING:
|
||||
}
|
||||
case SMELTING: {
|
||||
packetRecipe.recipeType = "smelting";
|
||||
packetRecipe.group = recipe.getGroup();
|
||||
SmeltingRecipe smeltingRecipe = (SmeltingRecipe) recipe;
|
||||
@ -68,6 +70,15 @@ public class RecipeManager {
|
||||
packetRecipe.experience = smeltingRecipe.getExperience();
|
||||
packetRecipe.cookingTime = smeltingRecipe.getCookingTime();
|
||||
break;
|
||||
}
|
||||
case STONECUTTER: {
|
||||
packetRecipe.recipeType = "stonecutting";
|
||||
packetRecipe.group = recipe.getGroup();
|
||||
StonecutterRecipe stonecuttingRecipe = (StonecutterRecipe) recipe;
|
||||
packetRecipe.ingredient = stonecuttingRecipe.getIngredient();
|
||||
packetRecipe.result = stonecuttingRecipe.getResult();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
packetRecipe.recipeId = recipe.recipeId;
|
||||
|
@ -0,0 +1,32 @@
|
||||
package net.minestom.server.recipe;
|
||||
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.network.packet.server.play.DeclareRecipesPacket;
|
||||
|
||||
public abstract class StonecutterRecipe extends Recipe {
|
||||
|
||||
private DeclareRecipesPacket.Ingredient ingredient;
|
||||
|
||||
private ItemStack result = ItemStack.getAirItem();
|
||||
|
||||
protected StonecutterRecipe(String recipeId, String group) {
|
||||
super(RecipeType.STONECUTTER, 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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user