java类org.bukkit.inventory.Recipe的实例源码

CraftingModule.java 文件源码 项目:ProjectAres 阅读 26 收藏 0 点赞 0 评论 0
public Recipe parseSmeltingRecipe(MapModuleContext context, Element elRecipe) throws InvalidXMLException {
    MaterialPattern ingredient = XMLUtils.parseMaterialPattern(XMLUtils.getRequiredUniqueChild(elRecipe, "ingredient", "i"));
    ItemStack result = parseRecipeResult(context, elRecipe);
    if(ingredient.dataMatters()) {
        return new FurnaceRecipe(result, ingredient.getMaterialData());
    } else {
        return new FurnaceRecipe(result, ingredient.getMaterial());
    }
}
SimpleWand.java 文件源码 项目:MystiCraft 阅读 20 收藏 0 点赞 0 评论 0
@Override
public Recipe getRecipe() {
    ShapedRecipe r = new ShapedRecipe(baseItem);
    r.shape("  x", " y ", "x  ");
    r.setIngredient('x', Material.REDSTONE);
    r.setIngredient('y', Material.STICK);
    return r;
}
CraftUtils.java 文件源码 项目:Transport-Pipes 阅读 22 收藏 0 点赞 0 评论 0
@EventHandler
public void onPrepareCraft(PrepareItemCraftEvent e) {

    Recipe r = e.getInventory().getRecipe();
    if (r == null || e.getViewers().size() != 1) {
        return;
    }

    Player viewer = (Player) e.getViewers().get(0);

    if (r.getResult() != null) {
        DuctDetails ductDetails = DuctItemUtils.getDuctDetailsOfItem(r.getResult());
        if (ductDetails != null) {
            if (!viewer.hasPermission(ductDetails.getCraftPermission())) {
                e.getInventory().setResult(null);
                return;
            }
        } else if (DuctItemUtils.getWrenchItem().isSimilar(r.getResult())) {
            if (!viewer.hasPermission("transportpipes.craft.wrench")) {
                e.getInventory().setResult(null);
                return;
            }
        }

        if (ductDetails != null && ductDetails.getDuctType() == DuctType.PIPE) {
            boolean prevent = false;
            for (int i = 1; i < 10; i++) {
                ItemStack is = e.getInventory().getItem(i);
                if (is != null && is.getType() == Material.SKULL_ITEM && is.getDurability() == SkullType.PLAYER.ordinal()) {
                    DuctDetails isDuctDetails = DuctItemUtils.getDuctDetailsOfItem(is);
                    prevent |= isDuctDetails == null;
                }
            }
            if (prevent) {
                e.getInventory().setResult(null);
            }
        }
    }
}
NoSwordModule.java 文件源码 项目:SurvivalAPI 阅读 25 收藏 0 点赞 0 评论 0
private static void onCraftItem(Recipe recipe, CraftingInventory inventory)
{
    if (recipe.getResult().getType() == Material.WOOD_SWORD
            || recipe.getResult().getType() == Material.STONE_SWORD
            || recipe.getResult().getType() == Material.IRON_SWORD
            || recipe.getResult().getType() == Material.GOLD_SWORD
            || recipe.getResult().getType() == Material.DIAMOND_SWORD)
        inventory.setResult(new ItemStack(Material.AIR));
}
RapidToolsModule.java 文件源码 项目:SurvivalAPI 阅读 25 收藏 0 点赞 0 评论 0
private void onCraftItem(Recipe recipe, CraftingInventory inventory)
{
    if (recipe.getResult().getType() == Material.WOOD_SWORD)
        inventory.setResult(new ItemStack(this.getMaterial(Material.WOOD_SWORD)));
    else if (recipe.getResult().getType() == Material.WOOD_PICKAXE)
        inventory.setResult(new ItemStack(this.getMaterial(Material.WOOD_PICKAXE)));
    else if (recipe.getResult().getType() == Material.WOOD_AXE)
        inventory.setResult(new ItemStack(this.getMaterial(Material.WOOD_AXE)));
    else if (recipe.getResult().getType() == Material.WOOD_SPADE)
        inventory.setResult(new ItemStack(this.getMaterial(Material.WOOD_SPADE)));
}
EnderChestRemovalListener.java 文件源码 项目:HCFCore 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Removes the ender-chest crafting recipe from the server meaning it can only be obtained from creative mode.
 */
private void removeRecipe() {
    for (Iterator<Recipe> iterator = Bukkit.recipeIterator(); iterator.hasNext();) {
        if (iterator.next().getResult().getType() == Material.ENDER_CHEST) {
            iterator.remove();
        }
    }
}
EnderChestRemovalListener.java 文件源码 项目:HCFCore 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Removes the ender-chest crafting recipe from the server meaning it can only be obtained from creative mode.
 */
private void removeRecipe() {
    for (Iterator<Recipe> iterator = Bukkit.recipeIterator(); iterator.hasNext();) {
        if (iterator.next().getResult().getType() == Material.ENDER_CHEST) {
            iterator.remove();
        }
    }
}
FlexWorkbenchInventory.java 文件源码 项目:FlexMC 阅读 26 收藏 0 点赞 0 评论 0
@Override
protected void setRawSlot( short slot, ItemStack itemStack ) {
    this.setItem( slot, itemStack );
    if( slot > 0 ) {
        me.lukas81298.flexmc.inventory.crafting.Recipe recipe = Flex.getServer().getRecipeManager().getRecipe( this );
        if( recipe != null ) {
            setItem( 0, recipe.getResult() );
        }
    }
}
CraftInventoryCrafting.java 文件源码 项目:ThermosRebased 阅读 22 收藏 0 点赞 0 评论 0
public Recipe getRecipe() {
    net.minecraft.item.crafting.IRecipe recipe = ((net.minecraft.inventory.InventoryCrafting)getInventory()).currentRecipe;
    // Cauldron start - handle custom recipe classes without Bukkit API equivalents
    try {
        return recipe == null ? null : recipe.toBukkitRecipe();
    } catch (AbstractMethodError ex) {
        // No Bukkit wrapper provided
        return new CustomModRecipe(recipe);
    }
    // Cauldron end
}
RecipeManager.java 文件源码 项目:CS-CoreLib 阅读 25 收藏 0 点赞 0 评论 0
public static void removeRecipe(Material type) {
    Iterator<Recipe> recipes = Bukkit.recipeIterator();
    Recipe recipe;
    while (recipes.hasNext()) {
        recipe = recipes.next();
        if (recipe != null && recipe.getResult().getType() == type) {
            recipes.remove();
        }
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号