@Override public boolean onBlockDestroyed(@Nonnull ItemStack stack, @Nonnull World world, @Nonnull IBlockState state, @Nonnull BlockPos pos, @Nonnull EntityLivingBase entity) { if (state.getBlockHardness(world, pos) != 0F) ToolCommons.damageItem(stack, 1, entity, MANA_PER_DAMAGE); return true; }
@Override public boolean onBlockDestroyed(@Nonnull ItemStack stack, @Nonnull World world, @Nonnull IBlockState state, @Nonnull BlockPos pos, @Nonnull EntityLivingBase entity) { if(state.getBlockHardness(world, pos) != 0F) ToolCommons.damageItem(stack, 1, entity, getManaPerDmg()); return true; }
@Override public boolean onBlockDestroyed(@Nonnull ItemStack stack, @Nonnull World world, @Nonnull IBlockState state, @Nonnull BlockPos pos, @Nonnull EntityLivingBase entity) { if (state.getBlockHardness(world, pos) != 0F) ToolCommons.damageItem(stack, 1, entity, getManaPerDamage()); return true; }
@Override public boolean onBlockDestroyed(@Nonnull ItemStack stack, @Nonnull World world, IBlockState state, @Nonnull BlockPos pos, @Nonnull EntityLivingBase entity) { if(usesMana(stack) && state.getBlockHardness(world, pos) != 0F) ToolCommons.damageItem(stack, 1, entity, getManaPerDamage()); return true; }
/** * Checks if this plane can handle the block at the specific coordinates. */ protected float calculateEnergyUsage( final WorldServer w, final BlockPos pos, final List<ItemStack> items ) { final IBlockState state = w.getBlockState( pos ); final float hardness = state.getBlockHardness( w, pos ); float requiredEnergy = 1 + hardness; for( final ItemStack is : items ) { requiredEnergy += is.getCount(); } return requiredEnergy; }
/** * Checks if this plane can handle the block at the specific coordinates. */ private boolean canHandleBlock( final WorldServer w, final BlockPos pos ) { final IBlockState state = w.getBlockState( pos ); final Material material = state.getMaterial(); final float hardness = state.getBlockHardness( w, pos ); final boolean ignoreMaterials = material == Material.AIR || material == Material.LAVA || material == Material.WATER || material.isLiquid(); final boolean ignoreBlocks = state.getBlock() == Blocks.BEDROCK || state.getBlock() == Blocks.END_PORTAL || state .getBlock() == Blocks.END_PORTAL_FRAME || state.getBlock() == Blocks.COMMAND_BLOCK; return !ignoreMaterials && !ignoreBlocks && hardness >= 0f && !w.isAirBlock( pos ) && w.isBlockLoaded( pos ) && w.canMineBlockBody( Platform.getPlayer( w ), pos ); }
final float hardness = bs.getBlockHardness( w, pos.getBlockPos() ) * 9.0f; if( hardness >= 0.0 )
Material mat = srcState.getMaterial(); if(!sticky && tile == null && mat.getPushReaction() == EnumPushReaction.NORMAL && srcState.getBlockHardness(world, pos2) != -1 && !srcState.getBlock().isAir(srcState, world, pos2)) { Material destMat = world.getBlockState(pos2.offset(dir)).getMaterial(); if(world.isAirBlock(pos2.offset(dir)) || destMat.isReplaceable()) {
@Override public boolean collideBurst(IManaBurst burst, EntityThrowable entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) { if(!entity.world.isRemote && !burst.isFake() && pos.getBlockPos() != null) { int harvestLevel = ConfigHandler.harvestLevelWeight; BlockPos bPos = pos.getBlockPos(); Block block = entity.world.getBlockState(bPos).getBlock(); IBlockState state = entity.world.getBlockState(bPos); int neededHarvestLevel = block.getHarvestLevel(state); if(entity.world.isAirBlock(bPos.down()) && state.getBlockHardness(entity.world, bPos) != -1 && neededHarvestLevel <= harvestLevel && entity.world.getTileEntity(bPos) == null && block.canSilkHarvest(entity.world, bPos, state, null)) { state = TECHNICAL_BLOCK_REMAP.getOrDefault(state, state); EntityFallingBlock falling = new EntityFallingBlock(entity.world, bPos.getX() + 0.5, bPos.getY(), bPos.getZ() + 0.5, state); falling.fallTime = 1; entity.world.setBlockToAir(bPos); ((WorldServer) entity.world).spawnParticle(EnumParticleTypes.FALLING_DUST, bPos.getX() + 0.5, bPos.getY() + 0.5, bPos.getZ() + 0.5, 10, 0.45, 0.45, 0.45, 5, new int[] {Block.getStateId(state)}); entity.world.spawnEntity(falling); } } return dead; }
@Override public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) { if (state.getBlockHardness(worldIn, pos) != 0) { stack.damageItem(1, entityLiving); } return true; }
@Override public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) { if (state.getBlockHardness(world, pos) != 0) { stack.damageItem(2, entityLiving); } return true; }
@Override public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) { if (state.getBlockHardness(world, pos) != 0) { stack.damageItem(2, entityLiving); } return true; }
@Override public boolean collideBurst(IManaBurst burst, EntityThrowable entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) { BlockPos coords = burst.getBurstSourceBlockPos(); if(!entity.world.isRemote && pos.getBlockPos() != null && !coords.equals(pos.getBlockPos()) && !burst.isFake() && !isManaBlock) { BlockPos pos_ = pos.getBlockPos().offset(pos.sideHit.getOpposite()); if(entity.world.isAirBlock(pos_) || entity.world.getBlockState(pos_).getBlock().isReplaceable(entity.world, pos_)) { IBlockState state = entity.world.getBlockState(pos.getBlockPos()); TileEntity tile = entity.world.getTileEntity(pos.getBlockPos()); if(state.getPushReaction() == EnumPushReaction.NORMAL && state.getBlock() != Blocks.OBSIDIAN && state.getBlockHardness(entity.world, pos_) >= 0 && tile == null) { entity.world.destroyBlock(pos.getBlockPos(), false); entity.world.setBlockState(pos_, state, 1 | 2); } } } return dead; }
float hardness = state.getBlockHardness(world, collidePos); int neededHarvestLevel = block.getHarvestLevel(state); int mana = burst.getMana();
@Override public boolean onBlockDestroyed(@Nonnull ItemStack item, @Nonnull World world, @Nonnull IBlockState bs, @Nonnull BlockPos pos, @Nonnull EntityLivingBase entityLiving) { if (bs.getBlockHardness(world, pos) != 0.0D) {// TODO if (useObsidianEffeciency(item, bs)) { extractInternal(item, DarkSteelConfig.pickPowerUseObsidian); } } if (!entityLiving.isSneaking() && entityLiving instanceof EntityPlayerMP && PlayerAOEAttributeHandler.hasAOE((EntityPlayerMP) entityLiving)) { doExplosiveAction(item, world, pos, (EntityPlayerMP) entityLiving); } return super.onBlockDestroyed(item, world, bs, pos, entityLiving); }
private boolean isBlackListedBlock(@Nonnull EntityPlayer player, @Nonnull RayTraceResult pos, @Nonnull IBlockState hitBlock) { return TeleportConfig.blockBlacklist.get().contains(hitBlock.getBlock()) && (hitBlock.getBlockHardness(player.world, pos.getBlockPos()) < 0 || !TeleportConfig.enableBlinkUnbreakableBlocks.get()); }
public static boolean isBlockBreakable(FakePlayerCore player, World worldObj, BlockPos pos) { IBlockState state = worldObj.getBlockState(pos); if (state.getBlock().isAir(state, worldObj, pos)) { return false; } if (player == null) { return state.getBlockHardness(worldObj, pos) > -1; } else { return state.getPlayerRelativeBlockHardness(player, worldObj, pos) > -1; } }
IBlockState state = world.getBlockState(pos_); Block block = state.getBlock(); if(!block.isAir(state, world, pos_) && !block.isReplaceable(world, pos_) && !(block instanceof BlockFalling) && (!(block instanceof ILaputaImmobile) || ((ILaputaImmobile) block).canMove(world, pos_)) && state.getBlockHardness(world, pos_) != -1) { TileEntity tile = world.getTileEntity(pos_);
private void affectBlock(World world, BlockPos origin, BlockPos pos, float maxHardness) { double distanceAdjustedHardness = maxHardness - origin.getDistance(pos.getX(), pos.getY(), pos.getZ()) * 15; if (distanceAdjustedHardness > 0 && distanceAdjustedHardness > world.getBlockState(pos).getBlockHardness(world, pos)) { breakBlockAndDrop(world, pos); } }
public BlockVanillaSlab(String name, IBlockState state, boolean doubleSlab) { super(name, state.getMaterial(), doubleSlab); setHardness(state.getBlockHardness(null, new BlockPos(0, 0, 0))); setResistance(state.getBlock().getExplosionResistance(null) * 5F / 3F); setSoundType(state.getBlock().getSoundType()); setCreativeTab(CreativeTabs.BUILDING_BLOCKS); }