Java 类org.bukkit.event.inventory.FurnaceSmeltEvent 实例源码

项目:Slimefun4-Chinese-Version    文件:FurnaceListener.java   
public void onSmelt(FurnaceSmeltEvent e)
{
    if(BlockStorage.check(e.getBlock()) != null && (BlockStorage.check(e.getBlock()) instanceof EnhancedFurnace))
    {
        EnhancedFurnace furnace = (EnhancedFurnace)BlockStorage.check(e.getBlock());
        Furnace f = (Furnace)e.getBlock().getState();
        int amount = f.getInventory().getSmelting().getType().toString().endsWith("_ORE") ? furnace.getOutput() : 1;
        ItemStack output = RecipeCalculator.getSmeltedOutput(f.getInventory().getSmelting().getType());
        ItemStack result = f.getInventory().getResult();
        if(result != null)
            result = result.clone();
        f.getInventory().setResult(null);
        if(result != null)
            f.getInventory().setResult(new CustomItem(result, result.getAmount() + amount <= result.getMaxStackSize() ? result.getAmount() + amount : result.getMaxStackSize()));
        else
            f.getInventory().setResult(new CustomItem(output, output.getAmount() + amount <= output.getType().getMaxStackSize() ? output.getAmount() + amount : output.getType().getMaxStackSize()));
    }
}
项目:OpenUHC    文件:Overcook.java   
/**
 * Handles the action of smelting all items at once, exploding the furnace, and dropping the smelted items on the
 * ground.
 *
 * @param event The event
 */
