当前位置: 首页>>代码示例>>Java>>正文


Java CraftEventFactory.callBlockPlaceEvent方法代码示例

本文整理汇总了Java中org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent方法的典型用法代码示例。如果您正苦于以下问题:Java CraftEventFactory.callBlockPlaceEvent方法的具体用法?Java CraftEventFactory.callBlockPlaceEvent怎么用?Java CraftEventFactory.callBlockPlaceEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.craftbukkit.event.CraftEventFactory的用法示例。


在下文中一共展示了CraftEventFactory.callBlockPlaceEvent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: interactWith

import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) {
    int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit
    if (l == 0) {
        --j;
    }

    if (l == 1) {
        ++j;
    }

    if (l == 2) {
        --k;
    }

    if (l == 3) {
        ++k;
    }

    if (l == 4) {
        --i;
    }

    if (l == 5) {
        ++i;
    }

    if (!entityhuman.a(i, j, k, l, itemstack)) {
        return false;
    } else {
        if (world.getType(i, j, k).getMaterial() == Material.AIR) {
            // CraftBukkit start - Store the clicked block
            if (CraftEventFactory.callBlockIgniteEvent(world, i, j, k, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) {
                itemstack.damage(1, entityhuman);
                return false;
            }

            CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k);
            // CraftBukkit end

            world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "fire.ignite", 1.0F, g.nextFloat() * 0.4F + 0.8F);
            world.setTypeUpdate(i, j, k, Blocks.FIRE);

            // CraftBukkit start
            org.bukkit.event.block.BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ);

            if (placeEvent.isCancelled() || !placeEvent.canBuild()) {
                placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte) 0, false);
                return false;
            }
            // CraftBukkit end
        }

        itemstack.damage(1, entityhuman);
        return true;
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:57,代码来源:ItemFlintAndSteel.java

示例2: interactWith

import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) {
    int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit

    if (l == 0) {
        --j;
    }

    if (l == 1) {
        ++j;
    }

    if (l == 2) {
        --k;
    }

    if (l == 3) {
        ++k;
    }

    if (l == 4) {
        --i;
    }

    if (l == 5) {
        ++i;
    }

    if (!entityhuman.a(i, j, k, l, itemstack)) {
        return false;
    } else {
        int i1 = world.getTypeId(i, j, k);

        if (i1 == 0) {
            // CraftBukkit start - Store the clicked block
            if (CraftEventFactory.callBlockIgniteEvent(world, i, j, k, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, entityhuman).isCancelled()) {
                itemstack.damage(1, entityhuman);
                return false;
            }

            CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k);
            // CraftBukkit end

            world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "fire.ignite", 1.0F, Item.f.nextFloat() * 0.4F + 0.8F); // CraftBukkit - fix compilation
            world.setTypeIdUpdate(i, j, k, Block.FIRE.id);

            // CraftBukkit start
            org.bukkit.event.block.BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ);

            if (placeEvent.isCancelled() || !placeEvent.canBuild()) {
                placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte) 0, false);
                return false;
            }
            // CraftBukkit end
        }

        itemstack.damage(1, entityhuman);
        return true;
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:60,代码来源:ItemFlintAndSteel.java

示例3: onItemUse

import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)
{
    int clickedX = p_77648_4_, clickedY = p_77648_5_, clickedZ = p_77648_6_; // CraftBukkit

    if (p_77648_7_ == 0)
    {
        --p_77648_5_;
    }

    if (p_77648_7_ == 1)
    {
        ++p_77648_5_;
    }

    if (p_77648_7_ == 2)
    {
        --p_77648_6_;
    }

    if (p_77648_7_ == 3)
    {
        ++p_77648_6_;
    }

    if (p_77648_7_ == 4)
    {
        --p_77648_4_;
    }

    if (p_77648_7_ == 5)
    {
        ++p_77648_4_;
    }

    if (!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_))
    {
        return false;
    }
    else
    {
        if (p_77648_3_.isAirBlock(p_77648_4_, p_77648_5_, p_77648_6_))
        {
            // CraftBukkit start - Store the clicked block
            if (CraftEventFactory.callBlockIgniteEvent(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_, org.bukkit.event.block.BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, p_77648_2_).isCancelled())
            {
                p_77648_1_.damageItem(1, p_77648_2_);
                return false;
            }

            CraftBlockState blockState = CraftBlockState.getBlockState(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_);
            // CraftBukkit end
            p_77648_3_.playSoundEffect((double)p_77648_4_ + 0.5D, (double)p_77648_5_ + 0.5D, (double)p_77648_6_ + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);
            p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, Blocks.fire);
            // CraftBukkit start
            org.bukkit.event.block.BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent(p_77648_3_, p_77648_2_, blockState, clickedX, clickedY, clickedZ);

            if (placeEvent.isCancelled() || !placeEvent.canBuild())
            {
                placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte) 0, false);
                return false;
            }

            // CraftBukkit end
        }

        p_77648_1_.damageItem(1, p_77648_2_);
        return true;
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:70,代码来源:ItemFlintAndSteel.java


注:本文中的org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。