Java 类net.minecraft.block.BlockBreakable 实例源码

项目:carpentersblocks    文件:BlockProperties.java   
/**
 * Returns whether block is a cover.
 */
public static boolean isCover(ItemStack itemStack)
{
    if (itemStack.getItem() instanceof ItemBlock && !isOverlay(itemStack)) {

        Block block = toBlock(itemStack);

        return block.renderAsNormalBlock() ||
               block instanceof BlockSlab ||
               block instanceof BlockPane ||
               block instanceof BlockBreakable ||
               FeatureRegistry.coverExceptions.contains(itemStack.getDisplayName()) ||
               FeatureRegistry.coverExceptions.contains(ChatHandler.getDefaultTranslation(itemStack));

    }

    return false;
}
项目:SecurityCraft    文件:BlockKeypad.java   
public boolean checkForSideTransparency(IBlockAccess world, BlockPos keypadPos, Block neighborBlock, EnumFacing side) {
    if(neighborBlock == Blocks.AIR)
        return true;

    // Slightly cheating here, checking if the block is an instance of BlockBreakable
    // and a vanilla block instead of checking for specific blocks, since all vanilla
    // BlockBreakable blocks are transparent.
    if(neighborBlock instanceof BlockBreakable && neighborBlock.toString().replace("Block{", "").startsWith("minecraft:"))
        return false;

    return true;
}
项目:SecurityCraft    文件:BlockKeypad.java   
public boolean checkForSideTransparency(IBlockAccess world, BlockPos keypadPos, Block neighborBlock, EnumFacing side) {
    if(neighborBlock == Blocks.AIR)
        return true;

    // Slightly cheating here, checking if the block is an instance of BlockBreakable
    // and a vanilla block instead of checking for specific blocks, since all vanilla
    // BlockBreakable blocks are transparent.
    if(neighborBlock instanceof BlockBreakable && neighborBlock.toString().replace("Block{", "").startsWith("minecraft:"))
        return false;

    return true;
}
项目:SecurityCraft    文件:BlockKeypad.java   
public boolean checkForSideTransparency(IBlockAccess world, BlockPos keypadPos, Block neighborBlock, EnumFacing side) {
    if(neighborBlock == Blocks.air)
        return true;

    // Slightly cheating here, checking if the block is an instance of BlockBreakable
    // and a vanilla block instead of checking for specific blocks, since all vanilla
    // BlockBreakable blocks are transparent.
    if(neighborBlock instanceof BlockBreakable && neighborBlock.toString().startsWith("net.minecraft.block"))
        return false;

    return true;
}
项目:SecurityCraft    文件:BlockKeypad.java   
public boolean checkForSideTransparency(IBlockAccess world, BlockPos keypadPos, Block neighborBlock, EnumFacing side) {
    if(neighborBlock == Blocks.air)
        return true;

    // Slightly cheating here, checking if the block is an instance of BlockBreakable
    // and a vanilla block instead of checking for specific blocks, since all vanilla
    // BlockBreakable blocks are transparent.
    if(neighborBlock instanceof BlockBreakable && neighborBlock.toString().replace("Block{", "").startsWith("minecraft:"))
        return false;

    return true;
}
项目:SecurityCraft    文件:BlockKeypad.java   
public boolean checkForSideTransparency(IBlockAccess world, BlockPos keypadPos, Block neighborBlock, EnumFacing side) {
    if(neighborBlock == Blocks.AIR)
        return true;

    // Slightly cheating here, checking if the block is an instance of BlockBreakable
    // and a vanilla block instead of checking for specific blocks, since all vanilla
    // BlockBreakable blocks are transparent.
    if(neighborBlock instanceof BlockBreakable && neighborBlock.toString().replace("Block{", "").startsWith("minecraft:"))
        return false;

    return true;
}
项目:modpack    文件:Main.java   
@EventHandler
   public void PreInit(FMLPreInitializationEvent preEvent) {

// blocks
blockDarkGlass = (BlockBreakable) new DarkGlass(Material.glass, false).setBlockName("DarkGlass").setLightOpacity(1000000);
GameRegistry.registerBlock(blockDarkGlass, "DarkGlass");

blockClearGlass = (BlockBreakable) new DarkGlass(Material.glass, false).setBlockName("ClearGlass").setLightOpacity(0);
GameRegistry.registerBlock(blockClearGlass, "ClearGlass");

blockBrightGlass = (BlockBreakable) new DarkGlass(Material.glass, false).setBlockName("BrightGlass").setLightLevel(0.8F);
GameRegistry.registerBlock(blockBrightGlass, "BrightGlass");

   }