@EventHandler(ignoreCancelled = true)
public void onFurnaceSmelt(FurnaceSmeltEvent event) {
  ItemStack resultItem = event.getResult();
  final Material result = resultItem.getType();
  //TODO: Verify that the "smelting amount" contains any extra ingredients
  final int amount = ((Furnace) event.getBlock().getState()).getInventory().getSmelting().getAmount();

  event.getSource().setType(Material.AIR);
  resultItem.setType(Material.AIR);

  Block block = event.getBlock();
  block.setType(Material.AIR);
  Location location = block.getLocation().add(0.5, 0.5, 0.5);
  World world = location.getWorld();
  world.createExplosion(location, 7);
  world.dropItem(location, new ItemStack(result, amount));
}
项目:Skript    文件:ExprFurnaceSlot.java   
@Override
protected Slot[] get(final Event e, final Block[] source) {
    return get(source, new Getter<Slot, Block>() {
        @SuppressWarnings("null")
        @Override
        @Nullable
        public Slot get(final Block b) {
            if (b.getType() != Material.FURNACE && b.getType() != Material.BURNING_FURNACE)
                return null;
            if (getTime() >= 0 && (e instanceof FurnaceSmeltEvent && b.equals(((FurnaceSmeltEvent) e).getBlock()) || e instanceof FurnaceBurnEvent && b.equals(((FurnaceBurnEvent) e).getBlock())) && !Delay.isDelayed(e)) {
                return new FurnaceEventSlot(e, ((Furnace) b.getState()).getInventory());
            } else {
                return new InventorySlot(((Furnace) b.getState()).getInventory(), slot);
            }
        }
    });
}
项目:Pokkit    文件:InventoryEvents.java   
@EventHandler(ignoreCancelled = false)
public void onFurnaceSmelt(cn.nukkit.event.inventory.FurnaceSmeltEvent event) {
    if (canIgnore(FurnaceSmeltEvent.getHandlerList())) {
        return;
    }

    Block furnace = PokkitBlock.toBukkit(event.getBlock());
    ItemStack source = PokkitItemStack.toBukkitCopy(event.getSource());
    ItemStack result = PokkitItemStack.toBukkitCopy(event.getResult());
    FurnaceSmeltEvent bukkitEvent = new FurnaceSmeltEvent(furnace, source, result);

    callCancellable(event, bukkitEvent);

    PokkitItemStack.overwriteNukkit(bukkitEvent.getSource(), event.getSource());
    PokkitItemStack.overwriteNukkit(bukkitEvent.getResult(), event.getResult());
}
项目:McMMOPlus    文件:InventoryListener.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) {
    Block furnaceBlock = event.getBlock();
    ItemStack smelting = event.getSource();

    if (!ItemUtils.isSmeltable(smelting)) {
        return;
    }

    Player player = getPlayerFromFurnace(furnaceBlock);

    if (!UserManager.hasPlayerDataKey(player) || !SkillType.SMELTING.getPermissions(player)) {
        return;
    }

    event.setResult(UserManager.getPlayer(player).getSmeltingManager().smeltProcessing(smelting, event.getResult()));
}
项目:DemigodsRPG    文件:AbilityListener.java   
@EventHandler(priority = EventPriority.LOWEST)
private void onEvent(FurnaceSmeltEvent event) {
    for (PlayerModel model : DGData.PLAYER_R.fromAspect(Aspects.CRAFTING_ASPECT_I)) {
        try {
            if (model.getOnline() && model.getLocation().getWorld().equals(event.getBlock().getWorld()) &&
                    model.getLocation().distance(event.getBlock().getLocation()) <
                            (int) Math.round(20 * Math.pow(model.getExperience(Aspects.CRAFTING_ASPECT_I), 0.15))) {
                int amount = event.getResult().getAmount() * 2;
                ItemStack out = event.getResult();
                out.setAmount(amount);
                event.setResult(out);
            }
        } catch (Exception oops) {
            oops.printStackTrace();
        }
    }
}
项目:CraftFX    文件:RecipeListener.java   
@EventHandler(priority = EventPriority.HIGH)
public void onFurnaceSmelt(FurnaceSmeltEvent event) {
    final List<FXRecipe> recipes = registry.get().getRecipes(event.getResult());
    // Check custom items not used in non-plugin recipes
    if (recipes.isEmpty()) {
        if (registry.get().getDefinition(event.getSource()).isPresent()) {
            event.setCancelled(true);
        }
    }
    // Check if valid furnace recipe
    else if (!recipes.stream().filter(r -> r instanceof FXFurnaceRecipe)
            .map(r -> (FXFurnaceRecipe) r)
                    // Check input matches the recipe
            .filter(r -> registry.get().isSimilar(r.getInput(), event.getSource()))
            .findAny().isPresent()) {
        event.setCancelled(true);
    }
}
项目:EpicQuest    文件:TypeSmelt.java   
@EventHandler
public void OnFurnaceSmelt(FurnaceSmeltEvent event){
    if(!EpicSystem.furnaceList.containsKey(event.getBlock().getLocation())) return;

    EpicPlayer epicPlayer = EpicSystem.furnaceList.get(event.getBlock().getLocation());
    List<EpicQuestTask> taskList = epicPlayer.getTasksByType(TaskTypes.SMELT_ITEM);

    for(EpicQuestTask task : taskList){
        Material itemID = event.getSource().getType();
        Material itemNeeded = Material.matchMaterial(task.getTaskID());

        if(itemID == itemNeeded){
            task.ProgressTask(1, epicPlayer, true);
        }
    }
}
项目:Skript    文件:ExprFurnaceSlot.java   
@SuppressWarnings("synthetic-access")
@Override
public void setItem(final @Nullable ItemStack item) {
    if (e instanceof FurnaceSmeltEvent) {
        if (slot == RESULT && getTime() >= 0) {
            if (item == null || item.getType() == Material.AIR) { // null/air crashes the server on account of a NPE if using event.setResult(...)
                Bukkit.getScheduler().scheduleSyncDelayedTask(Skript.getInstance(), new Runnable() {
                    @Override
                    public void run() {
                        FurnaceEventSlot.super.setItem(null);
                    }
                });
            } else {
                ((FurnaceSmeltEvent) e).setResult(item);
            }
        } else if (slot == ORE && getTime() >= 0) {
            Bukkit.getScheduler().scheduleSyncDelayedTask(Skript.getInstance(), new Runnable() {
                @Override
                public void run() {
                    FurnaceEventSlot.super.setItem(item);
                }
            });
        } else {
            super.setItem(item);
        }
    } else {
        if (slot == FUEL && getTime() >= 0) {
            Bukkit.getScheduler().scheduleSyncDelayedTask(Skript.getInstance(), new Runnable() {
                @Override
                public void run() {
                    FurnaceEventSlot.super.setItem(item);
                }
            });
        } else {
            super.setItem(item);
        }
    }
}
项目:CraftBukkit    文件:TileEntityFurnace.java   
public void burn() {
    if (this.canBurn()) {
        ItemStack itemstack = RecipesFurnace.getInstance().getResult(this.items[0]);

        // CraftBukkit start - fire FurnaceSmeltEvent
        CraftItemStack source = CraftItemStack.asCraftMirror(this.items[0]);
        org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack);

        FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(this.world.getWorld().getBlockAt(this.x, this.y, this.z), source, result);
        this.world.getServer().getPluginManager().callEvent(furnaceSmeltEvent);

        if (furnaceSmeltEvent.isCancelled()) {
            return;
        }

        result = furnaceSmeltEvent.getResult();
        itemstack = CraftItemStack.asNMSCopy(result);

        if (itemstack != null) {
            if (this.items[2] == null) {
                this.items[2] = itemstack;
            } else if (CraftItemStack.asCraftMirror(this.items[2]).isSimilar(result)) {
                this.items[2].count += itemstack.count;
            } else {
                return;
            }
        }
        // CraftBukkit end

        --this.items[0].count;
        if (this.items[0].count <= 0) {
            this.items[0] = null;
        }
    }
}
项目:Slimefun4    文件:FurnaceListener.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onSmelt(FurnaceSmeltEvent e) {
    if (BlockStorage.check(e.getBlock()) != null && BlockStorage.check(e.getBlock()) instanceof EnhancedFurnace) {
        EnhancedFurnace furnace = (EnhancedFurnace) BlockStorage.check(e.getBlock());
        Furnace f = (Furnace) e.getBlock().getState();
        int amount = f.getInventory().getSmelting().getType().toString().endsWith("_ORE") ? furnace.getOutput(): 1;
        ItemStack output = RecipeCalculator.getSmeltedOutput(f.getInventory().getSmelting().getType());
        ItemStack result = f.getInventory().getResult();
        if (result != null) result = result.clone();
        f.getInventory().setResult(null);
        if (result != null) f.getInventory().setResult(new CustomItem(result, result.getAmount() + amount > result.getMaxStackSize() ? result.getMaxStackSize(): result.getAmount() + amount));
        else f.getInventory().setResult(new CustomItem(output, output.getAmount() + amount > output.getType().getMaxStackSize() ? output.getType().getMaxStackSize(): output.getAmount() + amount));
    }
}
项目:Almura-Server    文件:TileEntityFurnace.java   
public void burn() {
    if (this.canBurn()) {
        ItemStack itemstack = RecipesFurnace.getInstance().getResult(this.items[0].getItem().id);

        // CraftBukkit start
        CraftItemStack source = CraftItemStack.asCraftMirror(this.items[0]);
        CraftItemStack result = CraftItemStack.asCraftMirror(itemstack.cloneItemStack());

        FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(this.world.getWorld().getBlockAt(this.x, this.y, this.z), source, result);
        this.world.getServer().getPluginManager().callEvent(furnaceSmeltEvent);

        if (furnaceSmeltEvent.isCancelled()) {
            return;
        }

        itemstack = CraftItemStack.asNMSCopy(furnaceSmeltEvent.getResult());

        if (this.items[2] == null) {
            this.items[2] = itemstack.cloneItemStack();
        } else if (this.items[2].id == itemstack.id) {
            // CraftBukkit - compare damage too
            if (this.items[2].getData() == itemstack.getData()) {
                this.items[2].count += itemstack.count;
            }
            // CraftBukkit end
        }

        --this.items[0].count;
        if (this.items[0].count <= 0) {
            this.items[0] = null;
        }
    }
}
项目:Tweakkit-Server    文件:TileEntityFurnace.java   
public void burn() {
    if (this.canBurn()) {
        ItemStack itemstack = RecipesFurnace.getInstance().getResult(this.items[0]);

        // CraftBukkit start - fire FurnaceSmeltEvent
        CraftItemStack source = CraftItemStack.asCraftMirror(this.items[0]);
        org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack);

        FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(this.world.getWorld().getBlockAt(this.x, this.y, this.z), source, result);
        this.world.getServer().getPluginManager().callEvent(furnaceSmeltEvent);

        if (furnaceSmeltEvent.isCancelled()) {
            return;
        }

        result = furnaceSmeltEvent.getResult();
        itemstack = CraftItemStack.asNMSCopy(result);

        if (itemstack != null) {
            if (this.items[2] == null) {
                this.items[2] = itemstack;
            } else if (CraftItemStack.asCraftMirror(this.items[2]).isSimilar(result)) {
                this.items[2].count += itemstack.count;
            } else {
                return;
            }
        }
        // CraftBukkit end

        --this.items[0].count;
        if (this.items[0].count <= 0) {
            this.items[0] = null;
        }
    }
}
项目:Craft-city    文件:TileEntityFurnace.java   
public void burn() {
    if (this.canBurn()) {
        ItemStack itemstack = RecipesFurnace.getInstance().getResult(this.items[0].getItem().id);

        // CraftBukkit start
        CraftItemStack source = CraftItemStack.asCraftMirror(this.items[0]);
        CraftItemStack result = CraftItemStack.asCraftMirror(itemstack.cloneItemStack());

        FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(this.world.getWorld().getBlockAt(this.x, this.y, this.z), source, result);
        this.world.getServer().getPluginManager().callEvent(furnaceSmeltEvent);

        if (furnaceSmeltEvent.isCancelled()) {
            return;
        }

        itemstack = CraftItemStack.asNMSCopy(furnaceSmeltEvent.getResult());

        if (this.items[2] == null) {
            this.items[2] = itemstack.cloneItemStack();
        } else if (this.items[2].id == itemstack.id) {
            // CraftBukkit - compare damage too
            if (this.items[2].getData() == itemstack.getData()) {
                this.items[2].count += itemstack.count;
            }
            // CraftBukkit end
        }

        --this.items[0].count;
        if (this.items[0].count <= 0) {
            this.items[0] = null;
        }
    }
}
项目:RoyalSurvivors    文件:SurvivorsListener.java   
@EventHandler
public void smeltFast(FurnaceSmeltEvent e) {
    if (!(e.getBlock().getState() instanceof Furnace)) return;
    Furnace f = (Furnace) e.getBlock().getState();
    if (!RUtils.isInInfectedWorld(f.getLocation())) return;
    ConfManager cm = ConfManager.getConfManager("otherdata.yml");
    Location l = f.getLocation();
    String path = "furnaces." + l.getWorld().getName() + "," + l.getBlockX() + "," + l.getBlockY() + "," + l.getBlockZ();
    if (!cm.getBoolean(path, false)) return;
    f.setCookTime((short) 140); // 7 seconds in = 3 seconds left
}
项目:Skript    文件:ExprFurnaceSlot.java   
@SuppressWarnings("unchecked")
@Override
public boolean setTime(final int time) {
    return super.setTime(time, getExpr(), FurnaceSmeltEvent.class, FurnaceBurnEvent.class);
}
项目:QuestManager    文件:CookingGui.java   
@EventHandler
public void onItemSmelt(FurnaceSmeltEvent e) {
    if (e.getBlock().getLocation().equals(furnace.getLocation())) {
        e.setCancelled(true);
    }
}
项目:Cauldron    文件:TileEntityFurnace.java   
public void smeltItem()
{
    if (this.canSmelt())
    {
        ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]);
        // CraftBukkit start
        CraftItemStack source = CraftItemStack.asCraftMirror(this.furnaceItemStacks[0]);
        org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack);
        FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(this.worldObj.getWorld().getBlockAt(this.xCoord, this.yCoord, this.zCoord), source, result);
        this.worldObj.getServer().getPluginManager().callEvent(furnaceSmeltEvent);

        if (furnaceSmeltEvent.isCancelled())
        {
            return;
        }

        result = furnaceSmeltEvent.getResult();
        itemstack = CraftItemStack.asNMSCopy(result);

        if (itemstack != null)
        {
            if (this.furnaceItemStacks[2] == null)
            {
                this.furnaceItemStacks[2] = itemstack;
            }
            else if (CraftItemStack.asCraftMirror(this.furnaceItemStacks[2]).isSimilar(result))
            {
                this.furnaceItemStacks[2].stackSize += itemstack.stackSize;
            }
            else
            {
                return;
            }
        }

        // CraftBukkit end
        --this.furnaceItemStacks[0].stackSize;

        if (this.furnaceItemStacks[0].stackSize <= 0)
        {
            this.furnaceItemStacks[0] = null;
        }
    }
}
项目:Empirecraft    文件:OnSmeltItem.java   
@EventHandler
public void onSmeltItem(FurnaceSmeltEvent event) {
    Config.getStringList("Global Settings.Unsmeltable Items").stream().filter((s) -> (event.getResult().getType().equals(Material.getMaterial(s)))).forEach((_item) -> {
        event.setCancelled(true);
    });
}
项目:SpigotSource    文件:TileEntityFurnace.java   
public void burn() {
    if (this.canBurn()) {
        ItemStack itemstack = RecipesFurnace.getInstance().getResult(this.items[0]);

        // CraftBukkit start - fire FurnaceSmeltEvent
        CraftItemStack source = CraftItemStack.asCraftMirror(this.items[0]);
        org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack);

        FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(this.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), source, result);
        this.world.getServer().getPluginManager().callEvent(furnaceSmeltEvent);

        if (furnaceSmeltEvent.isCancelled()) {
            return;
        }

        result = furnaceSmeltEvent.getResult();
        itemstack = CraftItemStack.asNMSCopy(result);

        if (itemstack != null) {
            if (this.items[2] == null) {
                this.items[2] = itemstack;
            } else if (CraftItemStack.asCraftMirror(this.items[2]).isSimilar(result)) {
                this.items[2].count += itemstack.count;
            } else {
                return;
            }
        }

        /*
        if (this.items[2] == null) {
            this.items[2] = itemstack.cloneItemStack();
        } else if (this.items[2].getItem() == itemstack.getItem()) {
            ++this.items[2].count;
        }
        */
        // CraftBukkit end

        if (this.items[0].getItem() == Item.getItemOf(Blocks.SPONGE) && this.items[0].getData() == 1 && this.items[1] != null && this.items[1].getItem() == Items.BUCKET) {
            this.items[1] = new ItemStack(Items.WATER_BUCKET);
        }

        --this.items[0].count;
        if (this.items[0].count <= 0) {
            this.items[0] = null;
        }

    }
}