mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-11-14 19:34:58 -05:00
Fix recipes
This commit is contained in:
parent
85cd8aebc1
commit
609aaf9222
8 changed files with 55 additions and 8 deletions
|
@ -472,7 +472,6 @@ public class MagicValues {
|
||||||
register(RecipeType.CRAFTING_SPECIAL_REPAIRITEM, "minecraft:crafting_special_repairitem");
|
register(RecipeType.CRAFTING_SPECIAL_REPAIRITEM, "minecraft:crafting_special_repairitem");
|
||||||
register(RecipeType.CRAFTING_SPECIAL_TIPPEDARROW, "minecraft:crafting_special_tippedarrow");
|
register(RecipeType.CRAFTING_SPECIAL_TIPPEDARROW, "minecraft:crafting_special_tippedarrow");
|
||||||
register(RecipeType.CRAFTING_SPECIAL_BANNERDUPLICATE, "minecraft:crafting_special_bannerduplicate");
|
register(RecipeType.CRAFTING_SPECIAL_BANNERDUPLICATE, "minecraft:crafting_special_bannerduplicate");
|
||||||
register(RecipeType.CRAFTING_SPECIAL_BANNERADDPATTERN, "minecraft:crafting_special_banneraddpattern");
|
|
||||||
register(RecipeType.CRAFTING_SPECIAL_SHIELDDECORATION, "minecraft:crafting_special_shielddecoration");
|
register(RecipeType.CRAFTING_SPECIAL_SHIELDDECORATION, "minecraft:crafting_special_shielddecoration");
|
||||||
register(RecipeType.CRAFTING_SPECIAL_SHULKERBOXCOLORING, "minecraft:crafting_special_shulkerboxcoloring");
|
register(RecipeType.CRAFTING_SPECIAL_SHULKERBOXCOLORING, "minecraft:crafting_special_shulkerboxcoloring");
|
||||||
register(RecipeType.CRAFTING_SPECIAL_SUSPICIOUSSTEW, "minecraft:crafting_special_suspiciousstew");
|
register(RecipeType.CRAFTING_SPECIAL_SUSPICIOUSSTEW, "minecraft:crafting_special_suspiciousstew");
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.github.steveice10.mc.protocol.data.game.recipe;
|
||||||
|
|
||||||
|
public enum CraftingBookCategory {
|
||||||
|
BUILDING,
|
||||||
|
REDSTONE,
|
||||||
|
EQUIPMENT,
|
||||||
|
MISC;
|
||||||
|
|
||||||
|
private static final CraftingBookCategory[] VALUES = values();
|
||||||
|
|
||||||
|
|
||||||
|
public static CraftingBookCategory from(int id) {
|
||||||
|
return VALUES[id];
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package com.github.steveice10.mc.protocol.data.game.recipe;
|
package com.github.steveice10.mc.protocol.data.game.recipe;
|
||||||
|
|
||||||
public enum RecipeType {
|
public enum RecipeType {
|
||||||
CRAFTING_SHAPELESS,
|
|
||||||
CRAFTING_SHAPED,
|
CRAFTING_SHAPED,
|
||||||
|
CRAFTING_SHAPELESS,
|
||||||
CRAFTING_SPECIAL_ARMORDYE,
|
CRAFTING_SPECIAL_ARMORDYE,
|
||||||
CRAFTING_SPECIAL_BOOKCLONING,
|
CRAFTING_SPECIAL_BOOKCLONING,
|
||||||
CRAFTING_SPECIAL_MAPCLONING,
|
CRAFTING_SPECIAL_MAPCLONING,
|
||||||
|
@ -10,13 +10,13 @@ public enum RecipeType {
|
||||||
CRAFTING_SPECIAL_FIREWORK_ROCKET,
|
CRAFTING_SPECIAL_FIREWORK_ROCKET,
|
||||||
CRAFTING_SPECIAL_FIREWORK_STAR,
|
CRAFTING_SPECIAL_FIREWORK_STAR,
|
||||||
CRAFTING_SPECIAL_FIREWORK_STAR_FADE,
|
CRAFTING_SPECIAL_FIREWORK_STAR_FADE,
|
||||||
CRAFTING_SPECIAL_REPAIRITEM,
|
|
||||||
CRAFTING_SPECIAL_TIPPEDARROW,
|
CRAFTING_SPECIAL_TIPPEDARROW,
|
||||||
CRAFTING_SPECIAL_BANNERDUPLICATE,
|
CRAFTING_SPECIAL_BANNERDUPLICATE,
|
||||||
CRAFTING_SPECIAL_BANNERADDPATTERN,
|
CRAFTING_SPECIAL_BANNERADDPATTERN,
|
||||||
CRAFTING_SPECIAL_SHIELDDECORATION,
|
CRAFTING_SPECIAL_SHIELDDECORATION,
|
||||||
CRAFTING_SPECIAL_SHULKERBOXCOLORING,
|
CRAFTING_SPECIAL_SHULKERBOXCOLORING,
|
||||||
CRAFTING_SPECIAL_SUSPICIOUSSTEW,
|
CRAFTING_SPECIAL_SUSPICIOUSSTEW,
|
||||||
|
CRAFTING_SPECIAL_REPAIRITEM,
|
||||||
SMELTING,
|
SMELTING,
|
||||||
BLASTING,
|
BLASTING,
|
||||||
SMOKING,
|
SMOKING,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.github.steveice10.mc.protocol.data.game.recipe.data;
|
package com.github.steveice10.mc.protocol.data.game.recipe.data;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.recipe.CraftingBookCategory;
|
||||||
import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient;
|
import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -10,6 +11,7 @@ import lombok.NonNull;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class CookedRecipeData implements RecipeData {
|
public class CookedRecipeData implements RecipeData {
|
||||||
private final @NonNull String group;
|
private final @NonNull String group;
|
||||||
|
private final @NonNull CraftingBookCategory category;
|
||||||
private final @NonNull Ingredient ingredient;
|
private final @NonNull Ingredient ingredient;
|
||||||
private final ItemStack result;
|
private final ItemStack result;
|
||||||
private final float experience;
|
private final float experience;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.github.steveice10.mc.protocol.data.game.recipe.data;
|
package com.github.steveice10.mc.protocol.data.game.recipe.data;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.recipe.CraftingBookCategory;
|
||||||
import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient;
|
import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -12,6 +13,7 @@ public class ShapedRecipeData implements RecipeData {
|
||||||
private final int width;
|
private final int width;
|
||||||
private final int height;
|
private final int height;
|
||||||
private final @NonNull String group;
|
private final @NonNull String group;
|
||||||
|
private final @NonNull CraftingBookCategory category;
|
||||||
private final @NonNull Ingredient[] ingredients;
|
private final @NonNull Ingredient[] ingredients;
|
||||||
private final ItemStack result;
|
private final ItemStack result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.github.steveice10.mc.protocol.data.game.recipe.data;
|
package com.github.steveice10.mc.protocol.data.game.recipe.data;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.recipe.CraftingBookCategory;
|
||||||
import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient;
|
import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -10,6 +11,7 @@ import lombok.NonNull;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class ShapelessRecipeData implements RecipeData {
|
public class ShapelessRecipeData implements RecipeData {
|
||||||
private final @NonNull String group;
|
private final @NonNull String group;
|
||||||
|
private final @NonNull CraftingBookCategory category;
|
||||||
private final @NonNull Ingredient[] ingredients;
|
private final @NonNull Ingredient[] ingredients;
|
||||||
private final ItemStack result;
|
private final ItemStack result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.github.steveice10.mc.protocol.data.game.recipe.data;
|
||||||
|
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.recipe.CraftingBookCategory;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NonNull;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class SimpleCraftingRecipeData implements RecipeData {
|
||||||
|
private final @NonNull CraftingBookCategory category;
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
|
||||||
import com.github.steveice10.mc.protocol.data.MagicValues;
|
import com.github.steveice10.mc.protocol.data.MagicValues;
|
||||||
import com.github.steveice10.mc.protocol.data.game.Identifier;
|
import com.github.steveice10.mc.protocol.data.game.Identifier;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.recipe.CraftingBookCategory;
|
||||||
import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient;
|
import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient;
|
||||||
import com.github.steveice10.mc.protocol.data.game.recipe.Recipe;
|
import com.github.steveice10.mc.protocol.data.game.recipe.Recipe;
|
||||||
import com.github.steveice10.mc.protocol.data.game.recipe.RecipeType;
|
import com.github.steveice10.mc.protocol.data.game.recipe.RecipeType;
|
||||||
|
@ -32,6 +33,7 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case CRAFTING_SHAPELESS: {
|
case CRAFTING_SHAPELESS: {
|
||||||
String group = helper.readString(in);
|
String group = helper.readString(in);
|
||||||
|
CraftingBookCategory category = CraftingBookCategory.from(helper.readVarInt(in));
|
||||||
Ingredient[] ingredients = new Ingredient[helper.readVarInt(in)];
|
Ingredient[] ingredients = new Ingredient[helper.readVarInt(in)];
|
||||||
for (int j = 0; j < ingredients.length; j++) {
|
for (int j = 0; j < ingredients.length; j++) {
|
||||||
ingredients[j] = helper.readRecipeIngredient(in);
|
ingredients[j] = helper.readRecipeIngredient(in);
|
||||||
|
@ -39,13 +41,14 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket {
|
||||||
|
|
||||||
ItemStack result = helper.readItemStack(in);
|
ItemStack result = helper.readItemStack(in);
|
||||||
|
|
||||||
data = new ShapelessRecipeData(group, ingredients, result);
|
data = new ShapelessRecipeData(group, category, ingredients, result);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CRAFTING_SHAPED: {
|
case CRAFTING_SHAPED: {
|
||||||
int width = helper.readVarInt(in);
|
int width = helper.readVarInt(in);
|
||||||
int height = helper.readVarInt(in);
|
int height = helper.readVarInt(in);
|
||||||
String group = helper.readString(in);
|
String group = helper.readString(in);
|
||||||
|
CraftingBookCategory category = CraftingBookCategory.from(helper.readVarInt(in));
|
||||||
Ingredient[] ingredients = new Ingredient[width * height];
|
Ingredient[] ingredients = new Ingredient[width * height];
|
||||||
for (int j = 0; j < ingredients.length; j++) {
|
for (int j = 0; j < ingredients.length; j++) {
|
||||||
ingredients[j] = helper.readRecipeIngredient(in);
|
ingredients[j] = helper.readRecipeIngredient(in);
|
||||||
|
@ -53,7 +56,7 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket {
|
||||||
|
|
||||||
ItemStack result = helper.readItemStack(in);
|
ItemStack result = helper.readItemStack(in);
|
||||||
|
|
||||||
data = new ShapedRecipeData(width, height, group, ingredients, result);
|
data = new ShapedRecipeData(width, height, group, category, ingredients, result);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SMELTING:
|
case SMELTING:
|
||||||
|
@ -61,12 +64,13 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket {
|
||||||
case SMOKING:
|
case SMOKING:
|
||||||
case CAMPFIRE_COOKING: {
|
case CAMPFIRE_COOKING: {
|
||||||
String group = helper.readString(in);
|
String group = helper.readString(in);
|
||||||
|
CraftingBookCategory category = CraftingBookCategory.from(helper.readVarInt(in));
|
||||||
Ingredient ingredient = helper.readRecipeIngredient(in);
|
Ingredient ingredient = helper.readRecipeIngredient(in);
|
||||||
ItemStack result = helper.readItemStack(in);
|
ItemStack result = helper.readItemStack(in);
|
||||||
float experience = in.readFloat();
|
float experience = in.readFloat();
|
||||||
int cookingTime = helper.readVarInt(in);
|
int cookingTime = helper.readVarInt(in);
|
||||||
|
|
||||||
data = new CookedRecipeData(group, ingredient, result, experience, cookingTime);
|
data = new CookedRecipeData(group, category, ingredient, result, experience, cookingTime);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case STONECUTTING: {
|
case STONECUTTING: {
|
||||||
|
@ -85,8 +89,12 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket {
|
||||||
data = new SmithingRecipeData(base, addition, result);
|
data = new SmithingRecipeData(base, addition, result);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default: {
|
||||||
|
CraftingBookCategory category = CraftingBookCategory.from(helper.readVarInt(in));
|
||||||
|
|
||||||
|
data = new SimpleCraftingRecipeData(category);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.recipes[i] = new Recipe(type, identifier, data);
|
this.recipes[i] = new Recipe(type, identifier, data);
|
||||||
|
@ -104,6 +112,7 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket {
|
||||||
ShapelessRecipeData data = (ShapelessRecipeData) recipe.getData();
|
ShapelessRecipeData data = (ShapelessRecipeData) recipe.getData();
|
||||||
|
|
||||||
helper.writeString(out, data.getGroup());
|
helper.writeString(out, data.getGroup());
|
||||||
|
helper.writeVarInt(out, data.getCategory().ordinal());
|
||||||
helper.writeVarInt(out, data.getIngredients().length);
|
helper.writeVarInt(out, data.getIngredients().length);
|
||||||
for (Ingredient ingredient : data.getIngredients()) {
|
for (Ingredient ingredient : data.getIngredients()) {
|
||||||
helper.writeRecipeIngredient(out, ingredient);
|
helper.writeRecipeIngredient(out, ingredient);
|
||||||
|
@ -121,6 +130,7 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket {
|
||||||
helper.writeVarInt(out, data.getWidth());
|
helper.writeVarInt(out, data.getWidth());
|
||||||
helper.writeVarInt(out, data.getHeight());
|
helper.writeVarInt(out, data.getHeight());
|
||||||
helper.writeString(out, data.getGroup());
|
helper.writeString(out, data.getGroup());
|
||||||
|
helper.writeVarInt(out, data.getCategory().ordinal());
|
||||||
for (Ingredient ingredient : data.getIngredients()) {
|
for (Ingredient ingredient : data.getIngredients()) {
|
||||||
helper.writeRecipeIngredient(out, ingredient);
|
helper.writeRecipeIngredient(out, ingredient);
|
||||||
}
|
}
|
||||||
|
@ -135,6 +145,7 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket {
|
||||||
CookedRecipeData data = (CookedRecipeData) recipe.getData();
|
CookedRecipeData data = (CookedRecipeData) recipe.getData();
|
||||||
|
|
||||||
helper.writeString(out, data.getGroup());
|
helper.writeString(out, data.getGroup());
|
||||||
|
helper.writeVarInt(out, data.getCategory().ordinal());
|
||||||
helper.writeRecipeIngredient(out, data.getIngredient());
|
helper.writeRecipeIngredient(out, data.getIngredient());
|
||||||
helper.writeItemStack(out, data.getResult());
|
helper.writeItemStack(out, data.getResult());
|
||||||
out.writeFloat(data.getExperience());
|
out.writeFloat(data.getExperience());
|
||||||
|
@ -157,8 +168,12 @@ public class ClientboundUpdateRecipesPacket implements MinecraftPacket {
|
||||||
helper.writeItemStack(out, data.getResult());
|
helper.writeItemStack(out, data.getResult());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default: {
|
||||||
|
SimpleCraftingRecipeData data = (SimpleCraftingRecipeData) recipe.getData();
|
||||||
|
|
||||||
|
helper.writeVarInt(out, data.getCategory().ordinal());
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue