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

项目:McMMOPlus    文件:InventoryListener.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFurnaceExtractEvent(FurnaceExtractEvent event) {
    Block furnaceBlock = event.getBlock();
    BlockState furnaceState = furnaceBlock.getState();
    ItemStack result = furnaceState instanceof Furnace ? ((Furnace) furnaceState).getInventory().getResult() : null;

    if (!ItemUtils.isSmelted(result)) {
        return;
    }

    Player player = getPlayerFromFurnace(furnaceBlock);

    if (!UserManager.hasPlayerDataKey(player) || !Permissions.vanillaXpBoost(player, SkillType.SMELTING)) {
        return;
    }

    event.setExpToDrop(UserManager.getPlayer(player).getSmeltingManager().vanillaXPBoost(event.getExpToDrop()));
}
项目:HCFCore    文件:ExpMultiplierListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onFurnaceExtract(FurnaceExtractEvent event) {
    double amount = event.getExpToDrop();
    if (amount > 0) {
        double multiplier = SettingsYML.EXP_MULTIPLIER_SMELTING;
        int result = (int) Math.ceil(amount * multiplier);
        event.setExpToDrop(result);
    }
}
项目:HCFCore    文件:ExpMultiplierListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onFurnaceExtract(FurnaceExtractEvent event) {
    double amount = event.getExpToDrop();
    if (amount > 0) {
        double multiplier = SettingsYML.EXP_MULTIPLIER_SMELTING;
        int result = (int) Math.ceil(amount * multiplier);
        event.setExpToDrop(result);
    }
}
项目:BetonQuest    文件:SmeltingObjective.java   
@EventHandler
public void onSmelting(FurnaceExtractEvent event) {
    String playerID = PlayerConverter.getID((Player) event.getPlayer());
    if (containsPlayer(playerID) && event.getItemType().equals(material) && checkConditions(playerID)) {
        SmeltData playerData = (SmeltData) dataMap.get(playerID);
        playerData.subtract(event.getItemAmount());
        if (playerData.isZero()) {
            completeObjective(playerID);
        }
    }
}
项目:Bits    文件:ConfigurationManager.java   
private static HashMap<String, Class> getEventClassAssociations()
    {
        HashMap<String, Class> classHashMap = new HashMap<String, Class>();
        classHashMap.put("block-break", BlockBreakEvent.class);
        classHashMap.put("block-place", BlockPlaceEvent.class);

//      classHashMap.put("entity-leash", PlayerLeashEntityEvent.class);
        classHashMap.put("entity-kill", EntityDeathEvent.class);
        classHashMap.put("entity-shear", PlayerShearEntityEvent.class);

        classHashMap.put("item-brew", BrewEvent.class);
        classHashMap.put("item-enchant", EnchantItemEvent.class);
        classHashMap.put("item-furnace", FurnaceExtractEvent.class);

        classHashMap.put("painting-create", HangingPlaceEvent.class);

        classHashMap.put("player-regenerate", EntityRegainHealthEvent.class);
        classHashMap.put("player-shoot", EntityShootBowEvent.class);
        classHashMap.put("player-chat", AsyncPlayerChatEvent.class);
        classHashMap.put("player-death", PlayerDeathEvent.class);
        classHashMap.put("player-sleep", PlayerBedEnterEvent.class);
        classHashMap.put("player-author", PlayerEditBookEvent.class);
        classHashMap.put("player-egg", PlayerEggThrowEvent.class);
        classHashMap.put("player-fish", PlayerFishEvent.class);
        classHashMap.put("player-eat", PlayerItemConsumeEvent.class);
        classHashMap.put("player-join", PlayerJoinEvent.class);
        classHashMap.put("player-move", PlayerMoveEvent.class);

        classHashMap.put("portal-create", PortalCreateEvent.class);

        classHashMap.put("vehicle-move", VehicleMoveEvent.class);

        classHashMap.put("world-change", PlayerChangedWorldEvent.class);

        return classHashMap;
    }
