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


Java IDismantleable类代码示例

本文整理汇总了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;未经允许,请勿转载。