项目:ZeldaSwordSkills    文件:ZSSItemEvents.java   
/**
 * Returns true if the ILiftBlock itemstack was able to pick up the block clicked
 * and the useBlock result should be denied
 */
private boolean blockWasLifted(World world, EntityPlayer player, ItemStack stack, BlockPos pos, EnumFacing face) {
    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();
    if (player.canPlayerEdit(pos, face, stack) || block instanceof ILiftable) {
        boolean isLiftable = block instanceof ILiftable;
        boolean isValidBlock = (block.isOpaqueCube() || block instanceof BlockBreakable) && Item.getItemFromBlock(block) != null;
        BlockWeight weight = (isLiftable ? ((ILiftable) block).getLiftWeight(player, stack, state, face)
                : (Config.canLiftVanilla() ? null : BlockWeight.IMPOSSIBLE));
        float strength = ((ILiftBlock) stack.getItem()).getLiftStrength(player, stack, state).weight;
        float resistance = (weight != null ? weight.weight : (block.getExplosionResistance(world, pos, null, null) * 5.0F/3.0F));
        if (isValidBlock && weight != BlockWeight.IMPOSSIBLE && strength >= resistance && (isLiftable || !block.hasTileEntity(state))) {
            if (world.isRemote) { // Send block's render color to server so held block can render correctly
                PacketDispatcher.sendToServer(new HeldBlockColorPacket(block.colorMultiplier(world, pos)));
            } else {
                ItemStack returnStack = ((ILiftBlock) stack.getItem()).onLiftBlock(player, stack, state);
                if (returnStack != null && returnStack.stackSize <= 0) {
                    returnStack = null;
                }
                ItemStack heldBlock = ItemHeldBlock.getBlockStack(state, returnStack);
                if (isLiftable) {
                    ((ILiftable) block).onLifted(world, player, heldBlock, pos, state);
                }
                player.setCurrentItemOrArmor(0, heldBlock);
                world.playSoundEffect(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, block.stepSound.getBreakSound(),
                        (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getFrequency() * 0.8F);
                world.setBlockToAir(pos);
            }
            return true;
        } else {
            WorldUtils.playSoundAtEntity(player, Sounds.GRUNT, 0.3F, 0.8F);
        }
    }
    return false;
}
项目:ZeldaSwordSkills    文件:ZSSItemEvents.java   
/**
 * Returns true if the ISmashBlock itemstack was able to smash up the block clicked
 * and the useBlock result should be denied
 */
private boolean blockWasSmashed(World world, EntityPlayer player, ItemStack stack, BlockPos pos, EnumFacing face) {
    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();
    boolean isSmashable = block instanceof ISmashable;
    Result smashResult = Result.DEFAULT;
    boolean wasDestroyed = false;
    if (player.canPlayerEdit(pos, face, stack) || isSmashable) {
        BlockWeight weight = (isSmashable ? ((ISmashable) block).getSmashWeight(player, stack, state, face)
                : (Config.canSmashVanilla() || isVanillaBlockSmashable(block) ? null : BlockWeight.IMPOSSIBLE));
        float strength = ((ISmashBlock) stack.getItem()).getSmashStrength(player, stack, state, face).weight;
        float resistance = (weight != null ? weight.weight : (block.getExplosionResistance(world, pos, null, null) * 5.0F/3.0F));
        smashResult = (isSmashable ? ((ISmashable) block).onSmashed(world, player, stack, pos, state, face) : smashResult);
        if (smashResult == Result.DEFAULT) {
            boolean isValidBlock = block.isOpaqueCube() || block instanceof BlockBreakable;
            if (isValidBlock && weight != BlockWeight.IMPOSSIBLE && strength >= resistance && (!block.hasTileEntity(state) || isSmashable)) {
                if (!(block instanceof BlockBreakable)) {
                    world.playSoundAtEntity(player, Sounds.ROCK_FALL, 1.0F, 1.0F);
                }
                if (!world.isRemote) { 
                    world.destroyBlock(pos, false);
                }
                wasDestroyed = true;
            }
        }
        ((ISmashBlock) stack.getItem()).onBlockSmashed(player, stack, state, face, (smashResult == Result.ALLOW || wasDestroyed));
    }
    return (smashResult == Result.ALLOW || wasDestroyed);
}
项目:ZeldaSwordSkills    文件:ItemHammer.java   
@Override
public boolean canHarvestBlock(Block block) {
    return block instanceof ISmashable || block instanceof BlockBreakable;
}
项目:ZeldaSwordSkills    文件:ItemHammer.java   
@Override
public BlockWeight getSmashStrength(EntityPlayer player, ItemStack stack, IBlockState state, EnumFacing side) {
    return (state.getBlock() instanceof BlockBreakable) ? strength.next() : strength;
}