项目:CraftBukkit    文件:SlotFurnaceResult.java   
protected void b(ItemStack itemstack) {
    itemstack.a(this.a.world, this.a, this.b);
    if (!this.a.world.isStatic) {
        int i = this.b;
        float f = RecipesFurnace.getInstance().b(itemstack);
        int j;

        if (f == 0.0F) {
            i = 0;
        } else if (f < 1.0F) {
            j = MathHelper.d((float) i * f);
            if (j < MathHelper.f((float) i * f) && (float) Math.random() < (float) i * f - (float) j) {
                ++j;
            }

            i = j;
        }

        // CraftBukkit start - fire FurnaceExtractEvent
        Player player = (Player) a.getBukkitEntity();
        TileEntityFurnace furnace = ((TileEntityFurnace) this.inventory);
        org.bukkit.block.Block block = a.world.getWorld().getBlockAt(furnace.x, furnace.y, furnace.z);

        FurnaceExtractEvent event = new FurnaceExtractEvent(player, block, org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(itemstack.getItem()), itemstack.count, i);
        a.world.getServer().getPluginManager().callEvent(event);

        i = event.getExpToDrop();
        // CraftBukkit end

        while (i > 0) {
            j = EntityExperienceOrb.getOrbValue(i);
            i -= j;
            this.a.world.addEntity(new EntityExperienceOrb(this.a.world, this.a.locX, this.a.locY + 0.5D, this.a.locZ + 0.5D, j));
        }
    }

    this.b = 0;
    if (itemstack.getItem() == Items.IRON_INGOT) {
        this.a.a((Statistic) AchievementList.k, 1);
    }

    if (itemstack.getItem() == Items.COOKED_FISH) {
        this.a.a((Statistic) AchievementList.p, 1);
    }
}
项目:Almura-Server    文件:SlotFurnaceResult.java   
protected void b(ItemStack itemstack) {
    itemstack.a(this.a.world, this.a, this.b);
    if (!this.a.world.isStatic) {
        int i = this.b;
        float f = RecipesFurnace.getInstance().c(itemstack.id);
        int j;

        if (f == 0.0F) {
            i = 0;
        } else if (f < 1.0F) {
            j = MathHelper.d((float) i * f);
            if (j < MathHelper.f((float) i * f) && (float) Math.random() < (float) i * f - (float) j) {
                ++j;
            }

            i = j;
        }

        // CraftBukkit start
        Player player = (Player) a.getBukkitEntity();
        TileEntityFurnace furnace = ((TileEntityFurnace) this.inventory);
        org.bukkit.block.Block block = a.world.getWorld().getBlockAt(furnace.x, furnace.y, furnace.z);

        FurnaceExtractEvent event = new FurnaceExtractEvent(player, block, org.bukkit.Material.getMaterial(itemstack.id), itemstack.count, i);
        a.world.getServer().getPluginManager().callEvent(event);

        i = event.getExpToDrop();
        // CraftBukkit end

        while (i > 0) {
            j = EntityExperienceOrb.getOrbValue(i);
            i -= j;
            this.a.world.addEntity(new EntityExperienceOrb(this.a.world, this.a.locX, this.a.locY + 0.5D, this.a.locZ + 0.5D, j));
        }
    }

    this.b = 0;
    if (itemstack.id == Item.IRON_INGOT.id) {
        this.a.a((Statistic) AchievementList.k, 1);
    }

    if (itemstack.id == Item.COOKED_FISH.id) {
        this.a.a((Statistic) AchievementList.p, 1);
    }
}
项目:Tweakkit-Server    文件:SlotFurnaceResult.java   
protected void b(ItemStack itemstack) {
    itemstack.a(this.a.world, this.a, this.b);
    if (!this.a.world.isStatic) {
        int i = this.b;
        float f = RecipesFurnace.getInstance().b(itemstack);
        int j;

        if (f == 0.0F) {
            i = 0;
        } else if (f < 1.0F) {
            j = MathHelper.d((float) i * f);
            if (j < MathHelper.f((float) i * f) && (float) Math.random() < (float) i * f - (float) j) {
                ++j;
            }

            i = j;
        }

        // CraftBukkit start - fire FurnaceExtractEvent
        Player player = (Player) a.getBukkitEntity();
        TileEntityFurnace furnace = ((TileEntityFurnace) this.inventory);
        org.bukkit.block.Block block = a.world.getWorld().getBlockAt(furnace.x, furnace.y, furnace.z);

        FurnaceExtractEvent event = new FurnaceExtractEvent(player, block, org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(itemstack.getItem()), itemstack.count, i);
        a.world.getServer().getPluginManager().callEvent(event);

        i = event.getExpToDrop();
        // CraftBukkit end

        while (i > 0) {
            j = EntityExperienceOrb.getOrbValue(i);
            i -= j;
            this.a.world.addEntity(new EntityExperienceOrb(this.a.world, this.a.locX, this.a.locY + 0.5D, this.a.locZ + 0.5D, j));
        }
    }

    this.b = 0;
    if (itemstack.getItem() == Items.IRON_INGOT) {
        this.a.a((Statistic) AchievementList.k, 1);
    }

    if (itemstack.getItem() == Items.COOKED_FISH) {
        this.a.a((Statistic) AchievementList.p, 1);
    }
}
项目:Cauldron    文件:SlotFurnace.java   
protected void onCrafting(ItemStack p_75208_1_)
{
    p_75208_1_.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.field_75228_b);

    if (!this.thePlayer.worldObj.isRemote)
    {
        int i = this.field_75228_b;
        float f = FurnaceRecipes.smelting().func_151398_b(p_75208_1_);
        int j;

        if (f == 0.0F)
        {
            i = 0;
        }
        else if (f < 1.0F)
        {
            j = MathHelper.floor_float((float)i * f);

            if (j < MathHelper.ceiling_float_int((float)i * f) && (float)Math.random() < (float)i * f - (float)j)
            {
                ++j;
            }

            i = j;
        }

        // Cauldron start - validate inventory before attempting to cast it
        if (this.inventory instanceof TileEntityFurnace) 
        {
            // CraftBukkit start
            Player player = (Player) thePlayer.getBukkitEntity();
            TileEntityFurnace furnace = ((TileEntityFurnace) this.inventory);
            org.bukkit.block.Block block = thePlayer.worldObj.getWorld().getBlockAt(furnace.xCoord, furnace.yCoord, furnace.zCoord);
            FurnaceExtractEvent event = new FurnaceExtractEvent(player, block, org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(p_75208_1_.getItem()), p_75208_1_.stackSize, i);
            thePlayer.worldObj.getServer().getPluginManager().callEvent(event);
            i = event.getExpToDrop();
            // CraftBukkit end
        }
        // Cauldron end

        while (i > 0)
        {
            j = EntityXPOrb.getXPSplit(i);
            i -= j;
            this.thePlayer.worldObj.spawnEntityInWorld(new EntityXPOrb(this.thePlayer.worldObj, this.thePlayer.posX, this.thePlayer.posY + 0.5D, this.thePlayer.posZ + 0.5D, j));
        }
    }

    this.field_75228_b = 0;

    FMLCommonHandler.instance().firePlayerSmeltedEvent(thePlayer, p_75208_1_);

    if (p_75208_1_.getItem() == Items.iron_ingot)
    {
        this.thePlayer.addStat(AchievementList.acquireIron, 1);
    }

    if (p_75208_1_.getItem() == Items.cooked_fished)
    {
        this.thePlayer.addStat(AchievementList.cookFish, 1);
    }
}
项目:SpigotSource    文件:SlotFurnaceResult.java   
protected void c(ItemStack itemstack) {
    itemstack.a(this.a.world, this.a, this.b);
    if (!this.a.world.isClientSide) {
        int i = this.b;
        float f = RecipesFurnace.getInstance().b(itemstack);
        int j;

        if (f == 0.0F) {
            i = 0;
        } else if (f < 1.0F) {
            j = MathHelper.d((float) i * f);
            if (j < MathHelper.f((float) i * f) && Math.random() < (double) ((float) i * f - (float) j)) {
                ++j;
            }

            i = j;
        }

        // CraftBukkit start - fire FurnaceExtractEvent
        Player player = (Player) a.getBukkitEntity();
        TileEntityFurnace furnace = ((TileEntityFurnace) this.inventory);
        org.bukkit.block.Block block = a.world.getWorld().getBlockAt(furnace.position.getX(), furnace.position.getY(), furnace.position.getZ());

        if (b != 0) {
            FurnaceExtractEvent event = new FurnaceExtractEvent(player, block, org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(itemstack.getItem()), b, i);
            a.world.getServer().getPluginManager().callEvent(event);
            i = event.getExpToDrop();
        }
        // CraftBukkit end

        while (i > 0) {
            j = EntityExperienceOrb.getOrbValue(i);
            i -= j;
            this.a.world.addEntity(new EntityExperienceOrb(this.a.world, this.a.locX, this.a.locY + 0.5D, this.a.locZ + 0.5D, j));
        }
    }

    this.b = 0;
    if (itemstack.getItem() == Items.IRON_INGOT) {
        this.a.b((Statistic) AchievementList.k);
    }

    if (itemstack.getItem() == Items.COOKED_FISH) {
        this.a.b((Statistic) AchievementList.p);
    }

}
项目:Craft-city    文件:SlotFurnaceResult.java   
protected void b(ItemStack itemstack) {
    itemstack.a(this.a.world, this.a, this.b);
    if (!this.a.world.isStatic) {
        int i = this.b;
        float f = RecipesFurnace.getInstance().c(itemstack.id);
        int j;

        if (f == 0.0F) {
            i = 0;
        } else if (f < 1.0F) {
            j = MathHelper.d((float) i * f);
            if (j < MathHelper.f((float) i * f) && (float) Math.random() < (float) i * f - (float) j) {
                ++j;
            }

            i = j;
        }

        // CraftBukkit start
        Player player = (Player) a.getBukkitEntity();
        TileEntityFurnace furnace = ((TileEntityFurnace) this.inventory);
        org.bukkit.block.Block block = a.world.getWorld().getBlockAt(furnace.x, furnace.y, furnace.z);

        FurnaceExtractEvent event = new FurnaceExtractEvent(player, block, org.bukkit.Material.getMaterial(itemstack.id), itemstack.count, i);
        a.world.getServer().getPluginManager().callEvent(event);

        i = event.getExpToDrop();
        // CraftBukkit end

        while (i > 0) {
            j = EntityExperienceOrb.getOrbValue(i);
            i -= j;
            this.a.world.addEntity(new EntityExperienceOrb(this.a.world, this.a.locX, this.a.locY + 0.5D, this.a.locZ + 0.5D, j));
        }
    }

    this.b = 0;
    if (itemstack.id == Item.IRON_INGOT.id) {
        this.a.a((Statistic) AchievementList.k, 1);
    }

    if (itemstack.id == Item.COOKED_FISH.id) {
        this.a.a((Statistic) AchievementList.p, 1);
    }
}