• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IDismantleable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中cofh.api.block.IDismantleable的典型用法代码示例。如果您正苦于以下问题:Java IDismantleable类的具体用法?Java IDismantleable怎么用?Java IDismantleable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: onItemUse

import cofh.api.block.IDismantleable; //导入依赖的package包/类
public boolean onItemUse(final ItemStack par1ItemStack, final EntityPlayer player, final World world, final int x, final int y, final int z, final int par7, final float par8, final float par9, final float par10) {
    if (!player.isSneaking()) {
        return false;
    }
    if (!this.check(par1ItemStack, world)) {
        return true;
    }
    if (world.isAirBlock(x, y, z)) {
        return false;
    }
    final Block block = world.getBlock(x, y, z);
    final int meta = world.getBlockMetadata(x, y, z);
    if (block.getBlockHardness(world, x, y, z) < 0.0f && (!(block instanceof IDismantleable) || !((IDismantleable)block).canDismantle(player, world, x, y, z))) {
        return false;
    }
    if (!block.canHarvestBlock(player, meta)) {
        return false;
    }
    player.swingItem();
    if (world.isRemote || !(player instanceof EntityPlayerMP)) {
        return true;
    }
    if (!this.check(par1ItemStack, world)) {
        return true;
    }
    if (!world.isAirBlock(x, y, z) && block.getBlockHardness(world, x, y, z) >= 0.0f) {
        ((EntityPlayerMP)player).theItemInWorldManager.tryHarvestBlock(x, y, z);
    }
    return true;
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:31,代码来源:ItemPrecisionShears.java


示例2: attemptDismantle

import cofh.api.block.IDismantleable; //导入依赖的package包/类
private boolean attemptDismantle(EntityPlayer entityPlayer, Block block, World world, int x, int y, int z)
{
    if(InteroperabilityHelper.hasIDismantleable) {
        if(block instanceof IDismantleable && ((IDismantleable) block).canDismantle(entityPlayer, world, x, y, z)) {

            ((IDismantleable) block).dismantleBlock(entityPlayer, world, x, y, z, false);
            return true;
        }
    }
    return false;
}
 
开发者ID:katzenpapst,项目名称:amunra,代码行数:12,代码来源:ItemNanotool.java


示例3: onBlockStartBreak

import cofh.api.block.IDismantleable; //导入依赖的package包/类
public boolean onBlockStartBreak(final ItemStack itemstack, final int x, final int y, final int z, final EntityPlayer player) {
    final World worldObj = player.worldObj;
    if (worldObj.isRemote) {
        return false;
    }
    final Block block = worldObj.getBlock(x, y, z);
    final int meta = worldObj.getBlockMetadata(x, y, z);
    worldObj.playAuxSFXAtEntity(player, 2001, x, y, z, Block.getIdFromBlock(block) + (worldObj.getBlockMetadata(x, y, z) << 12));
    final boolean flag1 = block.canHarvestBlock(player, meta);
    if (itemstack != null) {
        itemstack.func_150999_a(worldObj, block, x, y, z, player);
        if (itemstack.stackSize == 0) {
            player.destroyCurrentEquippedItem();
        }
    }
    List<EntityItem> extraDrops = null;
    List<EntityItem> baseCapturedDrops = null;
    EventHandlerEntityItemStealer.startCapture();
    if (block instanceof IDismantleable && ((IDismantleable)block).canDismantle(player, worldObj, x, y, z)) {
        ((IDismantleable)block).dismantleBlock(player, worldObj, x, y, z, false);
    }
    else {
        block.onBlockHarvested(worldObj, x, y, z, meta, player);
        if (block.removedByPlayer(worldObj, player, x, y, z, true)) {
            block.onBlockDestroyedByPlayer(worldObj, x, y, z, meta);
            if (flag1 || player.capabilities.isCreativeMode) {
                extraDrops = EventHandlerEntityItemStealer.getCapturedEntities();
                EventHandlerEntityItemStealer.startCapture();
                block.harvestBlock(worldObj, player, x, y, z, meta);
                baseCapturedDrops = EventHandlerEntityItemStealer.getCapturedEntities();
            }
        }
    }
    EventHandlerEntityItemStealer.stopCapture();
    boolean added = false;
    if (baseCapturedDrops == null) {
        baseCapturedDrops = EventHandlerEntityItemStealer.getCapturedEntities();
    }
    if (extraDrops != null) {
        baseCapturedDrops.addAll(extraDrops);
    }
    for (final EntityItem j : baseCapturedDrops) {
        if (player.inventory.addItemStackToInventory(j.getEntityItem())) {
            added = true;
            NetworkHandler.sendParticle(worldObj, "reddust", j.posX, j.posY, j.posZ, 0.5 + this.rand.nextDouble() * 0.15, 0.35, 0.65 + this.rand.nextDouble() * 0.3, false);
        }
        if (j.getEntityItem() != null && j.getEntityItem().stackSize > 0) {
            worldObj.spawnEntityInWorld((Entity)new EntityItem(j.worldObj, j.posX, j.posY, j.posZ, j.getEntityItem()));
        }
    }
    if (added) {
        for (int i = 0; i < 10; ++i) {
            NetworkHandler.sendParticle(worldObj, "reddust", x + this.rand.nextDouble(), y + this.rand.nextDouble(), z + this.rand.nextDouble(), 0.5 + this.rand.nextDouble() * 0.15, 0.35, 0.65 + this.rand.nextDouble() * 0.3, false);
        }
        ((EntityPlayerMP)player).mcServer.getConfigurationManager().syncPlayerInventory((EntityPlayerMP)player);
    }
    return true;
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:59,代码来源:ItemPrecisionShears.java



注:本文中的cofh.api.block.IDismantleable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GroovyASTTransformation类代码示例发布时间:2022-05-21
下一篇:
Java IQueue类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap