- Баллы
- 123
.
Последнее редактирование:
Следуйте инструкциям в видео ниже, чтобы узнать, как установить наш сайт как веб-приложение на главный экран вашего устройства.
Примечание: Эта функция может быть недоступна в некоторых браузерах.
Recipe.getComponent может бытьПроблема следующая, не один из рецептов не проходит проверку через equals...
Грустно...Проверять по компонентам, схеме и результату, только так.
Ска. Обманул меняСобственно так.
Состряпал я вот такой вот код:
Он вроде даже работает.Код:@Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null) return false; if (obj instanceof ShapedRecipe) { ShapedRecipe shaped_recipe = (ShapedRecipe) obj; if (!TextItemStack.equals(this.getResult(), shaped_recipe.getResult())) return false; for (int i = 0; i < 3; i++) { String my_shape = this.getShape()[i]; String recipe_shape = shaped_recipe.getShape()[i]; if (!my_shape.equals(recipe_shape)) return false; } Map<Character, ItemStack> my_map = this.getIngredientMap(); Map<Character, ItemStack> recipe_map = shaped_recipe.getIngredientMap(); return my_map.equals(recipe_map); } else return false; }
Но только если как "ключи" рецепта использовать ТОЛЬКО символы нижнего регистра.
(Это так для потомков(ну или просто для тех у кого будет такая-же проблема))
P.S. Ну и полный код класса.. На всякий)
Темку тоже оставлю открытой, авось кто решение лучше придумает... Хотя я вроде все сделяль красивенько...Код:package ua.gwm.bukkit_plugin.gwm_library; import org.bukkit.Bukkit; import org.*********ventory.ItemStack; import org.*********ventory.ShapedRecipe; import java.util.Map; public class AdvancedShapedRecipe extends ShapedRecipe { public static final char[] symbols = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'}; private ItemStack[] craft; public AdvancedShapedRecipe(ItemStack result, ItemStack[] craft) { super(result); if (craft.length != 9) throw new RuntimeException("ItemStack[] craft length must be 9."); this.craft = craft; } public void activate() { String[] shapes = {"", "", ""}; for (int i = 0; i < 3; i++) shapes[0] += craft[i] == null ? " " : symbols[i]; for (int i = 3; i < 6; i++) shapes[1] += craft[i] == null ? " " : symbols[i]; for (int i = 6; i < 9; i++) shapes[2] += craft[i] == null ? " " : symbols[i]; shape(shapes); for (int i = 0; i < 9; i++) if (craft[i] != null) setIngredient(symbols[i], craft[i].getType()); Bukkit.getServer().addRecipe(this); } public ItemStack[] getCraft() { return craft; } public void setCraft(ItemStack[] craft) { if (craft.length != 9) throw new RuntimeException("ItemStack[] craft length must be 9."); this.craft = craft; } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null) return false; if (obj instanceof ShapedRecipe) { ShapedRecipe shaped_recipe = (ShapedRecipe) obj; if (!TextItemStack.equals(this.getResult(), shaped_recipe.getResult())) return false; for (int i = 0; i < 3; i++) { String my_shape = this.getShape()[i]; String recipe_shape = shaped_recipe.getShape()[i]; if (!my_shape.equals(recipe_shape)) return false; } Map<Character, ItemStack> my_map = this.getIngredientMap(); Map<Character, ItemStack> recipe_map = shaped_recipe.getIngredientMap(); return my_map.equals(recipe_map); } else return false; } }
Ты про что?Ска. Обманул меня

Это не смешно! прекращай такие шуточкиТы про что?![]()

Какие?Это не смешно! прекращай такие шуточки![]()
