本文整理汇总了Java中org.bukkit.event.inventory.FurnaceSmeltEvent.getResult方法的典型用法代码示例。如果您正苦于以下问题:Java FurnaceSmeltEvent.getResult方法的具体用法?Java FurnaceSmeltEvent.getResult怎么用?Java FurnaceSmeltEvent.getResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.inventory.FurnaceSmeltEvent
的用法示例。
在下文中一共展示了FurnaceSmeltEvent.getResult方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onFurnaceSmelt
import org.bukkit.event.inventory.FurnaceSmeltEvent; //导入方法依赖的package包/类
/**
* 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));
}
示例2: onEvent
import org.bukkit.event.inventory.FurnaceSmeltEvent; //导入方法依赖的package包/类
@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();
}
}
}
示例3: burn
import org.bukkit.event.inventory.FurnaceSmeltEvent; //导入方法依赖的package包/类
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;
}
}
}
示例4: smeltItem
import org.bukkit.event.inventory.FurnaceSmeltEvent; //导入方法依赖的package包/类
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;
}
}
}
示例5: burn
import org.bukkit.event.inventory.FurnaceSmeltEvent; //导入方法依赖的package包/类
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;
}
}
}