org.bukkit.event.inventory.FurnaceSmeltEvent Java Examples
The following examples show how to use
org.bukkit.event.inventory.FurnaceSmeltEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExprFurnaceSlot.java From Skript with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings({"unchecked", "null"}) @Override public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) { isEvent = matchedPattern == 0; slot = parseResult.mark; if (isEvent && slot == RESULT && !ScriptLoader.isCurrentEvent(FurnaceSmeltEvent.class)) { Skript.error("Cannot use 'result slot' outside a fuel smelt event."); return false; } else if (isEvent && slot == FUEL && !ScriptLoader.isCurrentEvent(FurnaceBurnEvent.class)) { Skript.error("Cannot use 'fuel slot' outside a fuel burn event."); return false; } if (!isEvent) setExpr((Expression<Block>) exprs[0]); return true; }
Example #2
Source File: ExprFurnaceSlot.java From Skript with GNU General Public License v3.0 | 6 votes |
@Override @Nullable public ItemStack getItem() { switch (slot) { case RESULT: if (e instanceof FurnaceSmeltEvent) return getTime() > -1 ? ((FurnaceSmeltEvent) e).getResult().clone() : super.getItem(); else return super.getItem(); case FUEL: if (e instanceof FurnaceBurnEvent) return getTime() > -1 ? ((FurnaceBurnEvent) e).getFuel().clone() : super.getItem(); else return pastItem(); case ORE: if (e instanceof FurnaceSmeltEvent) return pastItem(); else return super.getItem(); default: return null; } }
Example #3
Source File: ExprFurnaceSlot.java From Skript with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("synthetic-access") @Override public void setItem(final @Nullable ItemStack item) { if (getTime() > -1) { Bukkit.getScheduler().scheduleSyncDelayedTask(Skript.getInstance(), () -> FurnaceEventSlot.super.setItem(item)); } else { if (e instanceof FurnaceSmeltEvent && slot == RESULT) { if (item != null) ((FurnaceSmeltEvent) e).setResult(item); else ((FurnaceSmeltEvent) e).setResult(new ItemStack(Material.AIR)); } else { super.setItem(item); } } }
Example #4
Source File: EnhancedFurnaceListener.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onItemSmelt(FurnaceSmeltEvent e) { SlimefunItem sfItem = BlockStorage.check(e.getBlock()); if (sfItem instanceof EnhancedFurnace) { Furnace furnace = (Furnace) e.getBlock().getState(); int amount = furnace.getInventory().getSmelting().getType().toString().endsWith("_ORE") ? ((EnhancedFurnace) sfItem).getOutput() : 1; Optional<ItemStack> result = Optional.ofNullable(furnace.getInventory().getResult()); if (!result.isPresent()) { result = SlimefunPlugin.getMinecraftRecipeService().getFurnaceOutput(furnace.getInventory().getSmelting()); } if (result.isPresent()) { ItemStack item = result.get(); furnace.getInventory().setResult(new CustomItem(item, Math.min(item.getAmount() + amount, item.getMaxStackSize()))); } } }
Example #5
Source File: Recipes.java From ProRecipes with GNU General Public License v2.0 | 4 votes |
@EventHandler(priority=EventPriority.MONITOR) public void onSmelt(final FurnaceSmeltEvent event){ for(RecipeFurnace rec : fur){ if(rec.toBurn.getType().equals(event.getSource().getType())){ if(rec.match(event.getSource())){ ////System.out.println("Matched"); ////System.out.println("1"); Furnace f = ((Furnace)event.getBlock().getState()); Inventory inv = f.getInventory(); //f.update(); ////System.out.println(rec.result.toString()); FurnaceCraftEvent eventFurnace = new FurnaceCraftEvent(ProRecipes.getAPI().getRecipe(RecipeType.FURNACE, fur.indexOf(rec)), inv, rec.getResult(), event.getSource()); ProRecipes.getPlugin().getServer().getPluginManager().callEvent(eventFurnace); //System.out.println("1"); event.setCancelled(true); break; }else if(!rec.def){ ////System.out.println("2"); ////System.out.println("It doesnt match and it doesn't have an original"); ////////////System.out.println("Doesn't"); event.setResult(null); event.setCancelled(true); ///return; //return; //System.out.println("2"); }else{ ////System.out.println("3"); //////System.out.println("It has an original"); event.setResult(rec.original.getResult()); event.setCancelled(false); //System.out.println("3"); // return; } } } if(event.getSource().getAmount()-1 > 0){ //Check if there's source, then set a timer for the amount of time for new one to finish, then add the old one on after that. ProRecipes.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(ProRecipes.getPlugin(), new Runnable(){ @Override public void run() { //refreshCraft(((Furnace)event.getBlock().getState()).getInventory()); } }, 1); } ////System.out.println("Cancelled: " + event.isCancelled()); ////System.out.println("Done"); }
Example #6
Source File: ExprFurnaceSlot.java From Skript with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("unchecked") @Override public boolean setTime(final int time) { return super.setTime(time, getExpr(), FurnaceSmeltEvent.class, FurnaceBurnEvent.class); }